Singular Value Decomposition (SVD)
The Singular Value Decomposition (SVD) is the most general and numerically stable way to decompose (factorize) any matrix, , into three component matrices. It works for square, rectangular, invertible, and non-invertible matrices—unlike Eigen-Decomposition, which requires square matrices.
SVD is a workhorse in data science, used everywhere from image compression to building recommendation engines.
1. The SVD Formula
Any matrix can be decomposed into the product of three other matrices:
Let's break down the components:
| Component | Shape | Properties | Role |
|---|---|---|---|
| Orthogonal () | Columns are the left singular vectors (basis for the column space of ). | ||
| (Sigma) | Diagonal (non-zero only on the main diagonal) | Diagonal elements are the singular values (). | |
| Orthogonal () | Rows are the right singular vectors (basis for the row space of ). |
The Singular Values ()
The singular values on the diagonal of are always positive and ordered from largest to smallest (). They quantify the importance or energy along the corresponding singular vectors.
2. Geometric Interpretation
SVD reveals that any linear transformation defined by can be viewed as a sequence of three simpler, geometric transformations:
- A rotation or reflection (defined by ).
- A scaling along the new axes (defined by ).
- Another rotation or reflection (defined by ).
This perspective is crucial for understanding how the matrix transforms data.
3. Applications in Machine Learning
SVD's ability to expose the latent structure of a matrix makes it indispensable in ML.
A. Principal Component Analysis (PCA)
SVD provides a direct and often more efficient way to perform PCA.
- If the input data matrix is , we can compute the SVD of : .
- The right singular vectors () are the same as the eigenvectors of the covariance matrix (), which are the Principal Components.
- The singular values () are related to the eigenvalues and directly tell us the variance along each component.
This approach is computationally preferable because it avoids the need to explicitly calculate the potentially large covariance matrix .
B. Low-Rank Approximation (Data Compression)
The singular values tell us how much "information" is stored along each dimension. Since the singular values are ordered ( is most important), we can approximate the original matrix by keeping only the top largest singular values and their corresponding vectors.
- is a low-rank approximation of .
- This is used for image and audio compression, and it's why PCA works well for dimensionality reduction: it throws away the dimensions with the least variance (smallest singular values).
C. Recommender Systems (Collaborative Filtering)
SVD is used to model the User-Item Interaction Matrix in collaborative filtering.
- is the matrix where rows are users and columns are movies, and entries are ratings.
- SVD decomposes into factors that represent latent (hidden) user tastes and latent movie characteristics.
- The middle singular value matrix defines the strength of these latent factors.
By decomposing the matrix, we can fill in the missing ratings and make accurate predictions for items a user has not yet seen.
4. SVD vs. Eigen-Decomposition
| Feature | Singular Value Decomposition (SVD) | Eigen-Decomposition |
|---|---|---|
| Matrix Type | Works for ALL matrices. | Only works for square matrices. |
| Component | ||
| Generality | More general, numerically stable, and foundational. | Special case of SVD (when is symmetric, ). |
In practice, if a matrix is non-square or if you need the most stable result, use SVD. SVD is the foundational method for many modern ML techniques.
SVD provides a stable way to find the principal axes of a matrix. The final fundamental concept in Linear Algebra is Diagonalization, which links Eigen-Decomposition to simplified matrix algebra.