Vismo · Create · Library · Topics · Guides · Pricing

k-nearest neighbours: ask the closest points

Two labeled classes of points sit on a plane alongside one new, unlabeled point. For k = 1, 3, and 7, the animation highlights the k closest neighbors, tallies their class labels, and shows the majority vote assigning the new point's class. A closing note contrasts small k (sensitive, noisy) versus large k (smoother, more biased) choices. Useful for students and teachers introducing instance-based learning, where prediction relies directly on stored data rather than a trained parametric model.

16:9 · every frame verified for overlaps, spacing and edges before rendering

The prompt that made it

Two classes of points and a new point; for k = 1, 3 and 7 the k nearest are highlighted, counted and the majority decides, with a note on small versus large k. No training step: the data is the model.

Make your own version

Make the next one in this series

Related animations

Feature Engineering For Numerical Data
Feature Engineering For Numerical Data

This animation walks through how raw numerical data becomes usable features for machine learning. It visualize…

K-Nearest Neighbors Classification Explained
K-Nearest Neighbors Classification Explained

This animation shows how the K-nearest neighbors algorithm classifies a new data point using labeled training …

Feature Engineering For Numerical Data
Feature Engineering For Numerical Data

An animated walkthrough of preparing numerical features for machine learning, covering how to represent data a…

Anatomy Of A CPU Context Switch
Anatomy Of A CPU Context Switch

An animated breakdown of how a single CPU core creates the illusion of running multiple programs at once. The …

What Really Happens When You Zip A File
What Really Happens When You Zip A File

An animated walkthrough of file compression internals, moving from a repetitive text file to the ZIP container…

Modular Functions In A C++ Calculator
Modular Functions In A C++ Calculator

A line-by-line walkthrough of a C++ program that doubles a number using two functions: one that prints a heade…