Regression
Regression is a supervised learning task where a model learns from labelled examples and predicts a numerical value for new data.
Regression predicts a number.
If the answer you want is a numerical value, such as a house price, temperature, salary, or sales amount, regression is one of the machine learning approaches you may use.
What Does Regression Mean?
Imagine you want to predict the price of a house.
You might have information about houses such as:
- Size of the house.
- Number of bedrooms.
- Location.
- Age of the house.
You also know the actual selling price of those houses.
A regression model can learn from those examples and estimate the price of a new house.
Simple House Price Example
Imagine we have historical house data like this:
| House Size | Bedrooms | Actual Price |
|---|---|---|
| 1,000 sq ft | 2 | $200,000 |
| 1,500 sq ft | 3 | $300,000 |
| 2,000 sq ft | 4 | $400,000 |
The model studies these examples and learns the relationship between the house information and its price.
Predicting a New House Price
Now suppose a new house has:
We don't know the actual selling price yet.
We give the information to our trained model.
The exact prediction will depend on the data and the model. The important point is that the output is a number.
Why Is Regression Supervised Learning?
Remember what we learned earlier about supervised learning.
The model learns from examples where the correct answer is already known.
In house-price prediction, we know the actual price of the houses in our training data.
Because the training examples contain known numerical answers, regression is a type of supervised learning.
Classification vs Regression
This is one of the most important differences to understand.
Example: Spam or Not Spam
The output belongs to a class.
Example: House Price = $350,000
The output is a numerical value.
Category → Classification
Number → Regression
Another Example: Predicting Salary
Regression is not limited to house prices.
Imagine a company wants to estimate an employee's salary using information such as experience, education, and job level.
Education + Job Level
The model is predicting a numerical salary, so this is a regression problem.
Regression Can Predict Many Different Numbers
The predicted value does not have to be a price.
In every case, the key question is: Are we trying to predict a numerical value?
The Model Does Not Know the Answer Beforehand
This is important to understand.
When we give a new house to the model, the actual selling price is not known yet.
The model uses patterns learned from previous examples to estimate the value.
A Simple Way to Recognize Regression
Look at the question being asked.
In each case, we are looking for a numerical answer.
Regression in One Picture
Regression Predicts a Numerical Value.
Regression is a supervised learning task. The model learns from examples where the correct numerical answer is known and then uses what it learned to estimate a value for new data.
Which One Is Regression?
A company wants to predict whether a customer will cancel their subscription.
If the possible answers are Cancel or Stay, this is classification.
Now change the problem:
The company wants to predict how much money the customer will spend next month.
This is regression, because the output is a numerical amount.