Skip to content
Statistics

How can we select K for K-means?

Domain knowledge first, then the elbow of inertia against k, average silhouette, or the gap statistic. Inertia falls monotonically, so the elbow is often ambiguous; silhouette scores separation as well as compactness. If a downstream use defines the segments, let that pick k.

Proposed by @Al_Grigor

datasciencetrivia.com

Card 1 of 259. Answer: Domain knowledge first, then the elbow of inertia against k, average silhouette, or the gap statistic. Inertia falls monotonically, so the elbow is often ambiguous; silhouette scores separation as well as compactness. If a downstream use defines the segments, let that pick k.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

There is no single correct rule. Use domain knowledge first, then diagnostics such as the elbow method, the average silhouette score and the gap statistic, which compares clustering tightness with random reference data. Each fits k-means over a range of k and compares results.

The elbow method plots inertia, the within-cluster sum of squared distances, against k. Inertia keeps falling as k grows, so you look for the bend: if k = 1 to 5 give 1000, 450, 200, 170 and 150, the gains flatten after k = 3. A point's silhouette is (b − a) / max(a, b), with a its mean distance to its own cluster and b to the nearest other cluster; pick the k with the highest average.

Scale features first and run several initializations, since k-means finds local optima. If no k looks clean, the data may lack round clusters: try a Gaussian mixture chosen by BIC, or DBSCAN. If a downstream use defines the segments, such as five sales tiers, let it set k.

All questions