Study Atlas › Computer Science › Machine learning

Clustering and unsupervised learning

Finding groups or structure in unlabelled data.

Edited by Alex C, EduAlx · Sources cited below

Explanation

k-means (Lloyd, 1957/1982) alternates assigning points to nearest centroids and recomputing centroids. Hierarchical clustering builds a dendrogram. DBSCAN finds density-based clusters and outliers. Dimensionality reduction (PCA, t-SNE, UMAP) visualises high-dimensional data, as in single-cell genomics.

Example

Segmenting customers by purchase behaviour for targeted marketing.

Code

from sklearn.cluster import KMeans
labels = KMeans(n_clusters=4, n_init=10).fit_predict(X)

How it works, step by step

  1. Choose k and initial centroids
  2. Assign each point to its nearest centroid
  3. Recompute centroids
  4. Repeat until assignments stop changing

Open the interactive page with diagrams →

People behind it

References

  1. S. P. Lloyd, IEEE Trans. Inf. Theory 1982, 28, 129–137.

Textbooks

Related topics

Decision trees and ensemble methodsPython programming essentialsTesting and debuggingReinforcement learningHuman–computer interaction and usabilityNatural language processingError-detecting and error-correcting codesComputer vision and convolutional neural networksAlgorithms and Big-O complexitySearch engines and PageRank