Lab · c02.s02.L1
Nearest-neighbour playground
A prediction is the label of the nearest stored example, or the commonest label among the k nearest, read off a ranked distance list.
Question: How can the closest example be the answer?
Frame 1 of 1: k = 1: one example decidesThe nearest stored example is the circle at distance 0.224. With k = 1 the vote has one member, so the prediction is circle; the other examples are not consulted.
k = 1: one example decides. The nearest stored example is the circle at distance 0.224. With k = 1 the vote has one member, so the prediction is circle; the other examples are not consulted.
Keyboard: Space plays or pauses, Left and Right step, Home goes to the first frame, End goes to the last frame.
Text description of this lab
A square field holds twenty examples: circles upper left, crosses upper right, diamonds along the bottom, and a star marks the query. A dashed ball grows from the star to enclose the nearest one, three, then five examples; enclosed shapes are ringed, lines tie them to the star, and a panel lists the distances and counts labels into a prediction. At centre the nearest circle gives way to two crosses when k grows, so proximity, not a fitted rule, decides.
Return to the section that hosts this lab
Caption status: synthetic. Every lab declares one of published, re-simulated, schematic, synthetic or interpolated.