How do you choose the number of clusters for k-means, and why can't you just pick the that minimises the k-means objective?
Unsupervised learning, Clustering
Level L1 Beginner. Length Short. Nature Th Theoretical.
What's being asked
Whether you know that the within-cluster spread always falls as grows, and the usual ways of choosing .
Key idea
The k-means objective , where is the centre of the cluster that point belongs to, never increases with and reaches 0 at . Minimising it would always pick , one cluster per point. So use a criterion that also rewards simplicity or separation: the elbow of , the average silhouette, the gap statistic, or BIC for a Gaussian mixture.
Steps
- Explain why cannot be the criterion. With more centres the best clustering can only get tighter, and with every point is its own centre, so .
- Elbow method: plot against and pick the after which the curve flattens, where extra clusters stop helping much.
- Silhouette: for each point, , where is its mean distance to its own cluster and to the nearest other cluster. Pick the with the highest average .
- Gap statistic, which compares with its value on random uniform data; or BIC for a Gaussian mixture model, which adds a penalty for the number of parameters.
- Mention the practical side: often is set by how many groups the business can actually act on.
Common mistakes
- Treating the elbow as exact. On real data it is often unclear.
- Comparing across single runs with random starts. Bad local optima can make the curve go up; use several restarts.
How long your answer should be
4–6 sentences.
Last checked on 4 December 2026.
Read this
Previous in Unsupervised learning: Why should you usually standardise features before running principal component analysis (PCA)?
Next in Unsupervised learning: Why is k-medoids (PAM) more robust to outliers than k-means, and what does it cost you?