Clustering for Segmentation
Let the data draw the segment boundaries
Clustering groups similar customers, users, or transactions using distance in a feature space. K-means is the everyday workhorse for turning a raw base into behaviorally distinct segments.
What you will learn
- Explain how k-means assigns points to centers
- Choose the number of clusters with the elbow method
- Validate clusters on business meaning, not just inertia
What is this?
Clustering is an unsupervised method that partitions customers into K groups so points within a group are near each other and far from other groups. K-means alternates between assigning points to the nearest center and moving each center to its group's mean. The output is segment labels you then inspect for business meaning.
Why do you need it?
- It finds segments in data whose boundaries your RFM cutoffs would have missed.
- It works the moment you have a feature table, with no labeled outcome to train on.
- It automates cohort discovery as your base changes.
Mental model
Rainclouds forming over a landscape of dots
Clusters forming in feature space
No one labels which dot belongs to which cloud; the density and distance draw the boundaries themselves.
How it works
- Choose features that capture the decision you care about (value, usage, support load).
- Standardize the features so no single one dominates distance.
- Run k-means for several K, plot inertia to find the elbow, and pick K.
- Label and profile each cluster; validate that clusters differ on metrics that matter.
Points are assigned to the nearest center; centers then move to their group mean.
In production
- A subscription company clusters on spend, usage depth, and tickets to size retention programs.
- Marketplace teams segment buyers by category mix to optimize the catalog.
- Support groups prioritize routing by cluster-driven predicted complexity.
Best practices
- Standardize features before k-means; raw spend will dominate otherwise.
- Run with a fixed random seed and n_init multiple times so labels are reproducible.
- Judge clusters by their business profile (do they differ on revenue?) more than the math.
Common mistakes
- Choosing K by the loudest inertia bend and ignoring whether clusters are actionable.
- Expecting k-means to handle strongly overlapping, elongated groups gracefully.
- Forgetting that cluster labels shift run-to-run — version them.
Debugging tips
- If a cluster is 90% of the base, re-scale features or reduce outlier dominance.
- If clusters split on irrelevant dimensions, drop those features from the input set.
Interview checkpoint
Quick quiz
In k-means, each iteration
Clusters should ultimately be judged by