Professional Documents
Culture Documents
LR 3
LR 3
Regression -
3
evaluation metric
-
Adjusted R2 Score -
-
Statsmodel Implementation
-
L = lyi - y e
L
W wo
*
=
arguin
i ,
Wo
i
x T(y y)
e Lz
lyi - Yildi
2
2
-
&
-
-
& Fr
E T
-
aw , GW2
↳
GW .
I
-
Elyi - iel n
update rule :
With
it-y L
with Not-ycwo
N
y .
.
y
2 -
In I XW + Wo
Is
i
Importance of feature scaling
other features
I
-
-
fi
d f2
>
I
fu L
fi =
km-driven f2 =
age
fa
fod d
- -to-
o
. -
·
f - S
When features fl
not scaled
features are
are
normalized
R-2
Adjusted
Score - variant
of R-2 scre
to R-2 Score ?
what will happen
Mythe
↳ Met a
Wid , ten ,
reduce
want s in
Meg might
to Zero
used and
Eg -
predicting car
selling prices you
time
of manufacture"
solu weird
correlation
age as
price Y↑
ice-cream sales
-
age
-
R2 can also go up
Goal : To heate c metric that penalizes the
feature
irrelevant to
.
the model
incorporation of an
[
1 (1 R2) (n-1)
-
Adjusted
-
Rascose =
(n -
d -
1)
-
R2 - R
data points R2 R2 R2 scose
n #
of
=
= =
d = #
of features
to Adj R2 'd'increases ?
Of what happens .
as
di n - d- 1d +4 1 - t d
S ,
n -d -1 & u-d-1
=> as d 4 adj .
R2 score should decrease
, .
R2 ↑ and di
Ans
#
Implement the Adj .
R2 score in
Python
R2 d
inputs = score
,
n
,
Quiz R2 I
Ste
=
-
-M In -
AdiR2 = 1
(n - d -
1)
adj Rascos =
I (man)
zok)if R2 =
1 =
O
adiR2 Score
-
d+ 1
=
if n = =
R2 E C-8 1]
Adj
,
.
Sure
Stats model Implementation =
Add two
= Wili t Wade
....
① 21 4 ,2 . .
Red 1
⑲ = W, 2 TW2 M12 . . Walled +Wo (1)
② I
1
④ ↓ in this case we can use wo like a
1
④ which has
for affth feature
weight
i value = 1 for all the data points .
I does this
Stab model
* linear regression
implementation
OLS model >
-
Squared error
↓
minimite
used statisticians
stats model >
-
by
lot statistical data that be
>
-
a
of
used to evaluate the model .
age
- =
[
Man I Scaler =
E
= 10
Mi -
~
X-train
X-train : Scaler fit-transform (X-train)
.
C ↳
& Ex-test learns Scales the
↳ Max min
, data
all these data
scaled X-test = Scaler transform (X-test)
points will be
d
10 data
using testing
max =
scale the
min
=
I
values
min, mon
which were learnt from using date
data ? learnt from training
training
normalization ?
the date before doing
of why are we
splitting
be unseen
and don't
Ans) we want Xetest to
test to
flow from
want any information
did
train which Can happen if we
m
eman- . . .
object >
- attributes
↳ min--
Scaler .
T(X-fest)
Scale . transform (4-tet)
Information to normalize
to scale.
use this individual
date -
itself
always comes from the training
Statsmodel summary
+ P < /t 10 .
025 0 .
975]
Coef stderror
7 2 4 5
:
O
-
-8 293
-
.
5: 9
:
0 7
km-driven
- .
95 % CF
of
the weight of
the feature
E
-
n : 2 -5 9 .
-6 . 2 - -- I
, ,
Y
d
Std . error -
95 % CI T
statsmodel
Hypothesis test run
by
:
E-ni2,5 9 -6 2 I
Su .
. - --
:
,
P < It
P-value D
20 5
P-value
.
Assumptions of Linear Regression
Linear Regression
L d
Statistics optimization
-
>
-
I
-
multicollinearity
&
No
-
valid
-
Normality of residuals
if all assumptions an
-
No Heteroskadasticity we have a
very
Linear
Autocorrelation
-
No
regression .
Assumption
of Linearity
price
Prize T
-
a
i
-
- +
a
,
-
X
>
Run-driven
-
-
There is a linear relationship Non-hear relationship
and feature
b) ~ the target
us better performance
give
quit) fic Ac ,
fs fu,
m
-
variance