K-means

K-means partitions data into k clusters by alternating two steps: assigning each point to the nearest centroid, then recomputing the centroids. It minimizes inertia. It assumes rather spherical groups, requires k to be set, depends on initialization, and needs standardized variables.

Example

KMeans(n_clusters=4, n_init=10, random_state=42).fit(X_s)

Related concepts

The whole glossary