The Real Python Podcast cover image

Using NumPy and Linear Algebra for Faster Python Code

The Real Python Podcast

00:00

How Are Vectors Helping With Machine Learning?

The k-nearest nagres algorithm actually uses this as part of its implementation. As your lists grow, you end up with slower and slower operations. So instead of storing these two lists as lists, what you can do is convert the data in those lists into arrays. And we basically just use this subtract method in NumPy. It's much, much faster. I've done some experiments again. If you watch the talk, you'll sort of see solid numbers with the examples that I've used. It's made my code up to four times faster. With much bigger data sets, you're probably going to see more improvements. Yeah.

Transcript
Play full episode

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app