Lesson 14: Clustering and Finding Groups
Classification sorts things into categories you already know. Clustering finds groups you did not know were there. Given a table of customers, with no labels at all, clustering can reveal that they fall into a few natural types — the bargain hunters, the regulars, the occasional big spenders — and those groups can then guide decisions. This is unsupervised learning: the data has no answers attached, and the algorithm's job is to find structure on its own.
The best-known clustering method is k-means. You choose how many groups, k, you want; the algorithm picks k starting points, assigns every observation to the nearest one, moves each starting point to the centre of its group, and repeats until the groups stop changing. The result is k clusters, each described by its centre. The method is simple and fast, which is why it is so widely used — and it has a clear weakness: it assumes the groups are roughly round and similar in size, and it will happily split a single stretched-out group into two.
Choosing k and Checking the Result
Choosing k is the hardest part, because the data does not tell you. A common approach is to run k-means for several values of k and plot how much the points vary within their clusters: the variation falls as k grows, but the improvement slows down, and the "elbow" of the curve suggests a reasonable k. But the elbow is a guide, not a rule — and the real test is whether the groups make sense. Do the clusters correspond to something you can describe and use? A clustering that produces groups nobody can explain is usually a clustering to distrust.
Clustering also needs care with scale. If one measurement is in thousands and another is in single digits, the large one will dominate the distances, and the clusters will reflect that one variable alone. Standardising — rescaling each column so it has a similar spread — is usually the first step, and forgetting it is the most common clustering mistake.
What Clustering Cannot Do
Clustering finds groups; it does not name them, and it does not prove they are real. The groups are a suggestion, to be checked against what you know and tested on new data. Two analysts can cluster the same data and get different groups, both defensible, because the choice of k and of the measurements shapes the answer. That is not a failure of the method — it is the nature of unsupervised learning. Report what you did, show the groups, and let the reader judge whether they are useful.
Clusters That Mislead
Clustering can produce groups that look meaningful but are not. The most common trap is clustering on a variable that dominates the distances — for example, grouping customers mostly by how much they spend, because spending is measured in thousands while everything else is measured in single digits. The clusters then say little more than "big spenders and small spenders", which you already knew. Standardising the variables helps, but it is not a cure: the choice of which variables to include shapes the clusters more than any algorithm does, and two reasonable choices can give two different answers.
The remedy is to treat clusters as hypotheses, not findings. Show the clusters, describe them in plain language, and check them against something outside the clustering itself: do the groups differ in a way you did not use to build them? Do they hold up on new data? Would a different choice of variables give the same groups? A cluster that survives those checks is worth reporting; one that does not is worth dropping, however neat it looked.
Checking Clusters Against Reality
The strongest check on a clustering is one that uses information the clustering never saw. If you clustered customers by what they buy, check whether the groups also differ in something else — how often they visit, how long they have been customers, or whether they respond to offers. If the groups differ on those outside measures too, they are capturing something real about behaviour, not merely an artefact of the variables you chose. If they do not differ at all, the clusters may be a neat pattern in the data with no meaning outside it. A clustering that predicts nothing new is a description, not a discovery, and it should be reported as one.
Key Terms
- Clustering
- Finding natural groups in data that has no labels.
- Unsupervised learning
- Learning from data with no answers attached, such as clustering.
- k-means
- A clustering method that splits data into k groups around k centres, repeated until stable.
- Centroid
- The centre of a cluster — the average of the points in it.
- Elbow method
- Choosing k by looking for the bend in the plot of within-cluster variation against k.
- Standardising
- Rescaling each column so measurements with different units have comparable spread.
Discussion Questions
- Classification and clustering both produce groups. What is the fundamental difference between them?
- Why would k-means split one long, stretched-out group into two? What does that tell you about its assumptions?
- Two analysts cluster the same data and get different groups. Is one of them wrong?
Practice Questions
- What is the difference between classification and clustering?
- How does k-means work, in brief?
- Why must measurements be standardised before clustering?
- What is the elbow method?
- Why should you distrust clusters that nobody can describe or use?
Show answers
- Classification sorts things into categories you already know, using labelled examples; clustering finds groups in data with no labels at all.
- Pick k starting points, assign each observation to the nearest one, move each point to the centre of its group, and repeat until the groups stop changing.
- Because a variable measured in thousands would otherwise dominate the distances and the clusters would reflect that one variable alone.
- Run k-means for several values of k and plot the within-cluster variation; the bend — the elbow — suggests a reasonable number of groups.
- Because the real test of a clustering is whether the groups make sense and are useful — groups with no interpretation may be an artefact of the method rather than real structure.