Clustering

Clustering is an unsupervised learning task that groups similar data points together into clusters, without any predefined labels, based purely on how alike the points are.

Data & AI

The algorithm discovers structure on its own: points within a cluster are more similar to each other than to points in other clusters. A popular method, k-means, splits data into a chosen number of groups by their distances.

Businesses use clustering to segment customers into groups with similar behavior, so they can target each group differently. Because there are no labels, there's no single 'correct' answer — clusters are judged by how useful and coherent they are.

Examples

Python

from sklearn.cluster import KMeans
import numpy as np

X = np.array([[1, 2], [1, 4], [10, 2], [10, 4]])
km = KMeans(n_clusters=2, n_init=10).fit(X)
print(km.labels_)

Output:

[1 1 0 0]

Learn it in a lesson

See also

Back to the Dictionary