Each grey dot is an item, such as a shop’s customer, placed by two measurements. Nobody has labelled them, so there are no right answers to learn from. k-means looks for groups (clusters) on its own: the diamonds are its guesses for the centres of k groups.
The question: where are the groups? Press Assign, then Update, and watch the guesses improve.
k-means groups unlabelled points into k clusters by repeating two steps: assign each point to its nearest centroid, then move each centroid to the average of its points. Each step can only lower the inertia, so the algorithm always settles down, usually within a few iterations.
It settles in a local minimum, though, so a bad starting position can split one blob in two and merge two others. In practice we run it several times from different starts and keep the lowest inertia. To choose k, plot inertia against k and look for the “elbow” where adding a cluster stops helping much.
Assign colours every point by its nearest centroid. Update moves each centroid to the mean of its points. Tap the plot to grab the nearest centroid and drag it somewhere silly.
k-means groups unlabelled points into k clusters by repeating two steps: assign each point to its nearest centroid, then move each centroid to the average of its points. Each step can only lower the inertia, so the algorithm always settles down, usually within a few iterations.
It settles in a local minimum, though, so a bad starting position can split one blob in two and merge two others. In practice we run it several times from different starts and keep the lowest inertia. To choose k, plot inertia against k and look for the “elbow” where adding a cluster stops helping much.
Things to try