Clustering
Clustering is an unsupervised learning technique that groups similar data points together without being given predefined categories.
Give the model data and let it discover similar groups.
In clustering, we do not tell the model which group each data point belongs to. Instead, the model looks for similarities in the data and creates groups based on those similarities.
What Is Clustering?
Imagine you have thousands of customers in an online store.
You know things about each customer, such as:
- How much they spend.
- How often they purchase.
- How many products they buy.
- How recently they purchased.
But you do not have categories such as "High Value", "Regular", or "Occasional".
Clustering can examine the customer data and discover groups of customers who behave similarly.
Simple Customer Example
Suppose we have these customers:
| Customer | Purchases | Total Spending |
|---|---|---|
| Customer A | 20 | $2,000 |
| Customer B | 18 | $1,800 |
| Customer C | 3 | $150 |
| Customer D | 4 | $200 |
Notice that we have not told the model which customers belong together.
But Customer A and Customer B behave similarly, while Customer C and Customer D also behave similarly.
A clustering algorithm can discover these similarities.
What Groups Might Be Discovered?
The algorithm might discover groups like these:
Customer A, Customer B
Customer C, Customer D
We did not provide these group names to the algorithm. The groups were discovered from similarities in the data.
A human might look at the resulting groups afterward and give them meaningful names.
Why Is Clustering Unsupervised Learning?
Remember the difference between supervised and unsupervised learning.
In supervised learning, we provide known answers.
In clustering, we do not provide the correct group for each customer.
Because the groups are not provided beforehand, this is an unsupervised learning task.
How Does Clustering Decide Who Belongs Together?
The algorithm looks at similarities between data points.
For example, suppose we are grouping customers based on spending and number of purchases.
Customers who have similar values may be placed in the same cluster.
$2,000 spending
$1,800 spending
These customers look similar according to the information we are using, so a clustering algorithm may place them in the same group.
"Similar" depends on which features we give the algorithm. If we change the data used for clustering, the resulting groups can also change.
Clustering vs Classification
These two concepts are easy to confuse.
We already have labelled examples.
Example: An email is labelled Spam or Not Spam.
We do not have predefined group labels.
Example: Discover groups of similar customers.
Classification → "Which known class?"
Clustering → "What groups exist?"
Another Example: Grouping Products
Clustering is not only useful for customers.
Imagine an online store has thousands of products but does not have useful product groups.
The store could provide information such as price, sales volume, product size, and customer behavior.
The algorithm may find groups of products that behave similarly, even though nobody gave it predefined product categories.
What Is a Cluster?
A cluster is simply a group of data points that are considered similar according to the information and method being used.
Points that are close or similar according to the chosen features.
A collection of similar data points.
Where Is Clustering Used?
Clustering is useful when you want to discover hidden structure or groups in data.
Clustering in One Picture
Clustering Discovers Groups in Unlabelled Data.
Unlike classification, we do not give the model the correct category for each data point. The algorithm looks for similarities and groups similar data together.
Is This Clustering?
An online store has information about 50,000 customers. It does not have customer categories. It wants to discover groups of customers with similar shopping behavior.
Yes. This is clustering.
There are no predefined customer groups. The goal is to discover groups based on similarities in the data.
Now consider this:
The store already has customers labelled High Value and Low Value, and wants to predict the category of a new customer.
That is classification, not clustering, because the categories are already known.