HTML

CSS

JAVASCRIPT

SQL

PYTHON

PHP

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Learn Data Science and Machine Learning & Flexible Online Courses!

Everything that you should know
about Linear Regression in python

HTML

Learn Data Science and Machine Learning & Flexible Online Courses!

Everything that you should know
about Linear Regression in python

Learn Data Science and Machine Learning & Flexible Online Courses!

Data is the most powerful weapon in today’s world more than 2.5 quintillion bytes of data produced every single day.
Over the last two years, we have generated more than 90% of world data.

Every sector uses data as its most important tool to grow its business. Every industry wants to integrate artificial
intelligence in their business. Machine learning and Data Science technologies are in big demand, more than 1 million
jobs are going to be created in the next 5 years.

Linear regression is one of the basic statistical algorithms in machine learning. In this tutorial, you will learn about
linear regression and it’s a various implementation in python.

After reading this blog post, you will be able to answer all of the following questions.

Some other blog post that you may want to read is

•  Top 4 libraries you must know for any deep learning projects

•  Facial Recognition web app in python

•  Time Series analysis in python part-1

•  Time Series analysis in python part-2

•  How to perform data analysis in python,

What is linear regression

Linear regression is a statistical model that inspects the linear relationship between two (Simple Linear Regression ) or more (Multiple Linear Regression) variables which are dependent variable and independent variables.

The term linear relationship means if one variable(or more) goes up then the other variable goes down and vice-versa is also true.

In the given figure we can see that a linear relationship can be positive or negative.

Learn Data Science and Machine Learning & Flexible Online Courses!

Let us understand it by an example- In a company XYZ, John salary is directly proportional to the no of hours did he work, This shows that a positive linear relationship between Ramesh salary and no of hours he works.

The price of laptops decreases throughout times, it shows us the negative linear relationship between laptop price and time.

Let us understand a little bit of math behind linear regression

The equation of linear regression is

Y = mX + b

where

• Y is an output variable,
• X is the input variable- the variables we are using to make predictions,
• m is the slope which determines the effect of x on y,
• and b is the bias which means how much our prediction is differing from the actual output.

As we have seen in the previous blog post, one of the assumptions of regression is the output variable must be continuous for making a prediction.

In the regression, we always trying to minimize our error by finding the “line of best fit”. This is the line that tells us about the minimal error between our prediction and the actual output.

Learn Data Science and Machine Learning & Flexible Online Courses!

In the given plot, we are trying to minimize our length of black lines as close as to the data points. For minimizing our error we use mean squared error also called the residual sum of squares.

You can check out the following article written by Patrick and his team that will clearly explain the math behind linear regression.

Now let us go the implementation of linear regression in python.