Clevix Ed

K-Nearest Neighbours

Coding & AI · Class 9–12 · Classification

All simulations
Drag the ★ · tap empty space to add a point

What to explore

Key ideas

kNN classifies a new point by a vote among the k closest training points. There is no training step: the model is the data itself (“lazy learning”).

Euclidean: d = √((x₁ − x₂)² + (y₁ − y₂)²)
Manhattan: d = |x₁ − x₂| + |y₁ − y₂|

Small k follows every noisy point (overfitting); very large k ignores local detail (underfitting).

Teacher tip

Act it out: put students on a grid, give each a coloured card, and let a “mystery student” ask their 3 nearest neighbours what colour they are.

Real uses: recommending films (“people near you liked…”), recognising handwritten digits.

Exam corner

In your syllabus

A free coding & ai simulation for Class 9–12.

Topics: classification, k nearest neighbours, distance, Euclidean, Manhattan, machine learning