MACHINE LEARNING • LESSON 2

Regression

Regression is a supervised learning task where a model learns from labelled examples and predicts a numerical value for new data.

THE CORE IDEA

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.

01

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.

02

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.

03

Predicting a New House Price

Now suppose a new house has:

SIZE 1,800 sq ft
BEDROOMS 3

We don't know the actual selling price yet.

We give the information to our trained model.

NEW HOUSE 1,800 sq ft + 3 bedrooms
TRAINED MODEL Uses learned patterns
PREDICTION $350,000

The exact prediction will depend on the data and the model. The important point is that the output is a number.

04

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.

INPUT House Information
+
KNOWN ANSWER Actual Price
LEARN Predict Future Prices

Because the training examples contain known numerical answers, regression is a type of supervised learning.

05

Classification vs Regression

This is one of the most important differences to understand.

CLASSIFICATION Predict a Category

Example: Spam or Not Spam

The output belongs to a class.

REGRESSION Predict a Number

Example: House Price = $350,000

The output is a numerical value.

Easy rule:

Category → Classification

Number → Regression

06

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.

INPUT 5 Years Experience

Education + Job Level

PREDICTION $75,000

The model is predicting a numerical salary, so this is a regression problem.

07

Regression Can Predict Many Different Numbers

The predicted value does not have to be a price.

REAL ESTATE Predict house price
WEATHER Predict temperature
BUSINESS Predict sales
FINANCE Predict numerical values

In every case, the key question is: Are we trying to predict a numerical value?

08

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.

PAST DATA Known Prices
TRAINING Learn Relationship
NEW HOUSE Unknown Price
PREDICTION Estimated Price
09

A Simple Way to Recognize Regression

Look at the question being asked.

QUESTION How much will this house cost? Regression
QUESTION How many products will we sell? Regression
QUESTION What will tomorrow's temperature be? Regression

In each case, we are looking for a numerical answer.

10

Regression in One Picture

TRAINING Examples + Known Numbers Model Learns Patterns
PREDICTION New Data Predict a Number
KEY IDEA

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.

QUICK CHECK

Which One Is Regression?

A company wants to predict whether a customer will cancel their subscription.

Answer

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.

Answer

This is regression, because the output is a numerical amount.

NEXT TOPIC

Clustering

We have learned how supervised learning can predict categories and numerical values. Next, we will look at clustering, where a model discovers groups in data without being given the groups beforehand.