Numerical Linear Algebra Cookbook
A review of numerical linear algebra for machine learning.
This review covers material from Part 2 of Linear Algebra and Learning from Data (LALFD).
Least Squares: Solution Methods
Many applications produce overdetermined linear systems
Setting the gradient to zero yields the normal equations:
Four computational approaches exist, ordered from most robust to regularised:
- Singular Value Decomposition (SVD): Compute
, the pseudoinverse of , then solve . Most numerically stable for ill-conditioned matrices. - Normal Equations: Solve
directly when has full column rank. Fast but sensitive to numerical precision. - QR Decomposition: Factor
using Gram-Schmidt to produce orthogonal columns . Better numerical stability than normal equations. - Regularisation: Minimise
to avoid overfitting. The penalty term constrains solution magnitude, yielding .
Further Reading
- Normal equations — Understanding the algebraic derivation
- Projections onto vectors — Geometric intuition for least squares solutions
- Projections — Comprehensive coverage of projection methods