Machine Learning · Flagship experience

K-Nearest Neighbours

What happens when prediction is literally “look at similar examples”?

Start here

What happens when prediction is literally “look at similar examples”?

KNN stores training examples and predicts from the labels or targets of nearby points. The geometry of the feature space is therefore the model.

Building interactive view…
Understand

Build the mental model

KNN stores training examples and predicts from the labels or targets of nearby points. The geometry of the feature space is therefore the model. Scale features and consider dimensionality. KNN can be expensive at inference and deteriorates in high-dimensional sparse spaces.

Click a stage to inspect what happens, what changes, and what should be checked before moving on.
Stage 1

Query point

Trace the operation itself. State what information it reads, what rule it applies, and which intermediate state or rows/columns change as a consequence. Technical context for K-Nearest Neighbours: Distance metric, scaling, k and weighting define neighbourhoods. Small k lowers bias but raises variance; large k smooths local structure.

Practitioner checkpoint: Scale features and consider dimensionality. KNN can be expensive at inference and deteriorates in high-dimensional sparse spaces.
What happens if…?

Break the assumption deliberately

Move k from 1 to a large value and watch local boundaries become smoother.

Move the control and explain what you expect before reading the visual.

Technical lens

Formalise what the visual is doing

Distance metric, scaling, k and weighting define neighbourhoods. Small k lowers bias but raises variance; large k smooths local structure.

Technical questionUse a tiny case to make the mechanism observable. Distance metric, scaling, k and weighting define neighbourhoods. Small k lowers bias but raises variance; large k smooths local structure. Verify one intermediate quantity, state change or mapping independently; then predict the consequence of this change: Move k from 1 to a large value and watch local boundaries become smoother.
Practitioner lens

Use it responsibly

Scale features and consider dimensionality. KNN can be expensive at inference and deteriorates in high-dimensional sparse spaces.

Transfer testTransfer this idea to a new example and justify each decision using this practitioner rule: Scale features and consider dimensionality. KNN can be expensive at inference and deteriorates in high-dimensional sparse spaces. Then explain what should change if you deliberately test: Move k from 1 to a large value and watch local boundaries become smoother.
Worked exploration

Use the visual as an experiment, not decoration

Place labelled points on a line and classify a new point using k=1, 3 and 5. Observe how small k reacts strongly to local noise while larger k smooths the boundary.

Technical lens

Distance metric, scaling, k and weighting define neighbourhoods. Small k lowers bias but raises variance; large k smooths local structure.

Practitioner check

Scale features and consider dimensionality. KNN can be expensive at inference and deteriorates in high-dimensional sparse spaces.

Prediction before interaction
Move k from 1 to a large value and watch local boundaries become smoother.
Exploration walkthrough

Turn the interaction into an evidence trail

Place labelled points on a line and classify a new point using k=1, 3 and 5. Observe how small k reacts strongly to local noise while larger k smooths the boundary. Before moving the control, state your prediction. After the visual changes, name the specific state, statistic, boundary or mapping that changed and explain why that change is consistent—or inconsistent—with your prediction.

  • Record one observable quantity before the interaction and the same quantity afterwards.
  • Change one factor at a time so the causal effect of the control is inspectable.
  • Use an edge or failure case to discover where the concept stops behaving as the simple story suggests.
Reference depth

Open the complete material

The flagship experience is the map. These pages contain the roads.

Continue this exact concept

Choose depth, practice or application.

These destinations are explicitly mapped to K-Nearest Neighbours; they are not generic landing-page fallbacks.