Vectorization in Python : Data Science Code

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • Crazy speedups with vectorization in Python.

Комментарии • 45

  • @jordanfogel8541
    @jordanfogel8541 2 года назад +11

    this is absolutely fantastic and so clearly and well-explained, much appreciated man!

  • @alsonyang2991
    @alsonyang2991 3 года назад +15

    Thanks for the amazing video. Concepts are well-explained.
    However, there is one possibly misleading part, which is vectorization != parallelization on the core level. For vectorization, the parallelization is actually done within one core on the register level. To prove this, try running the NumPy code in the demo, you would see the one CPU that python is running on, will boost up to 100% usage, while all the other CPUs are idled.
    Except for that, I think everything else is very clear and helpful. Thanks again!

    • @ritvikmath
      @ritvikmath  3 года назад +2

      Hey thanks for the details! I think I'll go run that experiment haha

    • @alsonyang2991
      @alsonyang2991 3 года назад

      @@ritvikmath let me know how it goes, it might also depend on the NumPy version as well😋 Cheers!

  • @vinson2233
    @vinson2233 2 года назад +6

    This concept is very important, but I see a lot of people who use Python don't know the concept of vectorization mainly because they come from C/Java/any other compiled languages where vectorization is the job of the compiler

    • @thankgodlove
      @thankgodlove Год назад

      is vectorization only in python or can it also be done in C/Java?

    • @LGseeker
      @LGseeker Год назад

      Read his comment again!

    • @thankgodlove
      @thankgodlove Год назад

      @@LGseeker wow thanks for the nice reply. NOT

  • @ShaunakDe
    @ShaunakDe 4 года назад +5

    Thanks for putting this out. This is such an under-rated skill with so few resources out there

  • @agustindangelo1412
    @agustindangelo1412 4 года назад +5

    Thanks ritvik, your videos are being pretty helpful for me! Great explanations.

  • @smudgepost
    @smudgepost Год назад

    Such an excellent video thank you for giving such a clear example. After struggling with a very slow and laggy loop earlier today I was trying to learn about multi-threading and also multiprocessing to see if I could speed up the calculation noting that CUDA is not supported on my current GPU. Then I found one of your web posts and was reading the code and testing it out without fully understanding a vectorization. To get more information I searched on RUclips later in the day and what did I find? I found the same person with the detailed video! Thank you so very much. I'm really getting my head around how natural language processing handles vast arrays of data so quickly and I believe my future is vectorization..

  • @kepstein8888
    @kepstein8888 2 года назад

    You are a great teacher. Very intuitive and down-to-earth. Thank you.

  • @Veebop100
    @Veebop100 4 года назад +5

    Summed up:
    Its still iterative, but using parallel conputation + not being strict in the Order of computation.
    Will numpy always use all 12 cores If i have a 12 cores cpu?

  • @prakashsuryakumar7284
    @prakashsuryakumar7284 3 года назад

    Thank you very much for the content. I really appreciate the amount of work and time that goes into making such videos.

  • @messi3210
    @messi3210 4 года назад +2

    Amazing video. Keep up the good work!

  • @diegoa.536
    @diegoa.536 4 года назад +1

    Great video! Everything was so clear and well explained

  • @mattkriese7170
    @mattkriese7170 Год назад

    So cool. Even as a newbie I was able to follow. Cheers 🇨🇦

  • @spearchew
    @spearchew 3 года назад +1

    good videos but i felt the reference to multiple cores in the first 2 minutes was confusing. if i understood correctly, the major speed up is that you can do operations on a massive list in one go rather than element by element... and this is true even if you have one core... (?)

  • @messi3210
    @messi3210 4 года назад +5

    Quick follow up question: are there any other libraries in python apart from numpy that leverage vectorization?

    • @ritvikmath
      @ritvikmath  4 года назад +3

      Great question. Many of the libraries you'll use in Python use vectorization since it's so powerful. Most notably, there is a library called pandas which helps us manipulate dataframes. It uses vectorization (actually uses numpy itself) to speed up it's computations. I'll be posting a video related to pandas soon.

    • @BhuvaneshSrivastava
      @BhuvaneshSrivastava 4 года назад

      @@ritvikmath great!! Waiting eagerly for your pandas video :)

    • @letsburn00
      @letsburn00 3 года назад

      Numba really really wins with vectorisation. It tends to work natively with a lot of numpy functions and if you're lucky it will just work immediately on your code.
      It dislikes object arrays, but with a little fine tuning it really works fast once you've optimised.

  • @ahmedelsabagh6990
    @ahmedelsabagh6990 2 года назад +1

    Good explanation, thanks for it.

  • @haneulkim4902
    @haneulkim4902 2 года назад

    Amazing content! I love how you explain reasons why vectorization is faster. So parallelization does not equal vectorization however it is one characteristic of vectorization, right?

  • @jimmylyu4714
    @jimmylyu4714 3 года назад

    it makes so much sense now! Thanks for the video

  • @deanmait
    @deanmait Год назад

    Great tutorial. Not sure the matrix products are as close though - i ran a few examples of the same code and the np.mean(abs(C2-C1)) difference was close to 2

  • @jessicatran5467
    @jessicatran5467 4 года назад +1

    love it! so easy to follow! thanks for your videos!

  • @sushipackdushi1
    @sushipackdushi1 Год назад

    great explanations for an intro!

  • @jakubkahoun8383
    @jakubkahoun8383 2 года назад

    Thanks you VERY VERY much. I m self tought, and this speed up my home project about 2000x :D

  • @arjungoud3450
    @arjungoud3450 2 года назад

    you are awsome man. Can you please take some time, and explain ReLU vs Sigmoid.

  • @UnpluggedPerformance
    @UnpluggedPerformance 3 года назад +1

    man your goooooood !!! nice video!

  • @amruthagaddale8551
    @amruthagaddale8551 4 года назад

    Wow... Awesome explanation

  • @BlueBirdgg
    @BlueBirdgg 2 года назад

    Great explanation! Ty!

  • @eduardosiqueirabonfim98
    @eduardosiqueirabonfim98 4 года назад +1

    great, thank you a lot!

  • @wjrasmussen666
    @wjrasmussen666 2 месяца назад

    How can we take advantage of the GPU?

  • @Johnspeed1141
    @Johnspeed1141 3 года назад

    This is might be a stupid question. When he ran the 'for' loop and gave him about 7 secs to run, the actual time it took was about 2-3 seconds to run. Is this '7 secs' different units than normal seconds? What am I missing?

  • @FitLife6767
    @FitLife6767 4 года назад

    Very good!

  • @anishbabus576
    @anishbabus576 4 года назад

    Thank you Ritvik

  • @Booogieman
    @Booogieman 4 года назад

    Cool

  • @lifefan1
    @lifefan1 2 года назад

    7:26