SlideShare a Scribd company logo
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
▪ What is Regression?
▪ Regression Use-case
▪ Types of Regression – Linear vs Logistic Regression
▪ What is Linear Regression?
▪ Finding best fit regression line using Least Square Method
▪ Checking goodness of fit using R squared Method
▪ Implementation of Linear Regression using Python
▪ Linear Regression Algorithm using Python from scratch
▪ Linear Regression Algorithm using Python (scikit lib)
Agenda for Today’s Session
“Regression analysis is a form of predictive modelling
technique which investigates the relationship between
a dependent and independent variable”What is
Regression?
Uses of
Regression
Three major uses for regression analysis are
▪ Determining the strength of predictors
▪ Forecasting an effect, and
▪ Trend forecasting
Linear vs
Logistic
Regression
Basis Linear Regression Logistic Regression
Core Concept The data is modelled
using a straight line
The probability of some
obtained event is
represented as a linear
function of a combination of
predictor variables.
Used with Continuous Variable Categorical Variable
Output/Prediction Value of the variable Probability of occurrence of
event
Accuracy and
Goodness of fit
measured by loss, R
squared, Adjusted R
squared etc.
Accuracy, Precision, Recall,
F1 score, ROC curve,
Confusion Matrix, etc
“Linear Regression is a method to predict dependent variable (Y)
based on values of independent variables (X). It can be used for the
cases where we want to predict some continuous quantity.”
What is Linear
Regression?
▪ Classification and Regression Capabilities
▪ Data Quality
▪ Computational Complexity
▪ Comprehensible and Transparent
Linear Regression
Selection
Criteria
▪ Evaluating Trends and Sales Estimates
▪ Analyzing the Impact of Price Changes
▪ Assessment of risk in financial services and
insurance domain
Where is
Linear
Regression
used?
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Line
Understanding
Linear
Regression
Algorithm
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
+ve
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
-ve
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Line
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Linear Regression
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Observation
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Regression Line
Least Square Method
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Estimated Value
Actual Value
error
error
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
Minimize the error
Understanding
Linear
Regression
Algorithm
Speed
Distance
X
Y
Machine Learning Training with Python www.edureka.co/python
+ve Relationship
Understanding
Linear
Regression
Algorithm
Speed
Distance
X
Y
Machine Learning Training with Python www.edureka.co/python
y = mx + c
Distance travelled in a
fixed duration of time
Understanding
Linear
Regression
Algorithm
Speed
Distance
X
Y
Machine Learning Training with Python www.edureka.co/python
y = mx + c
Speed of Vehicle
Understanding
Linear
Regression
Algorithm
Speed
Distance
X
Y
Machine Learning Training with Python www.edureka.co/python
y = mx + c
m = +ve slope of line
Understanding
Linear
Regression
Algorithm
Speed
Distance
X
Y
Machine Learning Training with Python www.edureka.co/python
y = mx + c
c = y - intercept of the line
Understanding
Linear
Regression
Algorithm
Speed
Time
X
Y
Machine Learning Training with Python www.edureka.co/python
-ve Relationship
Understanding
Linear
Regression
Algorithm
Speed
Time
X
Y
Machine Learning Training with Python www.edureka.co/python
y = - mx + c
Time taken to travel a
fixed distance
Understanding
Linear
Regression
Algorithm
Speed
Time
X
Y
Machine Learning Training with Python www.edureka.co/python
y = - mx + c
Speed of Vehicle
Understanding
Linear
Regression
Algorithm
Speed
Time
X
Y
Machine Learning Training with Python www.edureka.co/python
y = - mx + c
m = -ve slope of line
Understanding
Linear
Regression
Algorithm
Speed
Time
X
Y
Machine Learning Training with Python www.edureka.co/python
y = - mx + c
c = y - intercept of the line
Understanding
Linear
Regression
Algorithm
Independent Variable
DependentVariable
X
Y
Machine Learning Training with Python www.edureka.co/python
y = mx + c
Independent Variable
Dependent Variable
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean: ഥ𝒙 3 18/53.6 mean : ഥ𝒚
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6( , )
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean3( , )3.6
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
1
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
1
3
−
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
1
3
−
3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
1
3
−3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
2
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
2
−
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
2 −
3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
2 − 3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
3.6
3
−
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
3.6
3 −
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
3 −3.6
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.4
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.4
1.4
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 3 4 5 6
1
2
3
4
5
0
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
3
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
-2y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
where m = 𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
-1
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
2
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+cy = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-2
-1
0
1
2
-0.6
0.4
-1.6
0.4
1.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)𝑥 − ҧ𝑥 2
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
𝛴 = 10 𝛴 = 4
=
4
10
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
𝛴 = 10 𝛴 = 4
=
4
10
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
3.6
y = mx+c
𝛴 = 10 𝛴 = 4
=
4
10
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝑥 − ҧ𝑥 2
m =
𝛴
𝛴
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
0.4
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
3
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
3.6=0.4x3 + c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
3.6 = 1.2+ c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
3.6 - 1.2 = c
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
c = 2.4
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
mean 3 3.6
𝑥 − ҧ𝑥
-2
-1
0
1
2
𝑦 − ത𝑦
-0.6
0.4
-1.6
0.40.4
1.4
𝑥 − ҧ𝑥 2
4
1
0
1
4
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
-1
0
2
1.2
0.4
-1.6
0.4
1.4
-0.4
2.8
0.4
Independent Variable
Dependent Variable
X
Y
1 2 3 4 5 6
1
2
3
4
5
0 3
y = mx+c
(𝑥 − ҧ𝑥)(𝑦 − ത𝑦)
𝛴 = 10 𝛴 = 4
𝑥 − ҧ𝑥 2
m = 𝛴 =
4
10
c = 2.4
m = 0.4
c = 2.4
y = 0.4x + 2.4
Understanding Linear Regression Algorithm
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Mean Square Error
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
m = 0.4
c = 2.4
y = 0.4x + 2.4
For given m = 0.4 & c = 2.4, lets
predict values for y for x = {1,2,3,4,5}
y = 0.4 x 1+ 2.4 = 2.8
y = 0.4 x 2+ 2.4= 3.2
y = 0.4 x 3+ 2.4= 3.6
y = 0.4 x 4+ 2.4= 4.0
y = 0.4 x 5+ 2.4= 4.4
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Mean Square Error
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Regression Line
m = 0.4
c = 2.4
y = 0.4x + 2.4
For given m = 0.4 & c = 2.4, lets
predict values for y for x = {1,2,3,4,5}
y = 0.4 x 1+ 2.4 = 2.8
y = 0.4 x 2+ 2.4= 3.2
y = 0.4 x 3+ 2.4= 3.6
y = 0.4 x 4+ 2.4= 4.0
y = 0.4 x 5+ 2.4= 4.4
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Mean Square Error
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Regression Line
m = 0.4
c = 2.4
y = 0.4x + 2.4
For given m = 0.4 & c = 2.4, lets
predict values for y for x = {1,2,3,4,5}
y = 0.4 x 1+ 2.4 = 2.8
y = 0.4 x 2+ 2.4= 3.2
y = 0.4 x 3+ 2.4= 3.6
y = 0.4 x 4+ 2.4= 4.0
y = 0.4 x 5+ 2.4= 4.4
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Mean Square Error
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Regression Line Distance between actual
& predicted value
error
error
error
error
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Finding the
best fit line
Machine Learning Training with Python www.edureka.co/python
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Let’s check the Goodness of fit
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What is R-
Square?
Machine Learning Training with Python www.edureka.co/python
▪ R-squared value is a statistical measure of how close
the data are to the fitted regression line
▪ It is also known as coefficient of determination, or the
coefficient of multiple determination
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
1 2 4 5 60 3
1
2
3
4
5
Actual Value
1
2
3
4
5
3
4
2
4
5
𝑥 𝑦
mean
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 4 5 60 3
1
2
3
4
5
Actual Value
mean
distance = actual - mean
Calculation of 𝑹 𝟐
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
1 2 4 5 60 3
1
2
3
4
5
Predicted Value
1
2
3
4
5
2.8
𝑥
3.2
4.0
3.6
4.4
Regression line
Calculation of 𝑹 𝟐
𝑦𝑝
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Independent Variable
Dependent Variable
X
Y
Machine Learning Training with Python www.edureka.co/python
Distance actual - mean
Distance predicted - mean
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Regression line
vs
This is nothing but 𝑅2
=
Calculation of 𝑹 𝟐
𝑦 − ത𝑦 2
𝑦𝑝 − ത𝑦
2
𝛴
𝛴
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
– 0.6
0.4
–1.6
0.4
1.4
𝑦 − ത𝑦
mean y
3.6
𝑅2
=
𝑦 − ത𝑦 2
𝑦𝑝 − ത𝑦
2
𝛴
𝛴
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
– 0.6
0.4
–1.6
0.4
1.4
𝑦 − ത𝑦
mean y
3.6
𝑦𝑝𝑦 − ത𝑦 2
3.6
1.6
2.56
1.6
1.96
2.8
3.2
3.6
4.0
4.4
(𝑦𝑝 − ത𝑦)
-0.8
-0.4
0
0.4
0.8
𝑅2
=
𝑦 − ത𝑦 2
𝑦𝑝 − ത𝑦
2
𝛴
𝛴
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
– 0.6
0.4
–1.6
0.4
1.4
𝑦 − ത𝑦
mean y 3.6
𝑦𝑝𝑦 − ത𝑦 2
3.6
1.6
2.56
1.6
1.96
2.8
3.2
3.6
4.0
4.4
(𝑦𝑝 − ത𝑦)
-0.8
-0.4
0
0.4
0.8
𝑦𝑝 − ത𝑦
2
6.4
1.6
0
1.6
6.4
𝑅2
=
𝑦 − ത𝑦 2
𝑦𝑝 − ത𝑦
2
𝛴
𝛴
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
– 0.6
0.4
–1.6
0.4
1.4
𝑦 − ത𝑦
mean y 3.6
𝑦𝑝𝑦 − ത𝑦 2
0.36
0.16
2.56
0.16
1.96
2.8
3.2
3.6
4.0
4.4
(𝑦𝑝 − ത𝑦)
-0.8
-0.4
0
0.4
0.8
0.64
0.16
0
0.16
0.64
1.6
𝑅2
=
𝑦 − ത𝑦 2
(𝑦𝑝 −ത𝑦
2
𝛴
𝛴
5.2𝛴 𝛴
1.6
5.2
=
𝑦𝑝 − ത𝑦
2
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑥
1
2
3
4
5
3
4
2
4
5
𝑦
– 0.6
0.4
–1.6
0.4
1.4
𝑦 − ത𝑦
mean y 3.6
𝑦𝑝𝑦 − ത𝑦 2
3.6
1.6
2.56
1.6
1.96
2.8
3.2
3.6
4.0
4.4
(𝑦𝑝 − ത𝑦)
-0.8
-0.4
0
0.4
0.8
(𝑦𝑝 −−ത𝑦
2
6.4
1.6
0
1.6
6.4
11.32 16
𝑅2
≈ 0.3
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑅2
≈ 0.3
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑅2
≈ 0.7
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑅2
≈ 0.9
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑅2
≈ 1
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python
Calculation of 𝑹 𝟐
𝑅2
≈ 0.02
Independent Variable
Dependent Variable
X
Y
1 2 4 5 60 3
1
2
3
4
5
Actual vs Predicted Value
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Are
Low R-squared
values always
Machine Learning Training with Python www.edureka.co/python
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Are
High R-squared
values always
Machine Learning Training with Python www.edureka.co/python
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DEMO
Let’s learn to
code
© MadeByShape Ltd. Web Design Manchester 2018. All Rights Reserved.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.

More Related Content

What's hot (20)

Linear regression
Linear regressionLinear regression
Linear regression
MartinHogg9
 
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Edureka!
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
Sanghyuk Chun
 
Bias and variance trade off
Bias and variance trade offBias and variance trade off
Bias and variance trade off
VARUN KUMAR
 
Lasso and ridge regression
Lasso and ridge regressionLasso and ridge regression
Lasso and ridge regression
SreerajVA
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Lecture 6: Ensemble Methods
Lecture 6: Ensemble Methods Lecture 6: Ensemble Methods
Lecture 6: Ensemble Methods
Marina Santini
 
Machine learning session4(linear regression)
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)
Abhimanyu Dwivedi
 
Linear regression in machine learning
Linear regression in machine learningLinear regression in machine learning
Linear regression in machine learning
Shajun Nisha
 
K - Nearest neighbor ( KNN )
K - Nearest neighbor  ( KNN )K - Nearest neighbor  ( KNN )
K - Nearest neighbor ( KNN )
Mohammad Junaid Khan
 
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Edureka!
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning-Linear regression
Machine Learning-Linear regressionMachine Learning-Linear regression
Machine Learning-Linear regression
kishanthkumaar
 
Machine Learning Course | Edureka
Machine Learning Course | EdurekaMachine Learning Course | Edureka
Machine Learning Course | Edureka
Edureka!
 
supervised learning
supervised learningsupervised learning
supervised learning
Amar Tripathi
 
Linear regression with gradient descent
Linear regression with gradient descentLinear regression with gradient descent
Linear regression with gradient descent
Suraj Parmar
 
Random forest
Random forestRandom forest
Random forest
Musa Hawamdah
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine Learning
butest
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
Milind Gokhale
 
Understanding Bagging and Boosting
Understanding Bagging and BoostingUnderstanding Bagging and Boosting
Understanding Bagging and Boosting
Mohit Rajput
 
Linear regression
Linear regressionLinear regression
Linear regression
MartinHogg9
 
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Edureka!
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
Sanghyuk Chun
 
Bias and variance trade off
Bias and variance trade offBias and variance trade off
Bias and variance trade off
VARUN KUMAR
 
Lasso and ridge regression
Lasso and ridge regressionLasso and ridge regression
Lasso and ridge regression
SreerajVA
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Lecture 6: Ensemble Methods
Lecture 6: Ensemble Methods Lecture 6: Ensemble Methods
Lecture 6: Ensemble Methods
Marina Santini
 
Machine learning session4(linear regression)
Machine learning   session4(linear regression)Machine learning   session4(linear regression)
Machine learning session4(linear regression)
Abhimanyu Dwivedi
 
Linear regression in machine learning
Linear regression in machine learningLinear regression in machine learning
Linear regression in machine learning
Shajun Nisha
 
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Linear Regression Algorithm | Linear Regression in R | Data Science Training ...
Edureka!
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning-Linear regression
Machine Learning-Linear regressionMachine Learning-Linear regression
Machine Learning-Linear regression
kishanthkumaar
 
Machine Learning Course | Edureka
Machine Learning Course | EdurekaMachine Learning Course | Edureka
Machine Learning Course | Edureka
Edureka!
 
Linear regression with gradient descent
Linear regression with gradient descentLinear regression with gradient descent
Linear regression with gradient descent
Suraj Parmar
 
An introduction to Machine Learning
An introduction to Machine LearningAn introduction to Machine Learning
An introduction to Machine Learning
butest
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
Milind Gokhale
 
Understanding Bagging and Boosting
Understanding Bagging and BoostingUnderstanding Bagging and Boosting
Understanding Bagging and Boosting
Mohit Rajput
 

Similar to Linear Regression Algorithm | Linear Regression in Python | Machine Learning Algorithm | Edureka (20)

Linear Regression from Scratch in Python
Linear Regression  from Scratch in PythonLinear Regression  from Scratch in Python
Linear Regression from Scratch in Python
Dhirajk7
 
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Edureka!
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
SourajitMaity1
 
Ml ppt at
Ml ppt atMl ppt at
Ml ppt at
pradeep kumar
 
linear regression in machine learning.pptx
linear regression in machine learning.pptxlinear regression in machine learning.pptx
linear regression in machine learning.pptx
shifaaya815
 
Linear regression presentation explanation.pptx
Linear regression presentation explanation.pptxLinear regression presentation explanation.pptx
Linear regression presentation explanation.pptx
dheerajsrivast
 
Linear regression aims to find the "best-fit" linear line
Linear regression aims to find the "best-fit" linear lineLinear regression aims to find the "best-fit" linear line
Linear regression aims to find the "best-fit" linear line
rnycsepp
 
Detail Study of the concept of Regression model.pptx
Detail Study of the concept of  Regression model.pptxDetail Study of the concept of  Regression model.pptx
Detail Study of the concept of Regression model.pptx
truptikulkarni2066
 
Different Types of Machine Learning Algorithms
Different Types of Machine Learning AlgorithmsDifferent Types of Machine Learning Algorithms
Different Types of Machine Learning Algorithms
rahmedraj93
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Kuppusamy P
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
arsh260174
 
Regression Analysis Techniques.pptx
Regression Analysis Techniques.pptxRegression Analysis Techniques.pptx
Regression Analysis Techniques.pptx
YutaItadori
 
Linear regression.pptx
Linear regression.pptxLinear regression.pptx
Linear regression.pptx
ssuserb8a904
 
Module 3: Linear Regression
Module 3:  Linear RegressionModule 3:  Linear Regression
Module 3: Linear Regression
Sara Hooker
 
3ml.pdf
3ml.pdf3ml.pdf
3ml.pdf
MianAdnan27
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
Andrew Ferlitsch
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Andrew Ferlitsch
 
Linear Regression final-1.pptx thbejnnej
Linear Regression final-1.pptx thbejnnejLinear Regression final-1.pptx thbejnnej
Linear Regression final-1.pptx thbejnnej
mathukiyak44
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptx
Harsha Patel
 
Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithms
Arunangsu Sahu
 
Linear Regression from Scratch in Python
Linear Regression  from Scratch in PythonLinear Regression  from Scratch in Python
Linear Regression from Scratch in Python
Dhirajk7
 
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Machine Learning In Python | Python Machine Learning Tutorial | Deep Learning...
Edureka!
 
linear regression in machine learning.pptx
linear regression in machine learning.pptxlinear regression in machine learning.pptx
linear regression in machine learning.pptx
shifaaya815
 
Linear regression presentation explanation.pptx
Linear regression presentation explanation.pptxLinear regression presentation explanation.pptx
Linear regression presentation explanation.pptx
dheerajsrivast
 
Linear regression aims to find the "best-fit" linear line
Linear regression aims to find the "best-fit" linear lineLinear regression aims to find the "best-fit" linear line
Linear regression aims to find the "best-fit" linear line
rnycsepp
 
Detail Study of the concept of Regression model.pptx
Detail Study of the concept of  Regression model.pptxDetail Study of the concept of  Regression model.pptx
Detail Study of the concept of Regression model.pptx
truptikulkarni2066
 
Different Types of Machine Learning Algorithms
Different Types of Machine Learning AlgorithmsDifferent Types of Machine Learning Algorithms
Different Types of Machine Learning Algorithms
rahmedraj93
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Kuppusamy P
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
arsh260174
 
Regression Analysis Techniques.pptx
Regression Analysis Techniques.pptxRegression Analysis Techniques.pptx
Regression Analysis Techniques.pptx
YutaItadori
 
Linear regression.pptx
Linear regression.pptxLinear regression.pptx
Linear regression.pptx
ssuserb8a904
 
Module 3: Linear Regression
Module 3:  Linear RegressionModule 3:  Linear Regression
Module 3: Linear Regression
Sara Hooker
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
Andrew Ferlitsch
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Andrew Ferlitsch
 
Linear Regression final-1.pptx thbejnnej
Linear Regression final-1.pptx thbejnnejLinear Regression final-1.pptx thbejnnej
Linear Regression final-1.pptx thbejnnej
mathukiyak44
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptx
Harsha Patel
 
Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithms
Arunangsu Sahu
 
Ad

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 

Linear Regression Algorithm | Linear Regression in Python | Machine Learning Algorithm | Edureka

  • 1. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
  • 2. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Linear Regression Algorithm
  • 3. Copyright © 2017, edureka and/or its affiliates. All rights reserved. ▪ What is Regression? ▪ Regression Use-case ▪ Types of Regression – Linear vs Logistic Regression ▪ What is Linear Regression? ▪ Finding best fit regression line using Least Square Method ▪ Checking goodness of fit using R squared Method ▪ Implementation of Linear Regression using Python ▪ Linear Regression Algorithm using Python from scratch ▪ Linear Regression Algorithm using Python (scikit lib) Agenda for Today’s Session
  • 4. “Regression analysis is a form of predictive modelling technique which investigates the relationship between a dependent and independent variable”What is Regression?
  • 5. Uses of Regression Three major uses for regression analysis are ▪ Determining the strength of predictors ▪ Forecasting an effect, and ▪ Trend forecasting
  • 6. Linear vs Logistic Regression Basis Linear Regression Logistic Regression Core Concept The data is modelled using a straight line The probability of some obtained event is represented as a linear function of a combination of predictor variables. Used with Continuous Variable Categorical Variable Output/Prediction Value of the variable Probability of occurrence of event Accuracy and Goodness of fit measured by loss, R squared, Adjusted R squared etc. Accuracy, Precision, Recall, F1 score, ROC curve, Confusion Matrix, etc
  • 7. “Linear Regression is a method to predict dependent variable (Y) based on values of independent variables (X). It can be used for the cases where we want to predict some continuous quantity.” What is Linear Regression?
  • 8. ▪ Classification and Regression Capabilities ▪ Data Quality ▪ Computational Complexity ▪ Comprehensible and Transparent Linear Regression Selection Criteria
  • 9. ▪ Evaluating Trends and Sales Estimates ▪ Analyzing the Impact of Price Changes ▪ Assessment of risk in financial services and insurance domain Where is Linear Regression used?
  • 10. Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Line Understanding Linear Regression Algorithm
  • 17. Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Regression Line Least Square Method
  • 18. Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python Estimated Value Actual Value error error
  • 21. Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Distance travelled in a fixed duration of time
  • 22. Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Speed of Vehicle
  • 23. Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c m = +ve slope of line
  • 24. Understanding Linear Regression Algorithm Speed Distance X Y Machine Learning Training with Python www.edureka.co/python y = mx + c c = y - intercept of the line
  • 26. Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c Time taken to travel a fixed distance
  • 27. Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c Speed of Vehicle
  • 28. Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c m = -ve slope of line
  • 29. Understanding Linear Regression Algorithm Speed Time X Y Machine Learning Training with Python www.edureka.co/python y = - mx + c c = y - intercept of the line
  • 30. Understanding Linear Regression Algorithm Independent Variable DependentVariable X Y Machine Learning Training with Python www.edureka.co/python y = mx + c Independent Variable Dependent Variable
  • 31. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 Understanding Linear Regression Algorithm
  • 32. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 Understanding Linear Regression Algorithm
  • 33. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 Understanding Linear Regression Algorithm
  • 34. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean: ഥ𝒙 3 18/53.6 mean : ഥ𝒚 Understanding Linear Regression Algorithm
  • 35. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6( , ) Understanding Linear Regression Algorithm
  • 36. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean3( , )3.6 Understanding Linear Regression Algorithm
  • 37. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 38. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 1 Understanding Linear Regression Algorithm
  • 39. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 1 3 − Understanding Linear Regression Algorithm
  • 40. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 1 3 − 3 Understanding Linear Regression Algorithm
  • 41. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 1 3 −3 Understanding Linear Regression Algorithm
  • 42. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 2 Understanding Linear Regression Algorithm
  • 43. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 2 − Understanding Linear Regression Algorithm
  • 44. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 2 − 3 Understanding Linear Regression Algorithm
  • 45. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 2 − 3 Understanding Linear Regression Algorithm
  • 46. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 Understanding Linear Regression Algorithm
  • 47. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 Understanding Linear Regression Algorithm
  • 48. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 Understanding Linear Regression Algorithm
  • 49. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 50. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 3 Understanding Linear Regression Algorithm
  • 51. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 3.6 3 − Understanding Linear Regression Algorithm
  • 52. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 3.6 3 − Understanding Linear Regression Algorithm
  • 53. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 3 −3.6 Understanding Linear Regression Algorithm
  • 54. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 Understanding Linear Regression Algorithm
  • 55. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 Understanding Linear Regression Algorithm
  • 56. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 Understanding Linear Regression Algorithm
  • 57. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.4 Understanding Linear Regression Algorithm
  • 58. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.4 1.4 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 59. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 3 4 5 6 1 2 3 4 5 0 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 3 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 -2y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 where m = 𝛴 Understanding Linear Regression Algorithm
  • 60. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 -1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 61. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 62. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 63. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 2 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 64. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+cy = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 65. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 66. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -2 -1 0 1 2 -0.6 0.4 -1.6 0.4 1.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c Understanding Linear Regression Algorithm
  • 67. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦)𝑥 − ҧ𝑥 2 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 68. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 69. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c 𝛴 = 10 𝛴 = 4 = 4 10 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 70. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c 𝛴 = 10 𝛴 = 4 = 4 10 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 71. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 3.6 y = mx+c 𝛴 = 10 𝛴 = 4 = 4 10 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝑥 − ҧ𝑥 2 m = 𝛴 𝛴 Understanding Linear Regression Algorithm
  • 72. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 0.4 Understanding Linear Regression Algorithm
  • 73. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 3 Understanding Linear Regression Algorithm
  • 74. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 3.6=0.4x3 + c Understanding Linear Regression Algorithm
  • 75. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 3.6 = 1.2+ c Understanding Linear Regression Algorithm
  • 76. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 3.6 - 1.2 = c Understanding Linear Regression Algorithm
  • 77. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 c = 2.4 Understanding Linear Regression Algorithm
  • 78. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 mean 3 3.6 𝑥 − ҧ𝑥 -2 -1 0 1 2 𝑦 − ത𝑦 -0.6 0.4 -1.6 0.40.4 1.4 𝑥 − ҧ𝑥 2 4 1 0 1 4 (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) -1 0 2 1.2 0.4 -1.6 0.4 1.4 -0.4 2.8 0.4 Independent Variable Dependent Variable X Y 1 2 3 4 5 6 1 2 3 4 5 0 3 y = mx+c (𝑥 − ҧ𝑥)(𝑦 − ത𝑦) 𝛴 = 10 𝛴 = 4 𝑥 − ҧ𝑥 2 m = 𝛴 = 4 10 c = 2.4 m = 0.4 c = 2.4 y = 0.4x + 2.4 Understanding Linear Regression Algorithm
  • 79. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 80. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 81. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line m = 0.4 c = 2.4 y = 0.4x + 2.4 For given m = 0.4 & c = 2.4, lets predict values for y for x = {1,2,3,4,5} y = 0.4 x 1+ 2.4 = 2.8 y = 0.4 x 2+ 2.4= 3.2 y = 0.4 x 3+ 2.4= 3.6 y = 0.4 x 4+ 2.4= 4.0 y = 0.4 x 5+ 2.4= 4.4
  • 82. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Mean Square Error Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Regression Line Distance between actual & predicted value error error error error
  • 83. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Finding the best fit line Machine Learning Training with Python www.edureka.co/python
  • 84. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Let’s check the Goodness of fit
  • 85. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What is R- Square? Machine Learning Training with Python www.edureka.co/python ▪ R-squared value is a statistical measure of how close the data are to the fitted regression line ▪ It is also known as coefficient of determination, or the coefficient of multiple determination
  • 86. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 1 2 4 5 60 3 1 2 3 4 5 Actual Value 1 2 3 4 5 3 4 2 4 5 𝑥 𝑦 mean
  • 87. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Actual Value mean distance = actual - mean Calculation of 𝑹 𝟐
  • 88. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python 1 2 4 5 60 3 1 2 3 4 5 Predicted Value 1 2 3 4 5 2.8 𝑥 3.2 4.0 3.6 4.4 Regression line Calculation of 𝑹 𝟐 𝑦𝑝
  • 89. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Independent Variable Dependent Variable X Y Machine Learning Training with Python www.edureka.co/python Distance actual - mean Distance predicted - mean 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value Regression line vs This is nothing but 𝑅2 = Calculation of 𝑹 𝟐 𝑦 − ത𝑦 2 𝑦𝑝 − ത𝑦 2 𝛴 𝛴
  • 90. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 – 0.6 0.4 –1.6 0.4 1.4 𝑦 − ത𝑦 mean y 3.6 𝑅2 = 𝑦 − ത𝑦 2 𝑦𝑝 − ത𝑦 2 𝛴 𝛴
  • 91. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 – 0.6 0.4 –1.6 0.4 1.4 𝑦 − ത𝑦 mean y 3.6 𝑦𝑝𝑦 − ത𝑦 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (𝑦𝑝 − ത𝑦) -0.8 -0.4 0 0.4 0.8 𝑅2 = 𝑦 − ത𝑦 2 𝑦𝑝 − ത𝑦 2 𝛴 𝛴
  • 92. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 – 0.6 0.4 –1.6 0.4 1.4 𝑦 − ത𝑦 mean y 3.6 𝑦𝑝𝑦 − ത𝑦 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (𝑦𝑝 − ത𝑦) -0.8 -0.4 0 0.4 0.8 𝑦𝑝 − ത𝑦 2 6.4 1.6 0 1.6 6.4 𝑅2 = 𝑦 − ത𝑦 2 𝑦𝑝 − ത𝑦 2 𝛴 𝛴
  • 93. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 – 0.6 0.4 –1.6 0.4 1.4 𝑦 − ത𝑦 mean y 3.6 𝑦𝑝𝑦 − ത𝑦 2 0.36 0.16 2.56 0.16 1.96 2.8 3.2 3.6 4.0 4.4 (𝑦𝑝 − ത𝑦) -0.8 -0.4 0 0.4 0.8 0.64 0.16 0 0.16 0.64 1.6 𝑅2 = 𝑦 − ത𝑦 2 (𝑦𝑝 −ത𝑦 2 𝛴 𝛴 5.2𝛴 𝛴 1.6 5.2 = 𝑦𝑝 − ത𝑦 2
  • 94. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑥 1 2 3 4 5 3 4 2 4 5 𝑦 – 0.6 0.4 –1.6 0.4 1.4 𝑦 − ത𝑦 mean y 3.6 𝑦𝑝𝑦 − ത𝑦 2 3.6 1.6 2.56 1.6 1.96 2.8 3.2 3.6 4.0 4.4 (𝑦𝑝 − ത𝑦) -0.8 -0.4 0 0.4 0.8 (𝑦𝑝 −−ത𝑦 2 6.4 1.6 0 1.6 6.4 11.32 16 𝑅2 ≈ 0.3
  • 95. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑅2 ≈ 0.3 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 96. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑅2 ≈ 0.7 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 97. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑅2 ≈ 0.9 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 98. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑅2 ≈ 1 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 99. Copyright © 2017, edureka and/or its affiliates. All rights reserved.Machine Learning Training with Python www.edureka.co/python Calculation of 𝑹 𝟐 𝑅2 ≈ 0.02 Independent Variable Dependent Variable X Y 1 2 4 5 60 3 1 2 3 4 5 Actual vs Predicted Value
  • 100. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Are Low R-squared values always Machine Learning Training with Python www.edureka.co/python
  • 101. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Are High R-squared values always Machine Learning Training with Python www.edureka.co/python
  • 102. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DEMO Let’s learn to code © MadeByShape Ltd. Web Design Manchester 2018. All Rights Reserved.
  • 103. Copyright © 2017, edureka and/or its affiliates. All rights reserved.