DataCrux’s Complete Guide for Linear Regression

DataCrux’s Complete Guide for Linear Regression

DataCrux’s Complete Guide for Linear Regression

Did you liked it ??
+1
0
+1
0
+1
0
+1
0

Introduction

Let’s start with Machine Learning. So the first Machine Learning Algorithm which we are going to observe is Linear Regression. Linear Regression is one of the important and easiest Machine Learning algorithm. Here we are going to see each and every topic related to Linear Regression in detail. So let’s start our journey for Linear Regression.

 

The name Linear Regression itself tells us that it belongs to Regression algorithm from Supervised Learning. It has the origin from statistics, where it is used to study the relationship between the input and output numerical variables. Linear Regression is used to show the linear relationship between the independent variable (predictor) i.e. on X-axis and the dependent variable (output) i.e. on y-axis. In other words, (y) can be calculated from a linear combination of the input variable (x).

If there is a single dependent variable it is called as Simple or Univariate Linear Regression. If there are more than one (multiple) dependent variable it is called as Multiple or Multivariate Linear Regression. 

Before getting into Mathematics part of Linear Regression. Let’s understand with an easy example.

Experience in Years02456
Salary2,00,0004,00,0008,00,00010,00,00012,00,000

Can we find out the salary of a person with 3 years of experience?

Yes, we can definetly find out the salary. So if we plot the graph for the above data we get something like this.

Fig 1: After Plotting Graph

Now if we draw a straight line from the data points we can compute the results as below.

If a raise a line from years of experience on x-axis till Salary on y-axis we get the results that the salary for the professional with 3 years of experience is approximately 65,00,000.

from sklearn.linear_model import LinearRegression
#Representing LinearRegression as lr (creating LinearRegression object)
lr = LinearRegression()
#Fit the model using lr.fit()
lr.fit( X_train_lm , y_train_lm 
Did you liked it ??
+1
0
+1
0
+1
0
+1
0

Leave a Reply

Your email address will not be published. Required fields are marked *