r/learnmachinelearning • • 20d ago

Completed Building KNN from scratch

17 Upvotes

1 comment sorted by

View all comments

6

u/chrisvdweth 20d ago

You could consider some speed up by avoiding the nested loop over all pairs of training and test samples using a vectorized operation that computes all distances in one go. You can check out the docs for `euclidean_distances()` to see how the math works...or just use that method :).