sort points into groups
Each point has a class: triangle, square or circle. A test point is one whose class the racers are not shown. k-means sorts the test points into groups without seeing a class, and each group takes the class most of its points hold. k-nearest neighbours learns from training points whose class it knows. Four racers race: k-nearest neighbours, and k-means from three starts. Most test points right wins.
k-means never sees a class. It puts the 12 test points into groups, and each group takes the class most of its points hold. When classes tie for most, the group takes the tied class that comes first in the order triangle, square, circle: a group of 3 squares and 3 circles takes square. A test point is right when its group's class is its own.
k-means starts with one centre for each group: its k is the number of groups. It joins each point to its nearest centre, moves each centre to the middle of its points, and repeats until no centre moves. Each pass is a round. k-means starts three ways. From the corners: (0, 0) and (10, 10), and (0, 10) for a third group. From the first test points, one for each group. From the last test points. k-nearest neighbours learns from 9 training points with their classes. Its k is how many nearest training points vote, here 3: a test point gets the class most of them hold, or the nearest one's class when all three differ.
Most right wins. When racers tie, the one that measured the fewest distances wins; tied on that too, they all win. Each time a racer works out how far a point is from a centre or a training point, that is one distance. In each racer's picture below, the tint is the class a new point there would get. A cross marks where each k-means centre ended, and a circle is drawn round each test point its racer got wrong.
Start on two blobs in two groups.
the shape of the points
how many groups
k-means puts 12 test points into 2 groups without seeing a single class. k-nearest neighbours learns from 9 training points first.
Without scripts the keys cannot redraw, so the race shows two blobs in 2 groups.
which suits these points
On two blobs in 2 groups, k-nearest neighbours, k-means from the first test points and k-means from the last test points each got 12 of 12 test points right. Of those, k-means from the first test points measured the fewest distances: 48, against 108 for k-nearest neighbours and 72 for k-means from the last test points.
each racer's own page
k-nearest neighbours
k is 312 of 12 right, 108 distances measured
k-means
from the corners6 of 12 right, 48 distances measured
k-means
from the first test points12 of 12 right, 48 distances measured
k-means
from the last test points12 of 12 right, 72 distances measured
- a training point, which k-nearest neighbours learns from
- where a k-means centre ended
- a test point, drawn as its true class
- a test point the racer gave the wrong class
- the class the racer gives a new point there
- a spot left plain, where the racer gives no class
On the start, k-nearest neighbours measures 9 distances for each of the 12 test points: 9 times 12 is 108. k-means measures 12 times 2, 24 distances, each round: one from each test point to each centre. From the first test points, its second round moves no centre, so it stops: 2 times 24 is 48.
every shape in 2 groups, over five draws
A draw is a fresh set of points in the same shape. Each cell: test points right in five draws of 12 test points each, out of 60, and under it the distances measured. The most right on each row is in bold; where several tie, the ones that measured the fewest distances.
The start decides. On two blobs, the corners (0, 0) and (10, 10) lie just as far from one blob as from the other. From them, k-means makes two groups of 3 triangles and 3 squares each, so both take triangle and it gets only 6 of 12 right. Started at test points, it gets all 12. Over five draws, k-nearest neighbours wins only on a slant, in two groups and in three. In two groups, k-means from the first test points wins every other shape.
| the shape | k-nearest neighbours | k-means from the corners | k-means from the first test points | k-means from the last test points |
|---|---|---|---|---|
| two blobs | 60540 measured | 43312 measured | 60288 measured | 60312 measured |
| a ring round a middle | 39540 measured | 37312 measured | 39312 measured | 39384 measured |
| a slant | 56540 measured | 47432 measured | 49360 measured | 48264 measured |
| a corner | 46540 measured | 42384 measured | 55384 measured | 49312 measured |
| noisy blobs | 31540 measured | 45528 measured | 45360 measured | 44336 measured |