K-means and hierarchical clustering with Python
Where we such clusters had
As made us nobly wild, not mad
Robert Herrick
Some algorithms are examples of what’s known as supervised learning, in that they start with a set of labeled data and use that as the basis for making predictions about new, unlabeled data. Clustering, however, is an example of unsupervised learning, in which we work with completely unlabeled data (or in which our data has labels but we ignore them).
The Idea
Whenever you look at some source of data, it’s likely that the data will somehow form clusters. A data set showing where millionaires live probably has clusters in places like Beverly Hills and Manhattan. A data set showing how many hours people work each week probably has a cluster around 40 (and if it’s taken from a state with laws mandating special benefits for people who work at least 20 hours a week, it probably has another cluster right around 19). A data set of demographics of registered voters likely forms a variety of clusters (e.g., “soccer moms,” “bored retirees,” “unemployed millennials”) that pollsters and political consultants likely consider relevant.
There is generally no “correct” clustering. An alternative clustering scheme might group some of the “unemployed millenials” with “grad students,” ...
Get K-means and hierarchical clustering with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.