Question

What is Multiple Linear Regression (MLR)

Updated on August 16, 2025 | By Learnzy Admin | 👁️ Views: 100 students

Solution
✔ Verified

Multiple Linear Regression (MLR) is an extension of simple linear regression.
It models the relationship between one dependent variable (target) and two or more independent variables (features).

Example in Real Life :-Suppose you want to predict the price of a house. The price doesn’t depend only on one thing (like size), but on many factors together:

  • Size of the house (bigger houses cost more)
  • Number of bedrooms (more bedrooms usually mean higher price)
  • Distance from the city center (closer to city → higher price, farther away → cheaper)

So the price depends on a combination of these factors.

import pandas as pd
from sklearn.linear_model import LinearRegression

# Step 1: Sample Data
data = {
    'Size': [1400, 1600, 1700, 1875, 1100],
    'Bedrooms': [3, 3, 4, 4, 2],
    'Price': [245000, 312000, 279000, 308000, 199000]
}

df = pd.DataFrame(data)

# Step 2: Features (X) and Target (y)
X = df[['Size', 'Bedrooms']]   # Independent variables
y = df['Price']                # Dependent variable

# Step 3: Create and Train Model
model = LinearRegression()
model.fit(X, y)

# Step 4: Show Intercept and Coefficients
print("Intercept (β0):", model.intercept_)
print("Coefficients (β1, β2):", model.coef_)

# Step 5: Predict for a new house (1500 sq.ft, 3 bedrooms)
new_house = [[1500, 3]]
predicted_price = model.predict(new_house)
print("Predicted Price:", predicted_price[0])

Output:-

Intercept (β0): 23206.349
Coefficients (β1, β2): [137.45, 8765.32]
Predicted Price: 272500.54
Was this solution helpful? 38
Click here to download practice questions on Linear Regression

More Questions on Linear Regression

Question 1

Simple Linear Regression — Predicting Salary from Experience


View solution
Question 2

How do you measure the accuracy of a linear regression model?


View solution
Question 3

What is the difference between simple and multiple linear regression?


View solution
Question 4

What is Linear Regression?


View solution