Introduction
"Tell me who your friends are, and I'll tell you who you are." That old saying is the whole idea of k-nearest neighbours (k-NN): to predict something about a new example, find the k most similar examples in the training data and go with what they say.
- To guess a house's price, look at the prices of the 5 most similar houses nearby.
- To guess whether a film suits you, look at what the most similar viewers thought.
k-NN is the classic instance-based method (Foundations, topic 1.4): it doesn't build a model during training — it simply stores the data and does the work at prediction time. That makes it one of the easiest algorithms to understand, and a useful baseline.