Theory of Intelligence
MACHINE LEARNING•Classic Algorithms•Instance Based And Probabilistic Models•4.1 k-Nearest Neighbors

Introduction

Predict from the most similar training examples: how k-NN works, how to choose k and the distance, and why it struggles in high dimensions.

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.

Discuss theoretical concepts, mathematical formulas, and architectural foundations.

Supports inline code with `backticks`
No comments yet. Be the first to start the discussion!