ML Systems Lab Open interactive version →
Foundational 38 min read clusteringtaxonomyunsupervised

Clustering Taxonomy

Partitional vs hierarchical vs density-based, no ground truth = no accuracy

You have 10 million user sessions on an e-commerce site. You want to segment users into behavioral types to personalize recommendations. Nobody labeled anything — no one told you "this is a bargain hunter, this is a researcher, this is an impulse buyer." You need to find structure in the data itself. This is unsupervised learning: discovering pattern without a target variable.

The hard part is not the algorithm — it is that without labels, you cannot measure "correct." Every clustering algorithm embeds an assumption about what good clusters look like. K-means assumes spherical clusters of equal size. DBSCAN assumes density-separated clusters. Hierarchical methods assume nested structure. Choosing the algorithm is choosing an assumption, and the right assumption depends on your data geometry. Apply the wrong one and you get confident, stable, wrong clusters.

Evaluation without labels uses three internal metrics. Silhouette score: (b - a) / max(a, b) where a = mean distance to same-cluster points, b = mean distance to nearest different-cluster points. Range [-1, 1], higher is better — but biased toward spherical clusters. Davies-Bouldin index: ratio of within-cluster scatter to between-cluster distance, lower is better. Calinski-Harabasz index: ratio of between-cluster to within-cluster dispersion, higher is better. None of these is a substitute for domain evaluation. A silhouette score of 0.7 on clusters that mix bargain hunters with power users is useless.

Two other failure modes compound as the data or K get large. The curse of dimensionality: as feature count grows, distances between points become statistically similar — with 512 features, the gap between the nearest and farthest neighbor distance shrinks, so "nearest centroid" becomes a nearly arbitrary label. Init sensitivity: K-means starts from randomly placed centroids and only guarantees convergence to a local optimum, not the global one — different random initializations can land on different final clusters, and with a large K (say 150) relative to a modest sample size (10,000 points, about 67 points per cluster on average), those clusters are small enough that which points land where becomes unstable from run to run.

The metric that matters is business validity: pull 20 random examples from each cluster and ask "does this make sense?" Can your recommendation team write a distinct strategy for each segment? If not, the clustering has not solved the problem regardless of what any internal metric says.

NOT-this: "Clustering finds the true segments in your data." Clustering finds segments consistent with the algorithm's assumptions. The "true segments" only exist if your domain actually has discrete groups, not a continuous distribution. Most behavioral data is continuous — clustering imposes discretization. Use clustering to generate hypotheses, not to discover ground truth.

Key points

Takeaway

Choosing a clustering algorithm is choosing an assumption about what "similar" means — and the algorithm will always produce confident groups regardless of whether those groups reflect real structure or just its geometric constraints.

Recap

Check your understanding

Q1. A clustering of customers produces 5 clusters with silhouette score=0.62. A domain expert says 3 of the clusters look identical in terms of purchasing behaviour. How do you reconcile this?

Q2. Which two of the following are true when comparing k-means (silhouette=0.71) against DBSCAN (silhouette=0.43) on the same dataset?

Q3. A colleague proposes using k-means with k=150 to cluster 10,000 user-behaviour vectors with 512 features. What are the failure modes?

Q4. You need to explain to a non-technical stakeholder why you cannot report "clustering accuracy." What do you say?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →