Apex › Storage & databases

How k-means finds clusters (unsupervised)

Group unlabeled points into k clusters by alternating two trivial steps: assign each point to its nearest center, then move each center to the mean of its points. Both steps only shrink the total squared distance (inertia), so it drops monotonically and converges in a few rounds — on round blobs it recovers them cleanly (inertia 0.795, ARI 1.00). Then break it: switch to two concentric rings and watch k-means slice a straight line through both (ARI collapses to ~0 — its round objective can’t follow a non-convex shape, which is why DBSCAN exists), or re-seed to strand a center in a worse local optimum. Live.

More in Storage & databases