Unit 4 - Linear Regression
Unit 4 - Linear Regression
Regression Classification
Dependent Variable
- A dependent variable is the variable being tested and measured in a scientific
experiment.
- This is the main factor that you’re trying to understand or predict.
Independent Variables
- the variables that are changed or controlled in a scientific experiment to test the effects
on the dependent variable.
- These are the factors that you hypothesize have an impact on your dependent variable.
For example, a scientist wants to see if the brightness of light has any effect on a moth being
attracted to the light. The brightness of the light is controlled by the scientist. This would be the
independent variable. How the moth reacts to the different light levels (distance to light
source) would be the dependent variable.
Regression Model
Regression
Models
One Multiple
Feature Features
Learning Algorithm
Size of h Estimated
house price
x hypothesis Estimated
value Linear regression with one variable.
Univariate linear regression.
h maps from x’s to y’s One variable
How to choose ?
Size in feet2 (x) Price ($) in 1000's (y)
2104 460
1416 232
Training Set
1534 315
852 178
… …
Hypothesis:
: Parameters
3 3 3
h(x) = 1.5 + 0·x h(x) = 0.5·x
2 2 2
1 1 1 h(x) = 1 + 0.5·x
0 0 0
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
Cost Function
y
Θ0, Θ1
3 3
2 2
y
1 1
0 0
0 1 x 2 3 -0.5 0 0.5 1 1.5 2 2.5
𝐽 ( 1 )=0
Cost Function Minimization
(for both parameters)
Hypothesis:
Parameters:
Cost Function:
Goal:
(for fixed , this is a function of x) (function of the parameters )
Contour plot
(for fixed , this is a function of x) (function of the parameters )
= 360
=0
(for fixed , this is a function of x) (function of the parameters )
Outline:
• Start with some
• Keep changing to reduce
until we hopefully end up at a minimum
:= -
≥ 0
:= -
:= -
≤ 0
:= -
Current value of
=> .0
=>
The parameter values will not be changed
Gradient descent algorithm
assignment
a:=b
Simultaneously update
Learning rate &
update
and
simultaneously
J(0,1)
1
0
J(0,1)
1
0
Convex function
Bowl-shaped
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
(for fixed , this is a function of x) (function of the parameters )
Linear Regression with multiple Feature
Gradient Descent Algorithm
Gradient Descent Algorithm
Suppose we have 2 features, then
Polynomial Regression