Explaining Linear Regression

Prajakta Sathe
3 min readJan 28, 2022
Photo by Adi Goldstein on Unsplash

Hello dear reader! If you are currently on this page, it is safe to assume that you are beginning to learn machine learning.

Linear regression is probably the most primitive type of model that one can build. The concept behind it is simple. In this article, I aim to explain the same.

Now, linear regression is a type of supervised learning method. So, before you read further, I would suggest that you understand supervised learning. Here is my article on the same — go check it out — https://blog.devgenius.io/understanding-supervised-learning-bb8ee40556e9 — and come back here to read about linear regression! If you already know what is supervised learning, read on!

What is linear regression?

To understand linear regression, we need to break the term into two words — ‘linear’ and ‘regression’.

Let us go to the ‘regression’ part first. Regression is basically a process to figure out the relation between the dependent variable (it’s usually denoted by ‘y’) and the independent variable(s) — usually ‘x’.

Now, let’s go to the ‘linear’ part. This is as simple as it sounds. The regression graph will always be linear. When you draw the ‘x’ and the corresponding ‘y’ from the dataset on a graph paper, it will always be a straight line.

Are there any types of linear regression?

There are two types of linear regression — simple linear regression (only one ‘x’ is involved), multiple linear regression (multiple independent variables are involved), and multivariate linear regression (multiple ‘x’ and multiple ‘y’ are involved).

How does linear regression work?

Firstly, we give input to the machine in the form of a dataset that contains ‘x’ values mapped to their corresponding ‘y’ values.

For example, let’s say that we are predicting house prices using just one criterion — the area of the house. So, the area of the house will be in our x column and the corresponding price of the house will be in the y column. Each row in the dataset will represent a different house.

The model tries to learn from this data and comes up with a line function such as y=mx+c, where ‘y’ will be the price of the house, ‘x’ will be the area of the house, ‘m’ is the regression coefficient (in simple terms, the relation of x with y), and ‘c’ is the error term or noise. The noise considers all the factors other than ‘x’ that may change the value of ‘y’. The best-fit line is formed by estimating the regression coefficients in such a way that the error term is minimized.

Once the model is trained on this data, we can give different areas to the model, which in return will give us the predicted price of that house.

What are the applications of linear regression?

Linear regression is used in a variety of applications including biology, data-driven marketing, economics, and more! It is mostly used in making predictions such as predicting house prices or predicting the salary of employees.

Understand linear regression with an example —

If you want to understand linear regression with an example, do check out the following video!

I hope I was able to help you understand linear regression! Feel free to upvote, or leave comments and suggestions!

Please don’t forget to clap 👏🏻 if you felt that the article was helpful!

--

--

Prajakta Sathe

I write about data science and UI UX design and other exciting stuff!!