k-Means
Cluster around centroids
k-Means finds groups in unlabeled data by alternating between cluster assignment and centroid updates.
k-Means Demo
Two alternating moves: assign every point to its nearest centroid, then update each centroid to the average of its assigned points. Click the chart to add a point. Step manually to feel the rhythm, then run.
click chart to add a point · next move: assign
The two moves
assign: each point picks the closest centroid.
update: each centroid moves to the average of its assigned points.
Repeat. Both moves can only decrease (or hold) inertia — so the algorithm always converges.
Why initialization matters
Bad initial centroids can land in a local minimum and look stuck. This demo uses a k-means++ flavoured pick (first centroid random, the rest farthest-from-existing) so the first run looks sensible.