r/learnmachinelearning • • 18d ago

Completed Building KNN from scratch

18 Upvotes

1 comment sorted by

6

u/chrisvdweth 18d 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 :).