When eigenvectors are not enough
The topic Symmetric matrices and quadratic forms gave symmetric matrices a perfect description: an orthonormal basis of eigenvectors along which the matrix only stretches. Real data matrices are neither square nor symmetric. A dataset of examples with features is a matrix , and a linear layer maps to . For a rectangular matrix the equation does not even make sense: and live in different spaces.
Even a square matrix can let us down. Take the running example of this topic:
Its trace is and its determinant is , so its eigenvalues are . No real direction is merely stretched. Yet the geometry is simple: sends the unit circle to an ellipse, and an ellipse has two perpendicular axes.
The fix is to allow two orthonormal bases, one for the inputs and one for the outputs. Every matrix of rank factors as
Here and are orthogonal. Their columns and are the left and right singular vectors. The matrix has the same shape as and is zero except for its diagonal. The diagonal starts with the singular values and continues with zeros. This is the singular value decomposition, or SVD. Unlike an eigendecomposition, it exists for every real matrix of any shape.
The sum on the right reads as a recipe. Each term takes the component of the input along , scales it by and writes the result along . So is a sum of rank-one pieces, sorted from the most important to the least.
For a tall data matrix most columns of meet only the zero rows of . Libraries can skip them: np.linalg.svd(X, full_matrices=False) returns just the first columns.