Skip to content

Singular Value Decomposition (SVD)

The Singular Value Decomposition (SVD) is one of the most powerful tools in linear algebra. It is widely used in machine learning for dimensionality reduction, noise reduction, recommendation systems, and data compression.


Any real matrix ARm×nA \in \mathbb{R}^{m \times n} can be decomposed as:

A=UΣVTA = U \Sigma V^T
  • URm×mU \in \mathbb{R}^{m \times m}: orthogonal matrix (left singular vectors).
  • ΣRm×n\Sigma \in \mathbb{R}^{m \times n}: diagonal matrix with non-negative values (singular values).
  • VRn×nV \in \mathbb{R}^{n \times n}: orthogonal matrix (right singular vectors).

::: info Explanation of SVD

  • Singular values represent the importance (variance captured) of each dimension.
  • UU gives the directions in the original space.
  • VV gives the directions in feature space.
  • Truncating Σ\Sigma gives low-rank approximations of AA.
    :::

Let:

A=[100100]A = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 0 & 0 \end{bmatrix}

Performing SVD:

  • UU contains orthonormal basis vectors in row space.
  • Σ\Sigma has singular values [1,1][1, 1].
  • VV contains orthonormal basis vectors in column space.

  • PCA: PCA is essentially SVD on the centered data matrix.
  • Latent Semantic Analysis (LSA): Uses SVD in NLP for dimensionality reduction.
  • Recommendation Systems: Matrix factorization with SVD finds latent features of users and items.
  • Noise Reduction: Keep only top kk singular values to approximate data.

::: code-group

import numpy as np
A = np.array([[1, 0], [0, 1], [0, 0]])
# Perform SVD
U, S, Vt = np.linalg.svd(A)
print("U =\n", U)
print("Singular values =", S)
print("V^T =\n", Vt)
use ndarray::array;
use ndarray::Array2;
use ndarray_linalg::SVD;
fn main() {
let a: Array2<f64> = array![
[1.0, 0.0],
[0.0, 1.0],
[0.0, 0.0]
];
// Perform SVD
let (u, s, vt) = a.svd(true, true).unwrap();
println!("U = {:?}", u.unwrap());
println!("Singular values = {:?}", s);
println!("V^T = {:?}", vt.unwrap());
}

:::


  • Data compression → keep only top singular values.
  • Noise filtering → discard small singular values.
  • Feature extraction → reduced representations (PCA, LSA).

Continue to Positive Semi-Definite Matrices and Covariance.