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.
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






