In the previous article, we learned about Simple Linear Regression, where a model predicts a target variable using a single input feature.

However, real-world problems are rarely that simple.

Consider predicting house prices.

Would house price depend only on area?

Probably not.

Factors such as:

  • Area
  • Number of Bedrooms
  • Location
  • Age of Property
  • Distance from City Center
  • Nearby Schools

all influence the final price.

Similarly:

Employee salary may depend on:

  • Experience
  • Education
  • Skills
  • Certifications
  • Company Size

To handle such situations, we use Multiple Linear Regression.

Multiple Linear Regression extends Simple Linear Regression by using multiple input features to predict a target variable.

It is one of the most widely used Machine Learning algorithms and forms the foundation of many advanced predictive models.

What is Multiple Linear Regression?

Multiple Linear Regression is a supervised Machine Learning algorithm that models the relationship between:

  • Multiple Independent Variables (Features)
  • One Dependent Variable (Target)

Example:

ExperienceEducationSkills ScoreSalary
2Bachelor's705 LPA
5Master's8510 LPA
8Master's9516 LPA

Goal:

Predict Salary using multiple features.

Why Do We Need Multiple Features?

Suppose we want to predict house prices.

Dataset:

AreaPrice
100050
150075

Simple Linear Regression uses only Area.

But two houses can have the same area and very different prices.

Example:

AreaBedroomsLocationPrice
15002Rural60
15004City90

Area alone cannot explain the difference.

Multiple features are needed.

From Simple to Multiple Regression

Simple Linear Regression:

y=mx+by=mx+b
mm
bb

Only one feature is used.

Multiple Linear Regression expands this idea.

Multiple Linear Regression Equation

y=β0+β1x1+β2x2++βnxny=\beta_0+\beta_1x_1+\beta_2x_2+\cdots+\beta_nx_n

Where:

  • yy = Predicted value
  • β0\beta_0 = Intercept
  • β1,β2,,βn\beta_1,\beta_2,\ldots,\beta_n = Coefficients
  • x1,x2,,xnx_1,x_2,\ldots,x_n = Features

Understanding the Equation

Suppose:

Salary=2+1.5(Experience)+0.8(SkillScore)Salary = 2 + 1.5(Experience) + 0.8(SkillScore)

For:

Experience = 4

SkillScore = 80

Prediction:

Salary=2+1.5(4)+0.8(80)Salary= 2+ 1.5(4) + 0.8(80) Salary=72Salary= 72

The model combines information from multiple features.

Understanding Features

Features are the input variables used to make predictions.

Example:

House Price Dataset

Feature
Area
Bedrooms
Bathrooms
Age
Location Score

Target:

Price

Each feature contributes differently.

Understanding Coefficients

Coefficients represent the impact of a feature on the target variable.

Example:

Price=10+0.05(Area)+5(Bedrooms)Price= 10+ 0.05(Area) + 5(Bedrooms)

Interpretation:

  • Every additional square foot increases price by 0.05 units.
  • Every additional bedroom increases price by 5 units.

Positive Coefficients

Example:

Salary=2+3(Experience)Salary= 2+ 3(Experience)

Higher experience increases salary.

Positive coefficient:

+3+3

Negative Coefficients

Example:

Price=1002(Age)Price= 100- 2(Age)

As property age increases, price decreases.

Negative coefficient:

2-2

Intercept in Multiple Regression

The intercept represents:

Predicted value when all features equal zero.

Example:

Price=20+0.05(Area)Price= 20+ 0.05(Area)

If:

Area = 0

Then:

Price=20Price=20

This value is the intercept.

Visualizing Multiple Regression

Simple Linear Regression:

Straight line in 2D.

Multiple Linear Regression:

Plane or hyperplane in higher dimensions.

Example:

Two Features:

          Salary
^
/
/
/
/
--------/-------->
Experience

Skills

The model finds the best-fitting plane.

How Does the Model Learn?

The model:

  1. Takes historical data
  2. Tries different coefficients
  3. Makes predictions
  4. Calculates errors
  5. Adjusts coefficients
  6. Finds the best combination

The objective is:

Minimize prediction error.

Example Dataset

ExperienceSkillsSalary
1503
3707
58512

The model learns:

Salary=f(Experience,Skills)Salary= f(Experience,Skills)

Predictions Using Multiple Features

Suppose:

FeatureValue
Experience4
Skills80

The model combines both features to estimate salary.

Unlike Simple Linear Regression, predictions now depend on multiple variables simultaneously.

Why Multiple Regression Performs Better

Real-world outcomes usually depend on several factors.

Example:

Predicting Student Marks

Features:

  • Study Hours
  • Attendance
  • Previous Grades
  • Sleep Hours

Using only Study Hours would ignore valuable information.

Multiple Linear Regression utilizes all available information.

Matrix Representation

For large datasets, the equation is written using matrices.

Y=XβY = X\beta

Where:

  • YY = Target values
  • XX = Feature matrix
  • β\beta = Coefficient vector

Matrix notation simplifies calculations.

Training Multiple Linear Regression in Python

from sklearn.linear_model import LinearRegression

model = LinearRegression()

model.fit(X_train, y_train)

Making Predictions

predictions = model.predict(X_test)

Viewing Coefficients

print(model.coef_)

Example Output:

[1.5, 0.8, -0.3]

Each value corresponds to a feature.

Viewing Intercept

print(model.intercept_)

Example:

2.4

Example: House Price Prediction

Features:

  • Area
  • Bedrooms
  • Age

Model:

Price=20+0.05(Area)+8(Bedrooms)1(Age)Price= 20+ 0.05(Area) + 8(Bedrooms) - 1(Age)

Interpretation:

  • Larger houses cost more.
  • More bedrooms increase value.
  • Older houses decrease value.

Feature Importance Through Coefficients

Large coefficient magnitude often indicates stronger influence.

Example:

FeatureCoefficient
Area0.05
Bedrooms8
Age-1

Bedrooms have the strongest effect.

However:

Feature scaling may affect interpretation.

Advantages of Multiple Linear Regression

  • Easy to understand
  • Fast training
  • Highly interpretable
  • Handles multiple features
  • Strong baseline model

Limitations of Multiple Linear Regression

  • Assumes linear relationships
  • Sensitive to outliers
  • Struggles with complex patterns
  • Requires careful feature selection

Multiple Linear Regression vs Simple Linear Regression

Simple Linear RegressionMultiple Linear Regression
One FeatureMultiple Features
Straight LinePlane/Hyperplane
SimplerMore Powerful
Limited InformationUses More Information

Real-World Applications

House Price Prediction

Features:

  • Area
  • Bedrooms
  • Location

Target:

Price

Salary Prediction

Features:

  • Experience
  • Education
  • Skills

Target:

Salary

Sales Forecasting

Features:

  • Advertising Budget
  • Product Price
  • Season

Target:

Sales

Loan Risk Prediction

Features:

  • Income
  • Credit Score
  • Existing Debt

Target:

Risk Score

Common Mistakes

Using Highly Correlated Features

Example:

  • Monthly Income
  • Annual Income

Both provide nearly identical information.

This creates:

Multicollinearity

which can destabilize coefficients.

Ignoring Feature Scaling

Features with different scales may affect interpretation.

Assuming Correlation Means Causation

A feature may correlate with the target without causing it.

Always use domain knowledge.

Best Practices

  • Select meaningful features
  • Remove redundant variables
  • Handle outliers
  • Check assumptions
  • Evaluate model performance
  • Interpret coefficients carefully

Multiple Linear Regression Workflow

A typical workflow is:

  1. Collect data
  2. Select features
  3. Split data into train and test sets
  4. Train the model
  5. Learn coefficients
  6. Make predictions
  7. Measure errors
  8. Improve features if necessary

Why Multiple Linear Regression is Important

Most real-world Machine Learning problems involve multiple factors influencing the target variable. Multiple Linear Regression provides a simple yet powerful framework for modeling these relationships.

It introduces important concepts such as coefficients, feature contributions, multivariate prediction, and model interpretation. Understanding Multiple Linear Regression is essential because many advanced Machine Learning algorithms build upon the same principles of learning relationships between multiple features and a target variable.

In the next article, we will learn about the Cost Function, which explains how regression models measure prediction errors and determine whether one model is better than another.