lecture7-linear-regression
lecture7-linear-regression
Camp
Sibt ul Hussain
http://sites.google.com/SibtulHussain
Linear Regression
42000
41000
40000
39000
Series1
38000
37000
36000
35000
0 20 40 60 80 100 120 140 160 180 200
3
500000
Housing Prices400000
300000
Price 200000
(in
1000s of 100000
dollars)
0
500 1000 1500 2000 2500 3000
Size (feet2)
Regression Problem
Predict real-valued
output
4
Training set of
housing prices Size in Price ($) in
feet2 (x) 1000's (y)
2104 460
1416 232
1534 315
852 178
Notation: … …
m = Number of training examples
x’s = “input” variable / features
y’s = “output” variable / “target” variable
5
‘s: Parameters
How to choose ‘s ?
6
3 3 3
2 2 2
1 1 1
0 0 0
0 1 2 3 0 1 2 3 0 1 2 3
7
Idea: Choose so
that
is close
to for our
training examples
8
Cost Function
• Cost function is used to evaluate our
hypothesis, i.e. how good is our chosen
hypothesis.
▫ For instance, in case of linear regression cost
functions can be:
Hypothesis:
Parameters:
Cost Function:
Goal:
11
• Properties:
▫ Penalty for positive and negative deviations the
same
▫ Penalty for large deviations remains same, that
is an error with small value as well as large
value receives same treatment.
▫ Difficult to derivate (non-differentiable at zero).
▫ Convex
12
• Properties:
▫ Penalty for positive and negative deviations
is same
▫ Penalty for large deviations is large
compared to small deviations.
▫ Easy to derivate.
▫ Convex
13
L2 Cost Function
14
How ???
17
Feature Scaling:
Non-Linear Case
• Algorithm:
▫ Expand each feature to include the non-
linear mapping.
▫ Learn set of parameters using gradient
descent.