Orthogonal Projections
Formal
(Projection)
Let be a vector space and a subspace of . A linear mapping is called a projection if . Since Linear mappings can be expressed as matrices (Matrix Representation of Linear Mappings), the preceding definition applies to a special kind of transformation matrices called projection matrices which exhibit the property that .
(Projections onto 1-dimensional subspaces)
We want to project a vector onto a subspace where has exactly one basis vector (owing to the subspace being 1-dimensional). Any point on the line (element of vector space ) can be expressed as a scaled version of .
Therefore, the projection of onto the line, which we call , must be a multiple of :
Our goal is to find the scalar coefficient .
Notice that the “error vector” connecting the projection to the original vector, which is , must be orthogonal to the direction of line, .
Using the linearity of inner product, we can expand this:
Therefore,
Substituting (2) back in (1), we get
Now, if the basis vector were a unit vector ,
(Projections onto general subspaces)
The key to projecting onto a general k-dimensional subspace U is to first find an orthonormal basis for that subspace. As we discussed, this is like finding a perfect, perpendicular coordinate system for our subspace where every axis vector has a length of one.
Once you have this orthonormal basis, the magic happens: the complex problem of projecting onto a high-dimensional subspace breaks down into a series of simple projections onto lines.
The orthogonal projection of a vector x onto the subspace U is simply the sum of its individual projections onto each of the orthonormal basis vectors.
Since we know the simple formula for projecting onto a line spanned by a unit vector , we can substitute it in for each term:
This result states that to find the best approximation of x in U, you just need to:
- Calculate the coordinate (the scalar inner product ) of x along each basis direction of .
- Scale each basis vector by its corresponding coordinate.
- Sum these scaled basis vectors together. The vector you create, , is guaranteed to be the vector in that is closest to the original vector . Matrix form: The projection matrix for a subspace with an orthonormal basis B is:
ML Applications
This matrix form is not just a notational convenience; it is the exact formula used in the solution to many machine learning problems.
- Linear Regression: The solution for the optimal weight vector β in Ordinary Least Squares is given by , where is the matrix of features and y is the target vector. The vector of predicted values, , is then given by . If you substitute the formula for in, you get:
This is exactly the projection formula! The matrix is known in statistics as the hat matrix, because it “puts the hat on y” . It is the projection matrix that orthogonally projects the vector of true outcomes y onto the subspace spanned by the features in X.
Connections
- Forward Links: Gram-Schmidt Orthogonalization
- Backward Links: Angles and Orthogonality, Inner Products