liveBook · Manning

Within-cluster variation

As explained in Statistics Slam Dunk

Within-cluster variance measures the dispersion of observations around the centers of their assigned clusters.

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

How Statistics Slam Dunk covers it

How deep it goes
Defines the sum-of-squares calculation, interprets diminishing returns, and stops short of making elbow selection fully objective.
Examples
Uses scree plots and standardized NBA team payroll-and-wins clusters to make within-cluster sums of squares concrete.
What it assumes
Assumes familiarity with observations, means, distances, and K-means clustering while defining within-cluster variance through its calculation.
What you can do after
Evaluate candidate K-means solutions by plotting within-cluster sums of squares and identifying possible elbow points.
How it connects
Connects K-means clustering with centroids, Euclidean distance, inter-cluster variance, elbow method, and silhouette coefficient.

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.