Computing Parameters Analytically Normal Equation We have introduced a way of computing our parameter \(\theta\) – Gradient Descent But in Gradient Descent, we need to compute it by iteration, and it is obviously very complicated. In some cases, we still need feature scaling and mean normalization. Now there is a analytically way of computing parameter – Normal Equation . In the “Normal Equation” method, we will minimize J by explicitly taking its derivatives with respect to the θj ’s, and setting them to zero. This allows us to find the optimum theta without iteration. The normal equation formula is given below: \(θ=(X^TX)^{−1}X^Ty\) There is no need to do feature scaling with the normal equation. In Octave , use pinv(x'*x)*x'*y Gradient Descent Normal Equation Need to choose alpha No need to choose alpha Need lots of iterations No need to iterate \(O(kn^2)\) \(O(n^3)\) Inverse needs \(O(n^3)\) and \(X^TX\) needs \(O(n^2)\) Works well n is lar...
评论
发表评论