All About Linear Regression Formula

All About Linear Regression Formula

4 mins read552 Views Comment
Vikram
Vikram Singh
Assistant Manager - Content
Updated on Jan 27, 2023 13:03 IST

The linear regression formula gives the relationship between the dependent and independent variables. There are two types of linear regression: simple and multiple linear regression. This article will briefly discuss all about simple and multiple linear regression with the help of exmaples.

2022_11_MicrosoftTeams-image-86-2.jpg

Linear Regression models a linear relationship between two or more continuous variables (dependent and independent variables) with the line of regression. 

  • In linear regression, linear refers to a line, and regression refers to a relation in continuous variables.
  • There are two types of linear regression:
    • Simple Linear Regression 
      • It has only one dependent and independent variable.
      • Equation:
        • Y = mX + C
    • Multiple Linear Regression
      • It has only one dependent variable but more than one independent variable.
      • Equation:
        • Y = C0 + C1X1 + C2X2 + …….+ CnXn

In the linear regression algorithm, the goal is to find the formula (or equation) of a line (or a plane) to predict the value of the output (dependent/response/outcome) variable based on the input (independent/predictor/explanatory) variable with maximum accuracy or minimum error.

Also Read Regression Analysis

What is Programming What is Python
What is Data Science What is Machine Learning

This article will discuss the linear regression formula for both cases, i.e., Simple Linear Regression and Multiple Linear Regression.

Table of Content

Recommended online courses

Best-suited Machine Learning courses for you

Learn Machine Learning with these high-rated online courses

2.5 L
2 years
2.5 L
2 years
1.53 L
11 months
34.65 K
11 months
5.6 L
18 months
– / –
8 hours
– / –
6 months

Simple Linear Regression

Simple Linear Regression models the linear relationship between only one independent and one dependent variable. 

Example: Relation between Fahrenheit and degree Celsius 

F = (9/5)*C + 32,

where

F: dependent variable

C: Independent variable

Programming Online Courses and Certification Python Online Courses and Certifications
Data Science Online Courses and Certifications Machine Learning Online Courses and Certifications

Simple Linear Regression Formula

The formula of simple linear regression is given by:

Y = mX + c,

Where

Y: dependent variable

m: slope or regression coefficient

c: y-intercept

Now, the question is: How to find the value of m and c in the above equation:

In linear regression, we use ordinary Least Square Method to find the value of m and c.

Ordinary Least Square Method:

OLS method is used for estimating the value of unknown parameters by creating a model that will minimize the sum of squared error between the actual and predicted data.

In the OLS method, the value of m and c is given by:

2022_11_image-78.jpg
Least Square Regression in Machine Learning
Least Square Regression in Machine Learning
This article discusses the concept of linear regression. We have also covered least square regression in machine learning. Let’s begin! The article covers the concept of Least Square Regression...read more
R-Squared vs. Adjusted R-Squared
R-Squared vs. Adjusted R-Squared
Adjusted r squared is similar to r-squared and measures the variation in the target variable. Still, unlike r-squared, it takes only those independent variables with some significance and penalizes you...read more
How to Calculate R squared in Linear Regression
How to Calculate R squared in Linear Regression
In this article we focussed on R-squared in Linear Regression in which explain the procedure of calculating R squared value in step by step way and with example. When you...read more

Example: Find the linear regression equation for the given set of data.

x y
2 3
5 7
9 5
16 20
25 35

Now, firstly we will find the value of

2022_11_image-79.jpg
x y
1 3 (1 – 11) =  -10 (3-14) = -11 110 100
4 7 (4 – 11) = -7 (7-14) = -7 49 49
9 5 (9 – 11) = -2 (5-14) = -9 18 4
16 20 (16 – 11) = 5 (20-14) = 6 30 25
25 35 (25 – 11) = 14 (35-14) = 21 294 196
2022_11_image-80.jpg

Now, substituting the value of m in (ii), we get:

2022_11_image-81.jpg

Multiple Linear Regression

It is a statistical technique used to predict the value of one variable using one or more independent variables. In simple terms, MLR analyses how multiple independent variables are related to one dependent variable.
Let’s take an example to get a better understanding:

House Price
(in lacs)
Area 
(in square feet)
Years 
(Number of years been constructed)
Number of Floor
23.5 900 15 15
25 1200 12 17
44 1500 8 12
18.3 650 13 5
90 1650 5 1

Here, if you look the above data closely, the price of the
House depends on the area of the house, the number of years it builds, and on which floor it is.

Multiple Linear Regression Formula

Y = C0 + C1X1 + C2X2 + …….+ CnXn,

where

y: dependent variable

xi: independent variable/ explanatory variable

C0: y-intercept

Ci: slope coefficient/regression coefficient

Conclusion

Linear regression is one of the most important algorithms that are used to predict the machine learning model. This article briefly discusses the linear regression formula for both the cases (simple and multiple linear regression) with the help of examples.

Hope this article will gives a clear understanding of Linear Regression Formula.

Top Trending Article

Top Online Python Compiler | How to Check if a Python String is Palindrome | Feature Selection Technique | Conditional Statement in Python | How to Find Armstrong Number in Python | Data Types in Python | How to Find Second Occurrence of Sub-String in Python String | For Loop in Python |Prime Number | Inheritance in Python | Validating Password using Python Regex | Python List |Market Basket Analysis in Python | Python Dictionary | Python While Loop | Python Split Function | Rock Paper Scissor Game in Python | Python String | How to Generate Random Number in Python | Python Program to Check Leap Year | Slicing in Python

Interview Questions

Data Science Interview Questions | Machine Learning Interview Questions | Statistics Interview Question | Coding Interview Questions | SQL Interview Questions | SQL Query Interview Questions | Data Engineering Interview Questions | Data Structure Interview Questions | Database Interview Questions | Data Modeling Interview Questions | Deep Learning Interview Questions |

About the Author
author-image
Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio