K-Means Clustering Playground

K-means groups unlabeled points into k clusters. Click on the canvas to add points, pick k, then watch the algorithm step by step: assign each point to the nearest centroid, move the centroids to the mean, repeat until nothing changes.

Clustering Visualization not started
Controls
Number of clusters k
Points
0
SSE (inertia)
Iterations
0
Converged
How it works: K-means minimizes the sum of squared distances (SSE) between each point and its cluster's centroid. Each Step does one full pass: assign every point to the nearest centroid, then move each centroid to the average of its points. When no point changes cluster, the algorithm has converged. K-means is fast but sensitive to the starting centroids — try Generate data, change k, and compare the SSE you end up with.
What's happening here? Imagine sorting a pile of mixed coins by eye: you pick a few "reference" coins, put every coin next to the closest reference, then move each reference to the center of its pile, and repeat. That's k-means. The centroids (white cores with colored rings) are the references. Notice how clusters with different k produce very different groupings — the algorithm finds a grouping, not necessarily the grouping, and k is something you choose from domain knowledge.