normal equation

来源:互联网 发布:平板qq软件 编辑:程序博客网 时间:2024/04/26 07:18

normal equation:
Method to solve for θ analytically.
one step to get the optimal value.

θ=(XTX)1XTy

Octave:

pinv(X'*X)*X'*y

Gradient Descent
- Need to choose α
- Needs many iterations
- Works well even when n is large
Normal Equation

  • No need to choose alpha
  • Don’t need to iteration
  • Need to compute (XTX)1
  • Slow if n is very large(beyond 104)

    What if XTX is non-invertible?

  • Redundant features
    (e.g. x1=size in feet
    x2= size in m)

  • Too many features(e.g.m<=n)
    delete some features, or use regularization.
0 0
原创粉丝点击