KNN (Neighbors)

KNN looks at the closest examples and copies the group most of them belong to.

What it does

KNN looks at the closest examples and copies the group most of them belong to.

K: Number of neighbors • Proximity: How close items are

How it works

  • Put the new item on a map with old examples.
  • Find the closest neighbors.
  • Give the new item the label most nearby neighbors have.

Uses and applications

  • A music app can find songs similar to songs you already like.
  • A photo app can group a new picture with similar pictures.
  • A store can suggest products close to what you bought before.

In short

Nearby things are often alike, like “birds of a feather flock together.”

Related methods

  • K-Means: Also measures distance between points, but to form groups without labels.
  • Decision Tree: Classifies with learned questions instead of nearby neighbours.
  • Collaborative Filtering: Recommends from similar users, a neighbour-based idea.

Back to Prediction and classification · All topics

The interactive demonstration and the Python walkthrough for this topic need JavaScript.