SVD and Advanced Decompositions
🚀 SVD & Advanced Decompositions: The Power of Factorization
Matrix factorization allows us to decompose complex datasets into simpler, interpretable components. This is the “Gold Standard” for Dimensionality Reduction and uncovering latent features in massive datasets.
🟢 Level 1: Singular Value Decomposition (SVD)
1. The Universal Decomposition
Unlike eigendecomposition, which requires a square matrix, SVD works for any matrix : Where:
- (): Left singular vectors (orthogonal).
- (): Diagonal matrix containing singular values (sorted by magnitude).
- (): Right singular vectors (orthogonal).
2. Truncated SVD for Compression
By keeping only the top singular values, we create the best -rank approximation of . This is the foundation for:
- Data Compression: Representing a large dataset with fewer numbers.
- Latent Semantic Analysis (LSA): Finding hidden topics in a set of documents.
- Image Compression: Keeping only the most important features of an image.
import numpy as np
# A random 5x3 matrix
A = np.random.randn(5, 3)
# Perform SVD
U, s, Vt = np.linalg.svd(A)
print(f"U shape: {U.shape}, s shape: {s.shape}, Vt shape: {Vt.shape}")🟡 Level 2: Latent Factor Models
3. Collaborative Filtering ()
In recommendation systems (like Netflix), we decompose a user-item rating matrix into two lower-rank matrices:
- : User features (preferences).
- : Item features (characteristics). Predicted rating: .
4. Non-Negative Matrix Factorization (NMF)
A variation where all elements in the decomposed matrices must be non-negative. This is particularly useful for topic modeling and image processing, where negative values are physically meaningless.
🔴 Level 3: Tensor Calculus and Spectral Methods
5. Tensor Decompositions (CP and Tucker)
Tensors are multi-dimensional arrays (3D, 4D, etc.). Tensor decompositions generalize SVD to higher dimensions:
- CP Decomposition: Decomposes a tensor into a sum of rank-1 tensors.
- Tucker Decomposition: Factoring a tensor into a core tensor and factor matrices for each mode.
6. Spectral Methods and Graph Laplacians
Uses the eigenvalues and eigenvectors of the Graph Laplacian to find clusters in a network. This is the core of Spectral Clustering, which can identify complex, non-linear patterns in data.