Compute SVD and low-rank approximations in NumPy

8 steps · about 2 h 30 min · Beginner

  1. 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.

  2. See how SVD decomposes a linear map (article, Gregory Gundersen, 20 min)

    Visualizes how any rectangular matrix stretches orthogonal directions into orthogonal outputs.

  3. 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.

  4. 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.

  5. 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.

  6. Compare SciPy SVD options and checks (reference, SciPy, 15 min)

    Shows LAPACK driver choices and finite-input checks when working with larger numerical matrices.

  7. Connect SVD to the Moore-Penrose pseudoinverse (reference, NumPy, 15 min)

    Demonstrates how inverting nonzero singular values solves ill-conditioned least-squares systems.

  8. 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.