Linear Regression Explained in Python
Linear Regression Explained in Python
[Link]
A technique of finding the relationship between two or
more variables
Change in dependent variable is associated with a
Regression?
[Link]
Regression is a technique that displays the relationship
between variable “y” based on the values of variable “x”.
Regression?
[Link]
Temperature vs. Number of cones sold at ice cream store
Use Case
If you think there is a relationship between
two things regression would help confirm it!
[Link]
There are various types of Regression, but we will focus on:
Linear Regression
Regression
[Link]
LINEAR REGRESSION LOGISTIC REGRESSION
[Link]
Simple linear regression is useful for finding
[Link]
Y
Understandin Line
Dependent Variable
g Linear
Regression
X
Independent Variable
[Link]
Y
Understandin +ve
Dependent Variable
g Linear
Regression
X
Independent Variable
[Link]
Y
Understandin
Dependent Variable
g Linear
Regression
-ve
X
Independent Variable
[Link]
Y
Line
Understandin
Dependent Variable
g Linear
Regression
X
Independent Variable
[Link]
Y
Line of Linear
Regression
Understandin
Dependent Variable
g Linear
Regression
X
Independent Variable
[Link]
Y
Understandin
Dependent Variable
g Linear
Regression Observation
X
Independent Variable
[Link]
Y
Regression Line
Dependent Variable
g Linear
Regression
X
Independent Variable
[Link]
Y
error
Dependent Variable
g Linear error
Regression
Actual Value
X
Independent Variable
[Link]
Y
Understandin
Dependent Variable
g Linear
Regression
Minimize the
error
X
Independent Variable
[Link]
Y
g Linear
Distance
Regression
X
Speed
[Link]
Y
Understandin y = mx + c
g Linear
Distance
Distance travelled
in a fixed duration
Regression of time
X
Speed
[Link]
Y
Speed of
Understandin
Vehicle
y = mx + c
g Linear
Distance
Regression
X
Speed
[Link]
Y
Understandin y = mx + c
g Linear
Distance
m = +ve slope of line
Regression
X
Speed
[Link]
Y
Understandin y = mx + c
g Linear
Distance
Regression
c = y - intercept of the line
X
Speed
[Link]
Y
Understandin y = - mx + c
g Linear
Time
Time taken to travel
a fixed distance
X
Speed
[Link]
Y
Independent Variable
Understandin
Dependent Variable
y = mx + c
Regression
X
Independent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
Y 1 4
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
Y 1 4
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
Y 1 4
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
Y 1 4
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean: 𝒙 3 3.6
18/ mean : 𝒚
5
2
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
y = mx+c 1 4
Y
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 ( , ) mean 3 3.6
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
y = mx+c 1 4
Y
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 ( 3 , 3.6 ) mean
1
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦
y = mx+c 1 4
Y
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
y = mx+c 1 4
Y
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
Y
y = mx+c 1 4 1 −3
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
Y
y = mx+c 1 4 −2
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
Y
y = mx+c 1 4 −2
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
Y
y = mx+c 1 4 −2
2 −3
D ependent
Variable 2 3
5 3 4
4 2
4 5 5
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥
Y
y = mx+c 1 4 −2
−1
D ependent
Variable 2 3
5 3 4 0
4 2 1
4 5 5 2
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦
Y
y = mx+c 1 4 −2
−1
D ependent
Variable 2 3
5 3 4 0
4 2 1
44 5 5 2
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦
Y
y = mx+c 1 4 −2 4 −3.6
−1
D ependent
Variable 2 3
5 3 4 0
4 2 1
4 5 5 2
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−
−𝑦
Y
y = mx+c 1 4 −2 0.4
−1
D ependent
Variable 2 3
5 3 4 0
4 2 1
4 5 5 2
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦
Y
y = mx+c 1 4 −2 0.4
−1 3 − 3.6
D ependent
Variable 2 3
5 3 4 0
4 2 1
4 5 5 2
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦
Y
y = mx+c 1 4 −2 0.4
D ependent
Variable 2 3 −1 − 0.6
5 3 4 0 0.4
4 2 1 − 1.6
4 5 5 2 1.4
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑦 2
𝑥 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥
Y
y = mx+c 1 4 −2 0.4 4
D ependent
Variable 2 3 −1 − 0.6 1
5 3 4 0 0.4 0
4 2 1 − 1.6 1
4 5 5 2 1.4 4
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -2 x 0.4
D ependent
Variable 2 3 −1 − 0.6 1
5 3 4 0 0.4 0
4 2 1 − 1.6 1
4 5 5 2 1.4 4
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m=
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦) 1
m= =
1 𝛴 𝑥−𝑥 2 10
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
3.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
0.1
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 2 3 −1 − 0.6 1 0.6
3
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable
3.6 = 0.3 + 𝑐 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable 3.6 − 0.3 = 𝑐 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable
3.3 = 𝑐 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable
3.3 = 𝑐 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
c=3.3
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
X
0 1 2 3 4 5 6 I ndependent Variable
[Link]
Understanding Linear
Regression
𝑥 𝑦 𝑥−𝑥 𝑦−𝑦 𝑥−𝑥 2 (𝑥 − 𝑥)(𝑦 − 𝑦 )
Y
y = mx+c 1 4 −2 0.4 4 -0.8
D ependent
Variable
3.3 = 𝑐 2 3 −1 − 0.6 1 0.6
5 3 4 0 0.4 0 0
4 2 1 − 1.6 1 -1.6
4 5 5 2 1.4 4 2.8
3 mean 3 3.6 𝛴 = 10 𝛴=1
c=3.3
2 𝛴 (𝑥 − 𝑥)(𝑦 − 𝑦)
m= = 0.1
1 𝛴 𝑥−𝑥 2
Equation of Regression line for m = 0.1, c = 3.3 is:
X
0 1 2 3 4 5 6 I ndependent Variable
y = 0.1x+3.3
[Link]
Mean Square Error
m = 0.1
Y
D ependent c = 3.3
Variable
y = 0.1x + 3.3
5
For given m = 0.1 & c = 3.3 ,
4 Lets predict values for y when
x = {1,2,3,4,5}
3
y = 0.1 x 1+ 3.3 = 3.2
y = 0.1 x 2+ 3.3= 3.1
2 y = 0.1 x 3+ 3.3= 3.0
y = 0.1 x 4+ 3.3= 2.9
y = 0.1 x 5+ 3.3= 2.8
1
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Mean Square Error
m = 0.1
Y
D ependent c = 3.3
Variable
y = 0.1x + 3.3
5
For given m = 0.1 & c = 3.3 ,
4 L ine of Regression
Lets predict values for y when
x = {1,2,3,4,5}
3
y = 0.1 x 1+ 3.3 = 3.2
y = 0.1 x 2+ 3.3= 3.1
2 y = 0.1 x 3+ 3.3= 3.0
y = 0.1 x 4+ 3.3= 2.9
y = 0.1 x 5+ 3.3= 2.8
1
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Finding the best Fit Line
[Link]
Goodness of Fit – 𝑹𝟐
𝑥 𝑦𝑝
Y 1 3.2
D ependent
Variable 2 3.1
5 3 3.0
4 2.9
4 L ine of Regression
5 2.8
3
𝑅2 =
𝛴 (Predicted Distance – Mean)2
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑥 𝑦 𝑦𝑝 (𝑦𝑝 − 𝑦)
Y 1 4 3.2 3.2-3.6
D ependent
Variable 2 3 3.1
5 3 4 3.0
4 2 2.9
4 L ine of Regression
5 5 2.8
3
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑥 𝑦 𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦)
Y 1 4 3.2 -0.4 4 – 3.6
D ependent
Variable 2 3 3.1 -0.5
5 3 4 3.0 -0.6
4 2 2.9 -0.7
4 L ine of Regression
5 5 2.8 -0.8
3
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑥 𝑦 𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦)
Y 1 4 3.2 -0.4 0.4
D ependent
Variable 2 3 3.1 -0.5 -0.6
5 3 4 3.0 -0.6 0.4
4 2 2.9 -0.7 -1.6
4 L ine of Regression
5 5 2.8 -0.8 1.4
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
2
Y
D ependent
3.2 -0.4 0.4 −0.4
Variable 3.1 -0.5 -0.6
5 3.0 -0.6 0.4
L ine of Regression
2.9 -0.7 -1.6
4
2.8 -0.8 1.4
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
𝑦 −𝑦 2
2
Y 3.2 -0.4 0.4 0.16 0.4
D ependent
Variable 3.1 -0.5 -0.6 0.25
5 3.0 -0.6 0.4 0.36
2.9 -0.7 -1.6 0.49
4 L ine of Regression
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
𝑦 −𝑦 2
1 𝛴 𝑦𝑝 − 𝑦
2
𝑅2 =
X I ndependent 𝛴 𝑦−𝑦 2
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
𝑦 −𝑦 2
3 𝛴 1.9
𝛴 5.2
𝑅 2
=
𝛴 𝑦𝑝 − 𝑦
2
=
1.9
1 𝛴 𝑦−𝑦 2 5.2
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
𝑦𝑝 (𝑦𝑝 − 𝑦) (𝑦 − 𝑦) 𝑦𝑝 − 𝑦
2
𝑦 −𝑦 2
3 𝛴 1.9
𝛴 5.2
𝑅2 =
𝛴 𝑦𝑝 − 𝑦
2
= 0.36
1 𝛴 𝑦−𝑦 2
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
4 L ine of Regression
𝑅2 ≈ 0.6
3
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
4 L ine of Regression
𝑅2 ≈ 0.9
X I ndependent
Variable
0 1 2 3 4 5 6
[Link]
Goodness of Fit – 𝑹𝟐
4 𝑅2 ≈ 1
L ine of Regression
I ndependent
Variable
X
0 1 2 3 4 5 6
[Link]
[Link]
India : +91-7847955955
sales@[Link]
[Link]