Compute SVD and low-rank approximations in NumPy
8 steps · about 2 h 30 min · Beginner
- Understand the three-matrix factorization (reference, Wikipedia, 20 min)
Introduces U, Sigma and V^T as rotation, scaling and rotation so the geometry is clear before coding.
- See how SVD decomposes a linear map (article, Gregory Gundersen, 20 min)
Visualizes how any rectangular matrix stretches orthogonal directions into orthogonal outputs.
- Walk through a small worked example (tutorial, Hadrien Jean, 25 min)
Connects matrix notation to concrete NumPy arrays and shows how the factors multiply back.
- Call numpy.linalg.svd with full_matrices=False (reference, NumPy, 15 min)
Clarifies reduced versus full SVD shapes and how singular values are returned in descending order.
- Truncate small singular values for compression (reference, Wikipedia, 20 min)
Explains why keeping the top k singular triplets gives the closest rank-k matrix in Frobenius norm.
- Compare SciPy SVD options and checks (reference, SciPy, 15 min)
Shows LAPACK driver choices and finite-input checks when working with larger numerical matrices.
- Connect SVD to the Moore-Penrose pseudoinverse (reference, NumPy, 15 min)
Demonstrates how inverting nonzero singular values solves ill-conditioned least-squares systems.
- Scale low-rank projection to sparse text matrices (reference, scikit-learn, 20 min)
Applies randomized truncated SVD to high-dimensional sparse data where full factorization is too costly.