Lesson
The theory — k-means Clustering: Where You Start Decides What You Find
k-means looks for k groups by repeating two steps until nothing moves: put every point with the nearest centre, then move each centre to the mean of what it caught. What it is trying to minimise is the within-cluster sum of squares, the total squared distance from every point to its own centre, and each of the two steps can only lower it — which is the whole proof that the algorithm stops.
What each symbol means
k- how many clusters you asked for, which nothing in the data tells you
WCSS- the total squared distance from each point to its own centre
- Assumes
- That a cluster is a round blob of roughly equal size, because squared Euclidean distance to a mean cannot express anything else. Elongated, nested or very unequal groups are not found badly by k-means; they are not the kind of thing it is looking for.
Problem solved in full
-
You do not know how many clusters your data has, so you plan to read it off the elbow in the score curve. Try that reading on all four point sets and count how often it is right. The bottom panel gives you the best score at every k from 1 to 8, with the drop from the previous k drawn behind it.
-
First, why an elbow rather than a minimum. Set the point set to Three blobs and read the curve: 10.3978 at k = 1, then 5.6145, 1.0989, 0.9241, 0.8052, 0.6875, 0.6077, 0.5366. It never rises. It cannot: any clustering into k groups can be turned into one with k + 1 groups by splitting a group, and splitting can only move points closer to their own centre. Push k as far as the number of points and every point is its own cluster with the score exactly 0.
-
So the curve has no minimum to find, and the reading has to be about the drops instead. On the blobs they go 46.0%, then 80.4%, then 15.9%, 12.9%, 14.6%, 11.6%, 11.7%. The drop after k = 3 is a fifth of the drop into it — a collapse by a factor of 5.06 — and k = 3 is exactly how the data was built. The method works here, and this is the case everybody is shown.
-
Now the Lattice, which has no clusters at all. Its drops are 41.6%, 34.1%, 36.8%, 16.4%, 16.9%, 12.8%, 15.7%. There is a collapse by a factor of 2.25 after k = 4, which is exactly the shape you were told to look for. The elbow reading returns "four clusters" for a set with none.
-
The Ring next, where there genuinely are two groups. Its drops run 37.2%, 32.8%, 38.5%, 33.4%, 43.1%, 25.3%, 15.3% — no trend at all, and then two falls at the end. The sharpest collapse is after k = 6. The reading says six; the answer is two.
-
And Uneven, three clusters of different sizes: 43.8%, 48.4%, 35.4%, 24.7%, 16.1%, 14.4%, 21.8%. A smooth decline with no collapse anywhere — the sharpest is a factor of 1.53, which is not a corner. The reading gives you nothing, on data that does have three clusters in it.
Answer
One right out of four: correct on the blobs, four clusters invented on the lattice, six proposed for the ring’s two, and silence on the uneven set. The pattern is not random. The elbow is sharp exactly when the clusters are round, similarly sized and well separated — which is when you could have counted them by looking. It fades on every set where you actually needed the help. That is worth knowing before you use the curve to defend a number to somebody, and it is why the elbow sits beside the silhouette score, the gap statistic and information criteria rather than above them. None of those is on this page, and each of them is a different way of asking the same question the score curve cannot answer: not "where would k centres go", which always has an answer, but "are there groups here at all".
-
Learning path
Fitting a line to data
References (3)
- The algorithm itself. Written in 1957 for quantising a signal into levels, circulated as a Bell Labs memorandum, and not published for twenty-five years: S. P. Lloyd, “Least squares quantization in PCM.” IEEE Transactions on Information Theory 28(2), 129–137, 1982.
- The initialisation the second insight block measures — and the source of the bound that makes it worth using, which is a guarantee about the EXPECTED score rather than about any single run: D. Arthur and S. Vassilvitskii, “k-means++: The Advantages of Careful Seeding.” In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’07), 1027–1035. SIAM, 2007.
- Where the elbow reading comes from, and it was proposed with more caution than it is usually repeated with: R. L. Thorndike, “Who belongs in the family?” Psychometrika 18(4), 267–276, 1953.