Professional Documents
Culture Documents
ML 5
ML 5
1 / 21
Contents
Regression
2 / 21
Regression
f : X → Y (continuous) (1)
Many functions can be used. Simplest → linear function
3 / 21
Regression
Figure:
Figure: 4 / 21
Regression
Let green line is the actual function from which the points were
generated.
Need to find out how good is the line wrt the training examples.
To measure how good is the line → define the error of the line.
5 / 21
Regression
Find the distance of the point from this red line, and take the
squared distance from each point to the line, and take the sum of
squared errors.
6 / 21
Regression
Figure:
7 / 21
Regression
8 / 21
Regression
Sum of squared errors fig (a) > (b) > (c) > (d)
Fig(d) → even though the red line is fitted to all the points, this
function does not really correspond to the green line. So, for
other points, the error may be higher.
Fig(c) → function seems to have fit the points much better, and
within this range, the fit to the green line will be smaller.
9 / 21
Types of regression models
Simple (1 feature)
Linear
Non-linear
Multiple(2+ feature)
Linear
Non-linear
10 / 21
Linear regression
Figure:
11 / 21
Linear regression
Figure:
12 / 21
Linear regression
Given, the data points task is to find the parameters of the line i.e
b0 &b1
Y = bo + b1 x + (2)
13 / 21
Linear regression
Y = bo + b1 x + b2 x2 + ....bp xp + ε (3)
14 / 21
Linear regression
Assumptions
E(εi ) = 0
15 / 21
Linear regression
The least-squares regression line is the unique line such that the
sum of squared vertical (y) distances between the data points and
the line is the smallest possible.
SSE is
X
(yi − (bˆo + bˆ1 xi ))2 (5)
dD
16 / 21
Simple Linear regression
For 2 − d problem
Y = bo + b1 X (6)
To find the values of the coefficients which minimizes the
objective function, partial derivative of the objective function
(SSE) w.r.t coefficient is taken and set to 0
P P P
n xy − x y
b1 = P 2 P (7)
n x − ( x)2
P P
y − b1 x
bo = (8)
n
This is a closed form solution.
17 / 21
Multiple Linear regression
Y = bo + b1 X1 + b2 X2 + ...bn Xn (9)
n
X
h(x) = bi xi (10)
i=0
18 / 21
Multiple-choice
1 (X-intercept, Slope)
2 (Slope, X-Intercept)
3 (Y-Intercept, Slope)
4 (Slope, Y-Intercept)
19 / 21
Multiple-choice
1 (X-intercept, Slope)
2 (Slope, X-Intercept)
3 (Y-Intercept, Slope)
4 (Slope, Y-Intercept)
Answer (3)
20 / 21
Thank You
21 / 21