liveBook · Manning

K-means clustering

As explained in Grokking Machine Learning, Second Edition

K-means clustering is an iterative algorithm that assigns data points to clusters around movable centers of mass.

K-means clustering groups similar data points by choosing random centers of mass and moving them closer to the points until they settle into useful positions. section 2.11

A simple way to picture the process is:

  • Start with several randomly placed centers. section 2.11
  • Move the centers toward the data points they represent. section 2.11
  • Use the resulting groups to find patterns in unlabeled data, such as customer segments or recommendation groups. section 2.11
Figure 2.5 A plot of the email dataset. The horizontal axis corresponds to the size of the email and the vertical axis to the number of recipients. We can see three well-defined clusters in this dataset.

An email dataset plotted by message size and recipient count forms three visible clusters; a companion view groups those emails into three categories. section 2.11

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines iterative movement of random centers toward points, but defers detailed treatment of unsupervised-learning algorithms.
Examples
Uses an email dataset plotted by message size and recipient count, producing three visible categories.
What you can do after
Understand K-means as an iterative method for grouping points around movable centers.
How it connects
Connects K-means with unsupervised learning, hierarchical clustering, DBSCAN, and Gaussian mixture models.

Also explained in

Compare how 12 books explain K-means clustering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.