Did you know? You can give an AI system a collection of unlabelled examples and ask it to look for groups. Unlike a classroom exercise where every picture already says “apple” or “orange,” this task begins without those answers attached.
A common method is called clustering. Its quick idea is choose what to compare → represent each example with numerical features → measure similarity → form groups → inspect whether the groups are useful. The algorithm finds mathematical structure; a person still needs to decide what that structure means.
Imagine spreading coloured buttons across a table. You might naturally make piles based on colour. Someone else might group by size, and a third person by number of holes. All three arrangements could be reasonable. Clustering faces the same question: similar in which way?
The 30-second guide to clustering
- Unsupervised learning: looking for structure in data without the specific correct category labels used by supervised classification.
- Feature: a measurable property used to represent an example.
- Similarity or distance: a mathematical way of comparing examples.
- Cluster: a group formed according to the chosen method and features.
- Centroid: a central representative of a group used by algorithms such as k-means.
- Interpretation: checking whether a mathematical group corresponds to anything useful in the real task.
Clustering does not require the computer to discover one true hidden category for everything. Different features, distance measures and methods can create different valid arrangements of the same data.
First, how is clustering different from classification?
In classification, a training example might be a picture already marked “cat” or “dog.” The model learns to predict those established labels for new images. In clustering, the starting examples may have no cat-or-dog labels; the method groups them according to some measured resemblance.
After finding groups, a human might notice that one mainly contains cats and another mainly dogs. But the clustering algorithm did not necessarily understand animal biology or make a reliable cat detector. It simply organised the representations it was given.
This distinction matters because a system can group examples based on irrelevant background details. Images photographed in bright sunlight might appear similar to each other even when their subjects differ.
Step 1: Choose which properties will count
Suppose a fictional school library wants to understand patterns in borrowing activity without using students’ names. It might study aggregated numbers such as books borrowed per visit and number of visits per month. Those features could reveal groups with different patterns of library use.
But if the system includes an unrelated number—say, an arbitrary record identifier—it might create groups that have no practical meaning. Choosing appropriate features is as important as choosing the clustering algorithm.
Data preparation also matters. A feature measured in thousands can dominate one measured in single digits when an algorithm uses raw numerical distance. Normalisation or scaling may help, but should match the meaning of the data.
Step 2: Represent the examples as points
For a simple demonstration, imagine each example is just one number. You have six observations: 2, 3, 4, 10, 11 and 12. On a number line, the first three sit close together and the last three sit close together.
Those values suggest two visible groups. If they represented daily visitors to two small clubs, the numerical clusters might reflect genuinely different activity levels. If they represented random seat numbers, grouping them by closeness might tell us almost nothing useful.
Real datasets often have many features and are represented as points in a higher-dimensional mathematical space. We cannot draw every dimension easily, but algorithms can still compute similarities.
Step 3: See how k-means forms groups
One widely used clustering algorithm is k-means. You choose a value for k, the desired number of groups. The method begins with tentative centres, assigns each data point to a nearby centre, recalculates the centres and repeats until a stopping condition is reached.
In the six-number example, choose k = 2. One reasonable result places 2, 3 and 4 in one group, with a mean of 3. The other contains 10, 11 and 12, with a mean of 11. Those two means are the centres of the groups.
The example is deliberately simple, not a claim that real-world data always form two neat groups. K-means can behave differently when initial centres change, and it may struggle with elongated, unequal-density or unusually shaped clusters.
The important insight: the algorithm can tell you which points are near each other under its chosen measure. It does not prove why they are near each other.
Step 4: Know that k-means is not the only option
Other methods construct groups in different ways. Hierarchical clustering can organise examples into nested sets, much like branches on a family tree. Density-based clustering looks for areas where examples are crowded together, which can help with irregular shapes and some outliers.
Each method makes assumptions. A large number of points packed in a curved shape might confuse a method that expects roundish clusters. Conversely, a density-based approach may struggle when groups have very different densities.
It is sensible to compare methods using the problem’s needs, the nature of the features and whether the output remains stable under reasonable changes.
Step 5: Give the groups useful names only after reviewing them
Suppose a clustering analysis produces Group A, Group B and Group C. It can be tempting to rename them “enthusiastic learners,” “average learners” and “unmotivated learners.” That would be an unsupported leap from a data pattern to a judgement about people.
A group with fewer logged learning activities might reflect limited internet access, different schedules, unrecorded offline learning or a data-quality problem. Clustering alone cannot tell us which explanation is true.
A more careful description might be “low recorded platform activity during the measured period.” Even that should be qualified by the data source and timeframe. Mathematical group membership is not a permanent personal identity.
Step 6: Check whether the groups are stable and useful
Clustering has no single universal accuracy score because the intended true categories may not be known. Developers can examine within-group similarity, separation between groups, stability under different settings and whether domain experts recognise meaningful patterns.
One might repeat the process with a different starting point or carefully varied sample. If a supposedly meaningful group disappears whenever a few records change, decision-makers should be cautious. A technically neat division is not automatically useful.
For sensitive or consequential decisions, examine the consequences of using the clusters and whether they create unfair or misleading assumptions about groups of people.
How many clusters should the system create?
In k-means, k is a design choice. Choosing two groups might produce one broad distinction; choosing five may reveal smaller subdivisions. Neither choice is guaranteed to match a natural or morally meaningful boundary.
Developers can inspect measures of clustering compactness and separation, compare several values of k and consider the task’s practical purpose. A mathematically attractive score may still produce groups that are hard to explain or act upon.
Returning to our buttons, a pile grouped by colour may be useful when you want to build a rainbow pattern. Grouping by size may be better when you want to fit buttons through a small opening. Usefulness comes from the purpose.
Try this: group six objects in two different ways
Find six harmless household objects or draw them on paper. First divide them into groups by colour. Then regroup them by shape or size. Which items move from one group to another?
Write down the rule used for each grouping. You have demonstrated why clustering results depend on the features and the way similarity is defined.
For a numerical activity, put the points 2, 3, 4, 10, 11 and 12 on a number line. Mark a boundary between 4 and 10 and calculate the mean of each resulting group. Add the number 50. What happens to the idea of two neat groups? This shows how an unusual observation can affect some clustering methods.
Where clustering is useful
- Document organisation: suggesting groups of related articles that a person can review.
- Image exploration: finding visual patterns in large collections.
- Product catalogues: organising items by chosen features.
- Science: exploring patterns in measurements before testing explanations.
- Service planning: discovering broad usage patterns from appropriately governed data.
Clustering is exploratory. Discovering a pattern can help people form a hypothesis, but it does not by itself establish cause and effect.
Five mistakes worth avoiding
- Assuming labels are true: Group 1 and Group 2 are mathematical results, not automatically meaningful categories.
- Ignoring scale: poorly chosen units can distort distance calculations.
- Choosing k arbitrarily: the number of groups can change the story told by the results.
- Overlooking outliers: unusual points can move centres or challenge a method’s assumptions.
- Profiling individuals: a cluster membership must not become an unsupported judgment of a person’s character, ability or rights.
Frequently asked questions
Does clustering need labelled examples?
Not in the way a supervised classifier does. It groups unlabelled observations using selected features and similarity measures, though labels may later be used to evaluate or interpret the groups.
Is every cluster a real category?
No. Some groups reflect useful structure; others reflect measurement choices, noise or sampling patterns.
Why can two clustering tools disagree?
They may use different features, scales, distance measures, starting conditions or algorithms.
Can clustering predict tomorrow’s sales?
Clustering is primarily a way to group data. It may contribute features to a larger forecasting system, but time-series prediction is a separate task.
Can AI cluster text without reading exact keywords?
Yes. Some workflows convert passages into embeddings and then group the vectors. The quality of those groups still depends on the model and the purpose.
Your one-minute takeaway
- Clustering discovers groups in data without needing predefined class labels.
- Distance, feature selection and algorithm choices shape the result.
- Human interpretation is essential: a group is a pattern to investigate, not an unquestionable fact about the world.
Trusted resources and the next AI chapters
- Google for Developers: What Is Clustering? — accessible visual examples of grouping data.
- Google: How k-Means Clustering Works — centres, assignment and iteration.
- Google: Clustering Algorithms — choosing among different methods.
- Google Cloud: What Is Unsupervised Learning? — the wider family of unlabeled-data approaches.
- How AI Embeddings Find Similar Meanings — representing related text with numerical vectors.
- How AI Learns From Examples — compare unsupervised grouping with supervised learning.
- How AI Works: Complete Overview — the wider learning route.