Astoundingly clear and insightful explanations. Even as an analytics practitioner, I learned so much from this video! Super awesome. Thanks so much for uploading this content.
after some weeks of learning python for environmental data science (from a FORTRAN background) this despite being basic intro to Numpy, taught me several things I was unaware of before. Thanks.
It's quite interesting I changed the python for loop implementation to 'return sum(map(operator.mul, x, w))', and the timeit outcome reached to 36.5 µs. Thanks for sharing these vidoes
Interesting. How does it compare to the list comprehension on your machine? (just asking because it's different on each machine so I don't know whether 36.5 µs would be better or worse)
@@SebastianRaschka Well, at first I tried the list comprehension and it was 66.5 μs. The functional methods are also implemented in C and this is why it outperformed the list comprehemsion
@@greatbahram So it's about twice as fast. That's interesting to know, thanks. I usually don't use much base Python when I do scientific computing, but it's still useful insight that the map func can speed things up further compared to list comprehensions
For x@(w) seems that the parentheses are also optional, so one can write even the shorter x@w. After you learn to associate the .at with dot product, becomes quick and easy to read. But I also notice that this notation doubles the %timeit timings for me from 2 micro seconds to 4 micro seconds. I guess @ is just syntactic sugar and adds one internal transformation to the execution stack. Still, between 60 to 110 times faster than python for loop. Another method would be a list comprehension, but that would actually be 3 times slower than the for loop. def mydot(v1, v2): return sum([x*y for x,y in zip(v1, v2)])
Wow! This gives so much subtle but important details about numpy.
Astoundingly clear and insightful explanations. Even as an analytics practitioner, I learned so much from this video! Super awesome. Thanks so much for uploading this content.
Thanks for the kind words, that's very motivating to hear!
after some weeks of learning python for environmental data science (from a FORTRAN background) this despite being basic intro to Numpy, taught me several things I was unaware of before. Thanks.
It's quite interesting I changed the python for loop implementation to 'return sum(map(operator.mul, x, w))', and the timeit outcome reached to 36.5 µs.
Thanks for sharing these vidoes
Interesting. How does it compare to the list comprehension on your machine? (just asking because it's different on each machine so I don't know whether 36.5 µs would be better or worse)
@@SebastianRaschka Well, at first I tried the list comprehension and it was 66.5 μs. The functional methods are also implemented in C and this is why it outperformed the list comprehemsion
@@greatbahram So it's about twice as fast. That's interesting to know, thanks. I usually don't use much base Python when I do scientific computing, but it's still useful insight that the map func can speed things up further compared to list comprehensions
For x@(w) seems that the parentheses are also optional, so one can write even the shorter x@w. After you learn to associate the .at with dot product, becomes quick and easy to read. But I also notice that this notation doubles the %timeit timings for me from 2 micro seconds to 4 micro seconds. I guess @ is just syntactic sugar and adds one internal transformation to the execution stack. Still, between 60 to 110 times faster than python for loop.
Another method would be a list comprehension, but that would actually be 3 times slower than the for loop.
def mydot(v1, v2):
return sum([x*y for x,y in zip(v1, v2)])