How do you choose k in clustering, and how do you evaluate a clustering when you have no labels?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
I try hard not to pick k in a vacuum, because the right k is almost always defined by what the clusters are for. If the output is 8 support macros, then k is near 8 and the question is whether the data supports it.
Full worked answer
I try hard not to pick k in a vacuum, because the right k is almost always defined by what the clusters are for. If the output is 8 support macros, then k is near 8 and the question is whether the data supports it.
Mechanics for k-means: the elbow on inertia is weak (inertia decreases monotonically and the elbow is frequently invisible). Silhouette is better because it penalises overlap. If I switch to a Gaussian mixture I get BIC, which is a principled model-selection criterion, plus soft assignments.
My favourite honest check is stability: cluster bootstrap resamples and measure assignment consistency across runs with adjusted Rand index. Clusters that are not stable across resamples are not real, and this catches the noise-into-clusters failure that silhouette will happily wave through.
What people forget about k-means: it assumes roughly spherical, similar-sized, similar-density clusters, and it uses Euclidean distance, so features must be scaled. It will cheerfully chop one elongated cluster into three. When those assumptions break, use DBSCAN/HDBSCAN, which infer the cluster count, handle arbitrary shapes, and label outliers as noise instead of forcing every point somewhere. The price is tuning min_samples/eps and struggling with varying density, which HDBSCAN handles better. Agglomerative gives you a dendrogram and lets you defer the k decision.
On embeddings, which is the common case now (cluster user queries to discover intents): L2-normalize and use cosine, or spherical k-means. High-dimensional Euclidean distances concentrate and become uninformative. Reduce with PCA for speed, but validate in the original space rather than in the UMAP picture.
Extrinsic beats intrinsic every time. Hand-label a sample of clusters and check they are actionable, or measure whether the clustering improves the thing it feeds. And the practical 2026 trick: after clustering queries, ask an LLM to name each cluster from its members. If it cannot produce a coherent label, that is not a cluster.
What a good answer covers
- I try hard not to pick k in a vacuum, because the right k is almost always defined by what the clusters…
- If the output is 8 support macros, then k is near 8 and the question is whether the data supports it
- Mechanics for k-means: the elbow on inertia is weak (inertia decreases monotonically and the elbow is…
- Silhouette is better because it penalises overlap
- If I switch to a Gaussian mixture I get BIC, which is a principled model-selection criterion, plus soft…
Key terms: stability · Extrinsic beats intrinsic every time
Interviewer follow-ups to expect
Silhouette says k=2, the product team needs ~10 actionable segments. What do you do?
Why do high-dimensional Euclidean distances concentrate, and what does that do to k-means specifically?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep