liveBook · Manning

Centroid

As explained in Data Without Labels

A centroid is the arithmetic mean position of a set of points and represents a cluster in centroid-based clustering.

A centroid is the mean position of the points in a cluster. In centroid-based clustering, it represents that cluster: a point closer to the centroid is treated as more similar to the cluster. Distance therefore matters alongside the centroid; Euclidean distance is commonly used, while other distance measures describe different notions of closeness. section 2.3.1 section 2.3

K-means puts centroids to work in a repeating cycle:

  • Choose the number of clusters, k, and initialize that many centers. section 2.3.1
  • Assign each point to its nearest center, then move each center to the mean of its assigned points. section 2.3.1
  • Recalculate distances and assignments until the clustering no longer improves. section 2.3.1
Figure 2.7 The centroids are recalculated in step 4. In step 5, the data points are again reassigned new centers. In step 6, the centroids are again readjusted as per the new calculations.
figure

Follow the changing centers and point assignments: updating a centroid can change which cluster a point belongs to on the next pass. section 2.3.1

Inspect centroids in a vehicle-clustering workflow

Load the vehicle data, check its contents and missing values, and standardize the numeric features before fitting k-means. An elbow plot of average distance to the nearest center supports k=3 for this dataset. Fit `KMeans(n_clusters=3, n_init=15, random_state=2345)` on `X_standard`, then retrieve `kmeans.cluster_centers_` to profile the resulting clusters. The centers are expressed in the standardized feature space used for fitting; cluster labels and selected features can also be plotted to inspect the grouping. section 2.3.5

Treat a centroid as a useful summary, not a guarantee of a stable or meaningful cluster. Different choices of k change the result; random initial centers can change the solution, and outliers can distort it. Try multiple initializations and inspect the resulting groups in their data context. section 2.3.4 section 2.3.5

How Data Without Labels covers it

How deep it goes
Works through iterative assignment and mean-based center updates, then retrieves fitted centers; defers further centroid mathematics to an appendix.
Examples
Uses an illustrated three-center iteration and a standardized vehicle dataset clustered and profiled with Python.
What it assumes
Assumes comfort with numeric features and distance comparisons; defers detailed centroid and norm mathematics.
What you can do after
Apply it via scikit-learn to retrieve cluster centers and use them to profile a fitted vehicle-clustering result.
How it connects
Links centroids to k-means clustering, distance metrics, the elbow method, initialization, and outliers.

Also explained in

Compare how 7 books explain centroid →

Related concepts

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