MACHINE LEARNING • LESSON 2

Clustering

Clustering is an unsupervised learning technique that groups similar data points together without being given predefined categories.

THE CORE IDEA

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.

01

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.

02

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.

03

What Groups Might Be Discovered?

The algorithm might discover groups like these:

GROUP 1 Frequent High-Spending Customers

Customer A, Customer B

GROUP 2 Occasional Low-Spending Customers

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.

04

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.

DATA Customer Information
NO LABELS No Predefined Groups
CLUSTERING Find Similar Groups

Because the groups are not provided beforehand, this is an unsupervised learning task.

05

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.

CUSTOMER A 20 purchases

$2,000 spending

CUSTOMER B 18 purchases

$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.

Important:

"Similar" depends on which features we give the algorithm. If we change the data used for clustering, the resulting groups can also change.

06

Clustering vs Classification

These two concepts are easy to confuse.

CLASSIFICATION Predict a Known Category

We already have labelled examples.

Example: An email is labelled Spam or Not Spam.

CLUSTERING Discover Groups

We do not have predefined group labels.

Example: Discover groups of similar customers.

Easy way to remember:

Classification → "Which known class?"

Clustering → "What groups exist?"

07

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.

PRODUCT DATA Price + Sales + Customer Behavior
DISCOVERED GROUPS Similar Product Groups

The algorithm may find groups of products that behave similarly, even though nobody gave it predefined product categories.

08

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.

DATA POINTS Similar Data

Points that are close or similar according to the chosen features.

CLUSTER A Group

A collection of similar data points.

09

Where Is Clustering Used?

Clustering is useful when you want to discover hidden structure or groups in data.

E-COMMERCE Group similar customers
PRODUCTS Group similar products
DOCUMENTS Group similar documents
IMAGES Group similar images
10

Clustering in One Picture

INPUT Data Without Group Labels Find Similarities
RESULT Discover Groups Similar Data in the Same Cluster
KEY IDEA

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.

QUICK CHECK

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.

Answer

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.

Answer

That is classification, not clustering, because the categories are already known.

NEXT TOPIC

Choosing the Right Type of ML

We have now covered supervised learning, unsupervised learning, reinforcement learning, classification, regression, and clustering. Next, we will bring these ideas together and learn how to choose the right type of machine learning for a problem.