Lesson 4 of 9 10 min · 118 words
The closed-form solution
The normal equation and when it is practical.
Setting the gradient of to zero gives — the normal equations — and, if is invertible:
This gives the exact optimum in one step, with no learning rate or iterations. The cost is forming and solving a system, roughly . That is instant for tens or hundreds of features but impractical for hundreds of thousands.
is singular when features are perfectly collinear or when . Then there are infinitely many solutions; ridge regression's or the pseudo-inverse fixes it. Numerically, libraries use QR or SVD decompositions rather than computing the inverse directly.
Formula to remember
MSE gradient
Used for gradient-descent training.
Quick check · +5 XP