The Elbow Method for Finding K
The Elbow Method plots within-cluster inertia against the number of clusters K and identifies the “elbow” — the point where adding more clusters gives diminishing returns.
Plotting Inertia vs. K
As K increases, inertia always decreases. The optimal K is where the curve bends sharply — further increases give smaller reductions, forming an elbow shape.
Elbow Plot Code
Interpreting the Elbow
The elbow is the K value after which inertia decreases only marginally. For the blob dataset above, the elbow is at K=4, reflecting the true number of clusters.
When the Elbow is Ambiguous
Real-world data often produces smooth curves without a clear elbow. In such cases, supplement the elbow plot with the Silhouette Score (objective metric) and domain knowledge to select K.
Automated Elbow Detection
Limitations
The Elbow Method is a heuristic — it does not guarantee the statistically optimal K, and is unreliable for datasets with overlapping or non-spherical clusters.
Complementary Methods
Use the Elbow Method alongside the Silhouette Score, Gap Statistic, and domain expertise. For hierarchical clustering, the dendrogram can also suggest natural cluster counts. No single method should be used in isolation.