MACHINE LEARNING • LESSON 7

Simple Linear Regression

Simple Linear Regression is used when we want to predict one numerical value using one input feature.

THE SIMPLEST DEFINITION

One input → one numerical prediction.

Simple Linear Regression learns a straight-line relationship between one input variable and one numerical output.

01

A Simple Example

Suppose we want to predict a student's exam score based only on how many hours they studied.

Study Hours Exam Score
1 hour 45
2 hours 55
3 hours 65
4 hours 75
5 hours 85

Here, we have only one input: Study Hours.

We want to predict one output: Exam Score.

02

Why Is It Called "Simple"?

It is called Simple Linear Regression because there is only one input feature.

ONE INPUT Study Hours
MODEL Simple Linear Regression
ONE OUTPUT Exam Score

There can be many training rows, but there is only one input feature used to make the prediction.

03

See the Relationship

If we put the data on a graph, we can see that exam scores generally increase as study hours increase.

::contentReference[oaicite:0]{index=0}

Simple Linear Regression tries to find a straight line that represents this relationship.

04

The Formula

Simple Linear Regression can be represented using:

ŷ = b₀ + b₁x
ŷ Predicted value
x Input feature
b₀ Intercept
b₁ Slope / coefficient

The model learns b₀ and b₁ from the training data.

After learning them, the model can use a new value of x to calculate a prediction.

05

A Numerical Example

Suppose the model has learned this equation:

Score = 35 + 10 × Study Hours

Now suppose a student studies for 4 hours.

Score = 35 + 10 × 4 Score = 35 + 40 Predicted Score = 75

So the model predicts an exam score of 75.

06

What Does the Slope Tell Us?

In our example:

Score = 35 + 10 × Study Hours

The number 10 is the slope.

It tells us how much the predicted score changes when study hours increase by one hour.

1 additional study hour → approximately 10 points higher predicted score in this example.

The slope describes the direction and rate of the relationship represented by the fitted line.

07

Making a New Prediction

After training, we can give the model a study time it has not seen before.

NEW INPUT 6 hours
LEARNED EQUATION 35 + 10x
PREDICTION 95

The model uses the learned relationship to estimate the score for the new student.

08

Another Real-World Example

The same idea can be used to predict house prices from house size.

INPUT House Size

Example: 1,500 sq ft

MODEL Simple Linear Regression

Learns size → price relationship

OUTPUT Predicted Price

Example: ₹70 lakh

Again, there is only one input feature: House Size.

09

Simple Linear Regression vs Multiple Linear Regression

This distinction is important because the next topic is Multiple Linear Regression.

SIMPLE LINEAR REGRESSION One input feature

Study Hours → Exam Score

MULTIPLE LINEAR REGRESSION Multiple input features

Size + Bedrooms + Location → House Price

The key difference is the number of input features.

10

The Complete Idea

Training Data
One Input Feature
Learn the Linear Relationship
Learn the Best-Fitting Line
Give New Input
Predict One Numerical Value
REMEMBER THIS

Simple Linear Regression = One Input → One Numerical Output.

The model learns a straight-line relationship from training data. Once the line is learned, a new input can be given to the model to produce a numerical prediction.

QUICK CHECK

Which One Is Simple Linear Regression?

Study Hours → Exam Score One input → one numerical output
House Size → House Price One input → one numerical output
Size + Bedrooms → House Price Multiple inputs
Answer

The first two are examples of Simple Linear Regression because each uses one input feature. The third uses multiple input features, so it belongs to Multiple Linear Regression.

NEXT TOPIC

Multiple Linear Regression

Next, we will see what changes when we use multiple input features to predict one numerical output.