728x90

해당 내용은 coursera Andrew Ng교수의 Machine Learning강의노트정리

Normal Equation

Gradient descent는 global minimum으로 수렴하는 방식으로 해를 찾는 다면 Normal equation은 $\theta$ 의 해를 직접적으로 찾는 방법이다.

$\theta = (X^TX)^{-1} X^{T} y$

Gradient Descent

  • Need to choose $\alpha$
  • Needs many iterations
  • $O(kn^2)$
  • works well even when n is large

Normal Equation

  • No need to choose $\alpha$
  • Don’t need to iterate
  • $O(n^3)$, need to compute $(X^TX)^{-1}$
  • slow if n is very large → if $n\gtrsim 10000$겨

경사하강법은 learning rate과 iteration을 통해 최적의 값으로 수렴하도록 해야 한다. 반면 Normal Euqation은 learning rate과 iteration을 할 필요가 없다. 그러나 $(X^TX)^{-1}$값을 구할 수 있어야 하고 feature의 개수가 커지면 computation cost가 증가하여 계산속도가 느려지게 된다. $O(n^3)$ 따라서 feature가 많을 경우 Gradient descent가 더 잘 작동한다.

if $X^TX$non_invertible?

  • 중복되는 변수를 제거 → linearly dependent
  • 변수가 너무 많은 경우 → 데이터의 갯수 $\le$ 변수의 수
    • 변수를 줄이거나 regularization을 해줌

Refrenece
Machine learning , Coursera, Andrew Ng 

728x90

+ Recent posts