k-Means Visualizer
Clustering is a loop, not an oracle: assign every point to its nearest center, move each center to its mean, repeat.
Tip: step Assign → Update by hand once, then run the piled start and compare endings.
Try this
- Walk one loop. From the spread start with k = 3: press Assign, read the colors, press Update, watch the centers jump to their means. Two presses, one visible idea.
- Pile them up. Reset to the piled start and run to the end. Same data — do the trails lead somewhere different? The empty-cluster note may make an appearance.
- Starve a center. With k = 4, drag one center far from every point and assign. It wins no members and parks in place — the lab says so instead of dividing by zero.
How to read the loop
Lloyd's iteration has two moves. Assign: every point joins its nearest center (ties break to the lowest index, so this lab is fully deterministic). Update: each center moves to the mean of its members. The loop stops when no center moves — each one already sits exactly on its cluster's average.
The honest catch: where you start shapes where you land. Different initial centers can converge to different splits of the same data, and k-means never tells you which (if any) is “true” — it minimizes within-cluster spread, nothing more. The trails show every center's journey so the dependence is visible, not philosophical.
Inspect why the starting centers matter.
Repeat the same data with different initial centers and compare the clusters. This tool demonstrates one clustering method; a cluster is not automatically a meaningful real-world group.
Create a free account All free tools
A free account opens the first 3 lessons of each subject. Other lessons require a subscription and their prerequisites.