← back

k-means clustering

click to drop points, then cluster

How it works

Pick K random centroids. Assign each point to its nearest centroid. Recompute each centroid as the mean of its assigned points. Repeat.

Converges when assignments stop changing. The result depends on the initial centroid positions — run it multiple times to see different outcomes.

Minimizes total within-cluster variance — the sum of squared distances from each point to its centroid.

3