K-Means is not always the segmentation. Sometimes it is the compression layer.
A two-stage pattern where K-Means compresses millions of customers into representative centroids, then hierarchical clustering discovers the real segment structure.
TL;DR: An algorithm does not always have to be the final model. It can prepare a feasible representation for the next layer — K-Means as compression, hierarchical clustering as structure discovery.
The Problem
When you have a very large customer base and want to use a richer clustering method that does not scale directly, you hit a wall. Hierarchical clustering can reveal useful, nested structure — but applied directly to hundreds of thousands or millions of customers, it becomes computationally expensive very quickly.
K-Means scales much better. But if you use it as the final answer too early, it can flatten meaningful structure into a fixed number of clusters.
The Approach
The practical two-stage pattern is:
Stage 1: K-Means compresses the population into representative centroids
Take 1,000,000 customers. Apply K-Means with 1,000 centres. You now have 1,000 representative centroids — a manageable view of the broader structure.
Stage 2: Hierarchical clustering explores structure across those centroids
Run hierarchical clustering on the 1,000 centroids. This reveals the nested segment structure that K-Means alone would have flattened.
The important reframing is this: K-Means is not necessarily the final segmentation. It can be a representation and scale-reduction layer. Hierarchical clustering becomes the structure-discovery layer.
This is a broader applied-ML lesson: an algorithm does not always have to be the final model. It can prepare a feasible representation for the next layer.
Key Production Detail
One important production detail: centroids represent different numbers of customers. If you cluster centroids hierarchically, account for their cluster sizes and validate the final segments after assigning customers back to them.
Start by asking: what role should each algorithm play in the pipeline?
Key Takeaway
Design insight: An algorithm does not always have to be the final model. It can prepare a feasible representation for the next layer — K-Means as compression, hierarchical clustering as structure discovery.
FAQ
What is the key takeaway from "K-Means as Compression Before Hierarchical Clustering"?
An algorithm does not always have to be the final model. It can prepare a feasible representation for the next layer — K-Means as compression, hierarchical clustering as structure discovery.
Who wrote this and what is it about?
This was written by Mahmoud Trigui, Senior Data Scientist. K-Means does not always have to be the final segmentation. Use it as a compression layer to make hierarchical clustering scalable on large customer bases.