Least-squares geometry
A least-squares output is the attainable output that minimizes the sum of squared residual components relative to a target.
On this page 7 sections
01Choose an attainable output#
A linear model can produce outputs by changing its coefficients . Measurements may fall outside that set. Least squares selects the attainable output with the smallest sum of squared errors.
Suppose the allowed outputs are and the target is . Matching both coordinates exactly would require and simultaneously. The target is inconsistent with the model, so some error remains.
Output leaves residual . Its squared error is . Output leaves and squared error . Squaring keeps opposite errors from cancelling.
Outputs are for real . Target . Closest output?
Show answer and explanation
is perpendicular to .
02Why the closest point wins#
Every allowed displacement from has the form . Its dot product with the residual is zero. The residual is perpendicular to the directions in which the model can move.
Moving to gives squared errors and . Their linear terms cancel when added:
The extra term is nonnegative. No allowed move improves on .
The same reasoning works for a linear output subspace. A perpendicular residual adds no cross term when the squared distance is expanded. Moving away adds the squared length of the allowed displacement.
Two channels output for real . Target . Minimum sum of squared errors?
Show answer and explanation
Closest output ; error .
03Coefficients and predictions differ#
For outputs and target , the closest output is . Its residual is perpendicular to direction because .
The fitted coefficient is ; the fitted output is the pair . Reporting a coefficient when asked for an output confuses two different objects. The nonzero residual does not make this fit incorrect.
Outputs: , real . Target . Claim: exact fit. Closest output?
Show answer and explanation
is attainable; its error is vertical.
If the target already lies in the attainable subspace, its closest output is itself and the minimum error is zero. Otherwise, the closest output still exists in this finite-dimensional linear setting. Whether the coefficients producing it are unique is a separate question.
In ML, this geometry explains the best training fit within a chosen linear model. It does not establish performance on new observations. Computing coefficients efficiently and evaluating generalization have their own lessons.
Choose an attainable output whose residual is perpendicular to the output subspace.
- Identify the closest attainable output in an inconsistent linear system.
Sources & further reading
- [1]Margalit and Rabinoff: Interactive Linear Algebra, 6.5 The Method of Least Squares ↗textbooks.math.gatech.edu · Article
- [2]Margalit and Rabinoff: Interactive Linear Algebra, 6.3 Orthogonal Projection ↗textbooks.math.gatech.edu · Article
- [3]Boyd and Vandenberghe, Introduction to Applied Linear Algebra ↗stanford.edu · Article