MACHINE LEARNING • LESSON 2

Grouping Problems

Sometimes we have data but do not know the categories beforehand. Instead of telling the model which category each example belongs to, we ask it to discover useful groups in the data.

THE CORE IDEA

Find similar examples and group them together.

In a grouping problem, we do not necessarily provide the correct category for every example. The system looks for similarities and differences in the data and creates groups based on those patterns.

01

Imagine a Store With Many Customers

Suppose an online store has thousands of customers. The business wants to understand what types of customers it has.

But nobody has manually labeled the customers as "frequent buyers", "occasional buyers", or "inactive customers".

We only have customer information such as purchase frequency, spending, and website activity.

  • Customer A buys frequently and spends a lot.
  • Customer B buys occasionally and spends less.
  • Customer C rarely purchases anything.
02

The Model Looks for Similarity

A grouping algorithm looks at the available information and tries to identify examples that are similar to one another.

Customers with similar behavior may end up in the same group.

Customer Data

Purchase frequency, spending, activity

Find Similar Patterns

Compare customers based on their data

Groups

Similar customers grouped together

03

We Don't Give the Categories First

This is the major difference between classification and grouping.

Classification

We already know the categories and provide examples with those categories.

Example: Spam / Not Spam.

Grouping

We do not provide predefined categories. The algorithm discovers groups based on similarities.

Example: discover different customer segments.

04

Example: Customer Segmentation

Imagine we have customer data containing annual spending and number of purchases.

A grouping algorithm might discover that some customers behave similarly.

  • Customers who purchase frequently and spend a lot.
  • Customers who purchase occasionally.
  • Customers who rarely purchase.

These groups were not necessarily defined manually. They were discovered from patterns in the data.

05

Another Example: Products

Grouping can also be used to organize products based on their characteristics.

Suppose an online store has thousands of products but the existing categories are incomplete.

A grouping algorithm could find products that have similar characteristics and place them into groups.

Example

Products with similar price ranges, customer behavior, and purchasing patterns may naturally form groups.

06

Grouping Does Not Automatically Give Meaningful Names

This is an important point for beginners.

If an algorithm creates three groups, it may simply call them Group 1, Group 2, and Group 3.

A human still needs to examine those groups and understand what makes them different.

The algorithm finds the groups.

Humans often need to interpret what those groups actually mean in the real world.

07

Grouping Is Useful When We Don't Know the Structure

Grouping can be useful when the structure of the data is not obvious.

Instead of manually defining every category first, we allow the algorithm to search for patterns.

This can help us explore a dataset and discover relationships that were not obvious beforehand.

08

Classification vs Grouping

Classification

  • Categories are known.
  • Training examples have known labels.
  • Model predicts a known category.

Example: classify an email as Spam or Not Spam.

Grouping

  • Categories are not known beforehand.
  • Examples may not have labels.
  • Algorithm discovers groups from patterns.

Example: discover customer segments.

09

Where Is Grouping Used?

Grouping is useful in many situations where we want to discover natural structure in data.

  • Customer segmentation.
  • Grouping similar products.
  • Discovering similar documents.
  • Organizing large collections of data.
KEY IDEA

Grouping Discovers Structure Instead of Using Predefined Categories

When we do not have predefined labels, a grouping algorithm can look for similarities in the data and organize examples into groups.

QUICK CHECK

Which Approach Would You Use?

You already have emails labeled Spam and Not Spam.

Classification.

You have thousands of customers but don't know what customer types exist.

Grouping may be useful.

You want to predict the price of a house.

Numerical prediction.

NEXT TOPIC

What Are We Given?

We have now seen prediction, classification, and grouping. Next, we'll step back and ask a basic question: what information do we actually have before building an ML model?