Within-cluster variation measures how far observations lie from the centers of their assigned clusters. K-means seeks low within-cluster variation while separating clusters from one another. section 11.5
The within-cluster sum of squares adds the squared distances between every observation and its assigned cluster center. Increasing K usually lowers this value, but eventually produces diminishing returns. section 11.5.2
Use within-cluster variation to compare possible cluster counts:
- Plot K on the horizontal axis and within-cluster sum of squares on the vertical axis. section 11.5.2
- Look for the elbow, where adding clusters stops producing substantial reductions in variation. section 11.5.2
- Treat the elbow as a judgment rather than a guaranteed answer, because scree plots may lack a clear bend. section 11.5.2
NBA payroll and wins
A four-cluster K-means solution groups teams using standardized payroll and regular-season wins. Its reported within-cluster sums of squares are 3.519544e+16, 0, 1.012325e+16, and 2.254863e+16; the solution reports 91.6% between-cluster variation relative to total variation. section 11.5.2
options(scipen = 000) p3 <- fviz_nbclust(final_kmeans, kmeans, method = "wss") p4 <- fviz_nbclust(final_kmeans, kmeans, method = "silhouette")
Compare R scree-plot and silhouette-method code for evaluating candidate cluster counts. section 11.5.2
