Advanced Analytics
Intermediate 15 min read Advanced Analytics

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.

clusteringk-meansdistanceelbowunsupervisedsegmentation
Before we start

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
Introduction

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.

Motivation

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.
Think about it

Mental model

Imagine

Rainclouds forming over a landscape of dots

Think of

Clusters forming in feature space

No one labels which dot belongs to which cloud; the density and distance draw the boundaries themselves.

Mechanics

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.

Scale
Initialize
Assign
Re-center
Label
Real world

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.
Guidelines

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.
Watch out

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.
When things break

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.
Interviews

Interview checkpoint

Test yourself

Quick quiz

0/2
1

In k-means, each iteration

2

Clusters should ultimately be judged by

Go deeper

Official documentation