k-nearest neighbours
Tap anywhere to classify a point. Change k and watch the vote — and the borders — shift.
Tap anywhere to classify a point. Change k and watch the vote — and the borders — shift.
k-NN does no training at all. To classify a new point it finds the k closest labelled points and lets them vote. Small k follows every wobble in the data (jagged borders, sensitive to noise). Large k smooths the borders but can drown out small groups.
What counts as “close” depends on the distance metric. Euclidean measures in a straight line, so the neighbourhood is a circle. Manhattan adds up horizontal and vertical steps, so it is a diamond. With two classes and an even k, the vote can tie, which is why people usually pick an odd k.
The 5 nearest points lie within 1.13 units (euclidean). Majority wins.
k-NN does no training at all. To classify a new point it finds the k closest labelled points and lets them vote. Small k follows every wobble in the data (jagged borders, sensitive to noise). Large k smooths the borders but can drown out small groups.
What counts as “close” depends on the distance metric. Euclidean measures in a straight line, so the neighbourhood is a circle. Manhattan adds up horizontal and vertical steps, so it is a diamond. With two classes and an even k, the vote can tie, which is why people usually pick an odd k.
Things to try