What is clustering?
Clustering is a family of unsupervised learning methods that group records by similarity when nobody has defined the groups in advance. The algorithm compares records across chosen features, such as order frequency, average order size, and region. Records that sit close together end up in the same cluster. Text and images are usually converted to embeddings first, and wide tables often go through dimensionality reduction so that distances stay meaningful.
The output is a group label for each record, sometimes with a score for how firmly it belongs. An analyst profiles the clusters, names them, and judges whether they are distinct enough to act on.
Common clustering techniques
- K-means places a chosen number of centers, assigns each record to the nearest one, moves each center to the average of its records, and repeats until the groups stop changing. It is fast and easy to explain but expects compact groups of similar size. Despite the similar name, k-nearest neighbors is a different, supervised method.
- Hierarchical clustering starts with every record alone and repeatedly merges the two closest groups. The result is a tree that can be cut at whatever level of detail the business needs.
- Density-based clustering grows groups outward from crowded regions of the data, finds clusters of irregular shape, and labels isolated records as noise, which doubles as a simple form of anomaly detection.
- Gaussian mixture models treat each group as a bell-shaped distribution and give every record a probability of belonging to each group.
Clustering in practice
A regional apparel and home goods chain sends the same assortment to all 140 of its stores. Some locations mark down unsold stock while others run out. The planning team profiles each store by category sales mix, floor space, local household income, climate, and tourist-season share of sales. K-means separates the stores into six clusters, including small downtown stores that sell mostly accessories and gifts and large suburban stores with heavy seasonal home sales. Buyers now plan six assortments, one per cluster, a manageable workload that fits local demand far better than the old chain-wide plan.
What to watch for
- Scale the features before clustering, or a variable measured in large units, such as annual revenue, will outweigh everything else.
- Every algorithm returns groups even when the data has no real structure, so check that the clusters hold up when the data is resampled.
- Measures such as the silhouette score can suggest a number of clusters, but the final count should match how many distinct plans the business can run.
- Behavior shifts over time, so rerun the clustering on a schedule and track how many records change groups.