Singular value decomposition (SVD) factors a matrix into a sum of simple patterns, ordered by strength. Keep fewer patterns and you get an approximation of the original measurements. You do not get a generative model: SVD alone provides no probability distribution or rule for sampling new observations.
What do the three factors tell you?
For a real matrix A with m rows and n columns, write A = UΣVᵀ. In the reduced form, with q = min(m, n), U has shape m × q, Σ is q × q, and Vᵀ is q × n. Each column of V gives a direction in feature space; the corresponding column of U tells how that pattern is distributed across rows. The singular value on the diagonal of Σ scales the pattern. The columns of U and of V are orthonormal within each matrix.

Each pair of singular vectors contributes one outer product, weighted by its singular value. Count the positive singular values for the exact rank; with floating-point data, use a tolerance rather than testing for exact zero. Keeping only the k largest values gives the closest matrix of rank at most k in Frobenius norm (the square root of the sum of squared entrywise errors).
A rank-one reconstruction you can check by hand
Imagine two sensors measuring two samples. Their readings are [3, 1] for the first sample and [1, 3] for the second. Both rows have a common level of 2, but the sensors disagree in opposite directions. Which pattern survives if we keep just one component?
The singular values are 4 and 2. The leading direction is proportional to [1, 1]. Its rank-one contribution is a matrix with 2 in every cell. Subtract it from the original and the residual rows are [1, −1] and [−1, 1]. The Frobenius error is √(1 + 1 + 1 + 1) = 2, equal to the discarded singular value. The reconstruction retains 4²/(4² + 2²) = 80% of the squared matrix norm, yet loses the difference between the two samples entirely.
import numpy as np
A = np.array([[3., 1.], [1., 3.]])
u, s, vt = np.linalg.svd(A, full_matrices=False)
A1 = (u[:, :1] * s[:1]) @ vt[:1, :]
error = np.linalg.norm(A - A1, 'fro')
share = s[0]**2 / (s @ s)
print(s, A1, error, share)NumPy returns Vᵀ as vt. Keeping its first row and the first column of u selects a matched pair. A solver can flip both vector signs without changing their outer product, so check the reconstructed entries rather than a particular sign convention.
Why centering changes the answer in PCA
For principal component analysis (PCA), put observations in rows and subtract each column’s mean. Here both column means are 2, so the centered matrix is exactly the residual above. Its only nonzero direction is proportional to [1, −1]: one centered component captures all the variation. Add the means back after reconstruction and you recover the original readings. The 80% figure for uncentered SVD was not 80% of the variance.
In general, the right singular vectors of the centered matrix are the principal axes; UΣ contains the scores. With m observation rows (m > 1), the sample variance along each principal axis is its squared singular value divided by m − 1. Centering does not equalize units: changing meters to millimeters can change the leading direction. Decide whether to scale each feature, and fit any means and scales on the training set only.
When is truncation useful?
A grayscale image can be treated as a matrix of pixel intensities. Keeping a few components can preserve broad shapes while losing fine edges. A small reconstruction error does not guarantee that a faint but important detail survives. Choose the rank against the available storage and the detail your task needs, not a universal energy cutoff.
References and further reading
The NumPy SVD reference documents the returned factors and their shapes. The scikit-learn PCA reference explains centering, scaling, and explained variance.
As an Amazon Associate, we earn from qualifying purchases.
For a practical treatment of dimensionality reduction, see Aurélien Géron’s Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow (Amazon US).
𝓑𝓎: 𝓜𝓸𝒽𝒶𝓃𝒶𝒹 𝒜𝒷𝓊𝓀𝓂𝓮𝒾𝓁 𝒫𝒽.𝒟. 𝓮𝓍𝒸𝓮𝓇𝓅𝓉𝓈



