MACHINE LEARNING • LESSON 2

Classification

Classification is a supervised learning task where a model learns from labelled examples and predicts which category a new piece of data belongs to.

THE CORE IDEA

Classification predicts a category, not a continuous number.

We give the model examples with known categories. The model learns patterns from those examples and then uses those patterns to assign a category to new data.

01

What Does Classification Mean?

The word classification means putting something into a category or class.

For example, an email can belong to one of these categories:

CLASS Spam
CLASS Not Spam

If a machine learning model looks at a new email and predicts "Spam", it has performed a classification.

02

A Simple Example: Spam Detection

Imagine we have thousands of emails that humans have already classified.

Some emails are marked as Spam and others are marked as Not Spam.

Email Information Known Category
"You won a free prize!" Spam
"Meeting at 10 AM tomorrow" Not Spam
"Claim your free reward now" Spam
"Here is the project report" Not Spam

The model studies these examples and learns patterns that can help distinguish Spam from Not Spam.

03

What Happens With a New Email?

After training, we give the model an email it has never seen before.

NEW EMAIL "You have won a free gift!"
TRAINED MODEL Looks at learned patterns
PREDICTION Spam

The model is not simply looking for one particular word. A real classification model can use many features together to make its prediction.

04

Classification Uses Known Categories

During training, the model needs examples where the correct category is already known.

TRAINING DATA Features

Information about each example.

+
LABELS Known Categories

The correct class for each example.

MODEL Learns to Classify

Predicts a category for new data.

This is why classification belongs to supervised learning.

05

Binary Classification

Sometimes there are only two possible categories. This is called binary classification.

CLASS 1 Spam

The email belongs to the spam category.

CLASS 2 Not Spam

The email does not belong to the spam category.

Other examples of binary classification include:

  • Fraud / Not Fraud
  • Approved / Rejected
  • Disease Detected / Not Detected

The model has two possible classes to choose from.

06

Multi-Class Classification

Classification does not have to be limited to two categories.

If there are three or more possible categories, we can have a multi-class classification problem.

CLASS Cat
CLASS Dog
CLASS Bird

For example, an image classification model might receive an animal image and predict whether it is a cat, dog, or bird.

The model chooses one of the available classes.

07

How Does the Model Know Which Class to Choose?

During training, the model sees many examples and their correct categories.

It tries to learn patterns that separate one class from another.

For example, imagine a model that classifies fruits.

TRAINING EXAMPLES Apples

Size, color, weight, shape

TRAINING EXAMPLES Oranges

Size, color, weight, shape

After learning from many labelled examples, the model can use those patterns when it receives a new fruit.

NEW FRUIT Model predicts: Orange
08

Classification vs Regression

Classification and regression are both common supervised learning tasks, but they predict different kinds of outputs.

CLASSIFICATION Predict a Category

Example: Spam or Not Spam

The result belongs to a class.

REGRESSION Predict a Number

Example: House Price = $350,000

The result is a numerical value.

Easy way to remember:

If you are predicting a category such as Spam, Dog, or Approved, think classification.

If you are predicting a numerical value such as $350,000, 72.5, or 25°C, think regression.

09

Real-World Classification Examples

Classification is useful whenever the output needs to be one of several categories.

EMAIL Spam / Not Spam
BANKING Fraud / Not Fraud
MEDICAL Condition / No Condition
IMAGE Cat / Dog / Bird
10

Classification in One Picture

TRAINING Examples + Known Categories Model Learns Patterns
PREDICTION New Data Predict a Category
KEY IDEA

Classification Predicts Which Category a New Data Point Belongs To.

The model learns from labelled examples and uses the patterns it learned to assign a class to new data. Classification can have two classes or many classes.

QUICK CHECK

Is This Classification?

An online store wants to predict whether a customer will make a purchase after seeing a product.

Answer

Yes, if the possible outputs are categories such as Purchase and No Purchase.

The model is choosing between categories, so this is a classification problem.

Now consider a different problem:

The store wants to predict exactly how much money the customer will spend.

Answer

That is regression, because the output is a numerical value rather than a category.

NEXT TOPIC

Regression

Classification predicts categories. Next, we will learn how Machine Learning predicts numerical values using regression.