Professional Documents
Culture Documents
Linear Regression: Study On The Coursera All Right Reserved: Andrew NG
Linear Regression: Study On The Coursera All Right Reserved: Andrew NG
Linear Regression: Study On The Coursera All Right Reserved: Andrew NG
Size (feet2)
Supervised Learning Regression Problem
Given the “right answer” for Predict real-valued output
each example in the data.
Training set of Size in feet2 (x) Price ($) in 1000's (y)
housing prices 2104 460
1416 232
1534 315
852 178
… …
Notation:
Training Set
m = Number of training examples
Hypothesis:
‘s: Parameters
How to choose ‘s ?
y
Parameters:
Cost Function:
Goal:
Price
($)
in
1000’s
Question:How to minimize J?
Gradient Descent
Outline:
• Start with some
• Keep changing to reduce
until we hopefully end up at a minimum
Gradient descent algorithm
Current value of
Unchange
update
and
simultaneously
J(θ0,θ1)
θ1
θ0
(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
variables
Hypothesis:
Parameters:
Cost function:
Gradient descent:
Repeat
(simultaneously update )
Normal Equation in Linear
Examples:
Regression
Size (feet2) Number of Number of Age of home Price ($1000)
bedrooms floors (years)
1 2104 5 1 45 460
1 1416 3 2 40 232
1 1534 3 2 30 315
1 852 2 1 36 178
simultaneously update
Difference
Gradient Descent Normal Equation
• Need to choose α • No Need to choose α
• Needs many iterations • Don’t need to iterate
• Works well even n is • Slow if n is large
large