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.
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.
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:
If a machine learning model looks at a new email and predicts "Spam", it has performed a classification.
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.
What Happens With a New Email?
After training, we give the model an email it has never seen before.
The model is not simply looking for one particular word. A real classification model can use many features together to make its prediction.
Classification Uses Known Categories
During training, the model needs examples where the correct category is already known.
Information about each example.
The correct class for each example.
Predicts a category for new data.
This is why classification belongs to supervised learning.
Binary Classification
Sometimes there are only two possible categories. This is called binary classification.
The email belongs to the spam category.
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.
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.
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.
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.
Size, color, weight, shape
Size, color, weight, shape
After learning from many labelled examples, the model can use those patterns when it receives a new fruit.
Classification vs Regression
Classification and regression are both common supervised learning tasks, but they predict different kinds of outputs.
Example: Spam or Not Spam
The result belongs to a class.
Example: House Price = $350,000
The result is a numerical value.
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.
Real-World Classification Examples
Classification is useful whenever the output needs to be one of several categories.
Classification in One Picture
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.
Is This Classification?
An online store wants to predict whether a customer will make a purchase after seeing a product.
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.
That is regression, because the output is a numerical value rather than a category.