AI glossary · Basic · Classic ML, recsys & search
Clustering
Clustering is the process of automatically grouping unlabeled data by similarity, dividing it into several groups (clusters). It is a representative method of unsupervised learning.
About this term
- Level
- Basic · Technical terms you often meet in AI news
- Category
- Data, ops & platforms
- Added
- 2026-10-08
How it works
First, each data item is turned into a list of numbers (a feature vector) and treated like a point in space. Then the distance or similarity between points is calculated, and nearby points are grouped together. The best-known method, K-means, sets the number of groups K in advance, assigns each point to the nearest center, then recalculates each group's center, repeating until the result stops changing. Other widely used approaches include density-based methods (such as DBSCAN), which find regions where points are densely packed, and hierarchical clustering, which merges the closest items step by step to build a tree-shaped hierarchy.
The loop K-means uses to find groups
Until the result stops changing
- 1Set K centers
- 2Assign to nearest center
- 3Recalculate centers
- 1. Set K centers Random at first
- 2. Assign to nearest center Compute distance for each point
- 3. Recalculate centers Move to each group's mean position
Why it matters
Most real-world data has no answer labels, so clustering, which reveals structure without labels, is useful when first exploring data. It is used to segment customers by buying behavior, group similar news articles under one topic, or organize large numbers of documents by topic after embedding them. Finding points far from any group also leads into anomaly detection. It is also used to refine AI training data, for example by picking representative samples before data labeling or finding near-duplicate data.
Things to know
Clustering has no correct answer, so it is hard to judge whether a result is 'good'. Depending on which features are used and how distance is measured, completely different groups can emerge. Methods like K-means that require setting the number of groups in advance give forced results if that value is chosen poorly. Giving a group a meaning, such as 'price-sensitive customers', ultimately requires human interpretation.
Example
An online store divides customers into groups based on purchase frequency, spending and products of interest, and runs different marketing for each group. LLM services sometimes embed user questions and cluster them to see 'what topics people mostly ask about', and to find groups of questions that often fail so they can be improved.