12.3 \(k\)-Means

Where hierarchical methods build a whole tree, \(k\)-means fixes the number of clusters in advance and partitions the data directly, minimising the within-cluster sum of squares \[\sum ^{k}_{j=1}\sum _{\underline {x}\in C_j} \left \|\underline {x}-\overline {\underline {x}}_j\right \|^{2}.\] The algorithm alternates two steps until nothing changes: assign each observation to the nearest centroid, then recompute the centroids.

Note 12.4. Three properties matter in use. The algorithm converges, but only to a local minimum, and different starting points give different answers — so it should be run repeatedly from random starts. It requires \(k\) in advance, and the criterion cannot choose \(k\), since the within-cluster sum of squares decreases whenever \(k\) increases; the elbow of that curve against \(k\) is used in the same spirit, and with the same imprecision, as the scree plot of Section 4.5. And minimising a sum of squared Euclidean distances biases the result toward spherical clusters of comparable size, so genuinely elongated groups are routinely split.

Note 12.5. A clustering is a hypothesis, not a finding. Any of these algorithms will partition data that has no group structure whatever, and will do so confidently. Before interpreting clusters, check that they persist under a different distance, a different linkage or a different \(k\); that they are separated on variables not used to construct them; and that they mean something in the subject the data came from. None of these is a significance test, because none exists.

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.