chapter 6 Model representation

liner regression. this chapter see what the model looks like and what the overall process of supervised learning looks likes.

supervised learning ,has a data set ,called training set.
Machine Learning Wu Enda2
m =Number of traning examples
x’s = “input” variable/features
y’s =”output” variable/”target” variable
(x,y) - a single training example
(xi,yi) - ith training example

Machine Learning Wu Enda2
h - hypothesis
Housing price prediction model called linear regression, linear regression with one variable(univariate linear regression )

chapter 7 Cost function

-Housing price prediction
hypothesis:hθ=θ0+θ1x
θi’s:Parameter
choose θ0,θ1 so that hθ(x) is close to y for our training examples (x,y)

J(θ0,θ1)=i=1m(hθ(xi)yi)2

Goal: minmize(θ0,θ1)J(θ0,θ1),
J(θ0,θ1)is Cost function or Squate error cost function

chapter 8 Cost function intuition 1

give some example to get back to intuition about what the cost function is doing and why we use it .
Machine Learning Wu Enda2
look up some plots to understand the cost function ,to do so ,we simplify the algorithm,so that it only had one parameter theta one.

chapter 10 Gradient descent

it is taking about gradient descent for minimizing some arbitrary function J.

Have some function J(θ0,θ1)
Want minθ0,θ1J(θ0,θ1)
Outline:

  • start with some θ0,θ1.
  • keep changing θ0,θ1 to reduce J(θ0,θ1) until we hopefully end up to a minimum.

Machine Learning Wu Enda2

Gradient descent algorithm:

repeat until convergence {

θj:=θjaθjJ(θ0,θ1) (for j=0 and j=1)

}

a- called the learning rate,it basically controls how big a step we take downhill with gradient descent.

θj - it is a derivative term

simultaneously update :

temp0:=θ0aθ0J(θ0,θ1)

temp1:=θ1aθ1J(θ0,θ1)

θ0:=temp0

θ1:=temp1

in the next chapter ,we’re going to go into the details of the derivative term.which it wrote out but didn’t really define.

chapter 11 Gradient descent intuition

get better intuition about what the algorithm is doing ,and why the steps of the gradient descent algorithm might make sense.

Machine Learning Wu Enda2

Machine Learning Wu Enda2

if a is too small,gradient descent can be slow.

if a is too large,gradient descent can overshoot the minimum.it may fail to converge or even diverge.

Machine Learning Wu Enda2

if you’re already at a local optimum,one step of gradient descent does absolutely nothing.It doesn’t change parameter.cause it keeps your solution at the local optimum.

Gradient descent can converge to a local minimum,even with the learning rate a fixed.

θj:=θjaθjJ(θ0,θ1)

As we approach a local minimum.gradient descent will automatically take smaller steps.So,no need to decrease a over time.

Machine Learning Wu Enda2

derivative term and partial derivative

chapter 12 Gradient descent for linear regression

put together gradient descent with our cost function,and that will give us an algorithm for linear regression for fitting a straight line to our data.

Gradient descent algorithm :

the key term we need is this derivative term over here.

θjJ(θ0,θ1)=θj12mi=1m(θ0+θ1x(i)+y(i))2

j=0:θ0J(θ0,θ1)=1mi=1m(θ0+θ1x(i)+y(i))·(θ0+θ1x(i)+y(i))=1mi=1m(θ0+θ1x(i)+y(i))

j=0:θ1J(θ0,θ1)=1mi=1m(θ0+θ1x(i)+y(i))·(θ0+θ1x(i)+y(i))=1mi=1m(θ0+θ1x(i)+y(i))·x(i)

Machine Learning Wu Enda2

“Batch” Gradient Descent :

“Batch”: Each step of gradient descent uses all the training examples.

相关文章: