Open Agent School · Public worked example

K-means: meaning and example

Welcome! Take one idea with you today.

K-means partitions points into a chosen number of groups by minimizing squared distance to each group's center. A common algorithm alternates assigning points to their nearest center and moving centers to the means of assigned points.

Picture it: For one-dimensional values [0, 2, 8, 10] and two groups, centers 1 and 9 give assignments [0, 2] and [8, 10]. Squared distances are 1, 1, 1, and 1, totaling 4.

What is easy to mix up?

Cluster numbers are arbitrary identifiers. You must inspect examples and task usefulness before attaching semantic labels or making decisions about people.

Teaching example by Open Agent School. Source: scikit-learn: K-means.