Walk instead of solve
The topic Least squares ended with two problems of the closed form. The normal equations need the matrix and a solve that costs , out of reach for a million features. And they exist only for squared error: the Huber loss has no formula for its minimizer, and neither does any classification loss in this course.
Both problems have one answer. Instead of solving , walk towards that point. Start anywhere, take a small step against the gradient, repeat:
The negative gradient is the direction of steepest descent, and is the step size, or learning rate. Both come from the topic Unconstrained optimization of Mathematics for ML. Here we look at what they do to a model.
The loss is the mean squared error from Least squares, . Its gradient is
That is two matrix–vector products: first the residuals , then times them. A step costs , and only the number of nonzero entries when is sparse. Nothing of size is ever formed.
Take four points , and the model , so has the columns and . The minimum is with . At we have and . With :
| step | ||
|---|---|---|
| 0 | ||
| 1 | ||
| 2 |
The loss falls. But the slope jumped from past its target to , then back to . The next block explains the overshoot.