liveBook · Manning

Centroid

As explained in Statistics Slam Dunk

A centroid is the central position of a set of points, commonly calculated as the coordinate-wise mean.

A centroid is the mean, or central position, of the points assigned to a cluster. K-means uses centroids to organize data into nonoverlapping groups. section 11.5

K-means repeatedly updates centroids through this process:

  • Initialize K centroids randomly. section 11.5
  • Assign each data point to its nearest centroid, typically using Euclidean distance. section 11.5
  • Recalculate each centroid as the mean of its assigned points. section 11.5
  • Stop when centroids become fixed or the maximum iteration limit is reached. section 11.5

NBA payroll and wins

With four clusters, R calculates centroids from NBA team payrolls and regular-season wins. Each centroid reports the salary and win means for its cluster, while every team receives a cluster assignment. section 11.5.2

k <- kmeans(final_kmeans, 4, iter.max = 25, nstart = 25) 
print(k)
## K-means clustering with 4 clusters of sizes 15, 1, 3, 11
##
## Cluster means:
##   salarytotal wintotal
## 1  1366605768 700.8667
## 2  2034231301 626.0000
## 3  1763863525 835.0000
## 4  1490569128 746.0000
##
## Clustering vector:
## CHA NOP ATL BOS BKN CHI CLE DAL DEN DET GSW HOU IND LAC LAL MEM MIA MIL 
##   1   1   1   4   4   1   4   3   1   1   1   4   4   1   3   4   4   1 
## MIN NYK OKC ORL PHI PHO POR SAC SAS TOR UTA WAS 
##   1   2   1   4   4   1   3   1   4   1   1   4 
##
## Within cluster sum of squares by cluster:
## [1] 3.519544e+16 0.000000e+00 1.012325e+16 2.254863e+16
## (between_SS / total_SS =  91.6 %)
##
## Available components:
## 
## [1] "cluster"      "centers"      "totss"        "withinss"    
## [5] "tot.withinss" "betweenss"    "size"         "iter"        
## [9] "ifault"

Inspect the R output for cluster sizes, centroid means, team assignments, within-cluster sums of squares, and between-cluster variation. section 11.5.2

How Statistics Slam Dunk covers it

How deep it goes
Explains centroids through iterative assignment, mean recalculation, convergence, and within-cluster variation.
Examples
Uses NBA team payrolls and regular-season wins to calculate four cluster centroids and assign every team.
What you can do after
Apply it via base R's kmeans() and interpret cluster means as centroids.
How it connects
Connects centroids to K-means clustering, Euclidean distance, cluster assignment, and within-cluster variance.

Also explained in

Compare how 7 books explain centroid →

Related concepts

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.