What Is Linear Regression ?

Harshwardhan Jadhav
Analytics Vidhya
Published in
4 min readSep 20, 2020

Basic theoretical understanding of Linear Regression.

Image Courtesy: Rajtanawade, https://www.behance.net/rajtanawade

(Secret: This is a stolen(borrowed) technique from Statistics)

In the current fast growing world lot of technologies are gaining attention. As a result of this many people are moving towards learning the latest technologies to enhance their skillset and ofcourse so as to secure their jobs.

Machine Learning is the fastest growing technology all around the world obviously due to it’s ability to make our lives way easier on daily basis.

Now let’s get to the main objective of our article.

Broadly speaking there are two types of problems we solve in Machine Learning:

  1. Classification - Used for predicting Descrete Variable. e.g. Review is positive or negative
  2. Regression - Used for predicting a Continuous Real Variable. e.g. Predicting a stock price

Here we are going to discuss the regression problem i. e. we are going to see how Machine Learning helps in predicting a real valued variable. There are many algorithms available at present for doing this work. Linear Regression is one of them and which is very basic one. So let’s dive into it…

Linear Regression

As it’s name suggests it is an algorithm which uses Linear approach for the purpose of predicting a real value that can be anything like a stock price, a house price or something else which is represented by a real value.

So,

“In statistics, Linear Regression is a linear approach to modeling the relationship between a scalar response (or dependent variable) and one or more explanatory variables (or independent variables).”

This is what wikipedia’s definition for Linear Regression is.

In simple words, if there are two variable X and y, we can use linear regression to find out the relation between X and y. But how does linear regression achieves this task?

y = mX + c

The above is the equation of line and this is what linear regression uses to achieve the task of modeling relation bewteen X and y, by finding out best values of m’ and c’. Here we are trying to find out value of y given the value of X.

e.g. Given X = 5, m=0.3, c = 0.6 find the value of y.

so we can calculate the value of y for a single point X as follows,

y = 0.3 * 5 + 0.6

y = 2.1

Image Courtesy: Rajtanawade, https://www.behance.net/rajtanawade

This is the value of y calculated by using equation of line for a single point X. This calculation is performed by linear regression algorithm when there are multiple X points and those many corresponding y’s to be calculated.

But you must be wondering how do we know the value of m and c when there are many X points? Well that’s where Machine Learning comes in…I mean the Linear Regression model which generalises the values of m and c so as to find the value of y for all the X points.

So basically when we have many X points we provide these points to linear regression algorithm and it gives us the generalized values of coefficients m and c. Further these coefficients can be used for predicting the value of y for any point X we provide in the future.

e.g. look at the following table,

Find the full dataset here: https://www.kaggle.com/sonalisingh1411/genderheightweightcsv#

here, X = Height and y = Weight we provide this data to the linear regression model and it gives us the the generalised values of m and c which can be used for predicting value of y for any point X, By using the equation y=mX + c. Here in above example we will get the coefficients (m and c) which can be applied for any value of height for predicting (calculating) the weight of that particular person.

This was a very basic overview of what Linear Regression is. In the next article we will see how the Linear Regression Algorithm actually works so as to find out the generalised coefficients.

Thank you for reading this article, I hope you must have got some insights of Linear Regression. If this article helped you to understand fundamentals of Linear Regression, do share with the ones who you think would benifit.

Thanks again and see you in the Next article in which we will see actual working of Linear Regression.

Ps: Please feel free to point out any misconceptions.

Reference:

--

--

Analytics Vidhya
Analytics Vidhya

Published in Analytics Vidhya

Analytics Vidhya is a community of Generative AI and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Harshwardhan Jadhav
Harshwardhan Jadhav

Written by Harshwardhan Jadhav

Data Scientist | Mechanical Engineer

No responses yet