What Is the Intuitive Relationship Between SVD and PCA?
At a glance
- 1. Center the data
Subtract each feature’s mean so the matrix describes variation around the data’s center.
- 2. Compute the SVD
Factor the centered matrix as UΣVᵀ; the columns of V are the principal directions.
- 3. Read the scores
Project the observations onto those directions: the scores are UΣ.
- 4. Measure the variation
Square the singular values to obtain variation along each direction, up to the covariance divisor.
PCA and the singular value decomposition (SVD) are closely connected, but they are not the same thing. PCA is a way to find directions that capture as much variation in a dataset as possible. SVD is a matrix factorization that, when applied to the appropriately prepared data matrix, gives those directions directly.
The key condition is that the data are usually centered first: subtract the mean of each feature from its observations. The explanation below uses observations in rows and features in columns; transposing the data changes which side of the SVD contains the principal directions.
The connection in one equation
Let be an matrix of centered data, with observations and features. Its SVD is
The columns of are directions in feature space. For centered data, these are the principal component directions. The singular values on the diagonal of tell you how much variation lies along each direction: their squares are proportional to the component variances.
The component scores—the coordinates of the observations in the new PCA directions—are
So, in practical terms, the right singular vectors give the PCA directions, and the left singular vectors multiplied by the singular values give the scores.
Why this works
The sample covariance matrix of centered data is
Substitute the SVD, using :
Thus, the columns of are eigenvectors of the covariance matrix, and the corresponding eigenvalues are , where is the corresponding singular value. Those eigenvectors are precisely the directions PCA chooses, ordered from greatest variance to least.
There is also a geometric way to see it. Pick a unit direction in feature space. Projecting every row of onto it gives the score vector . Its squared length is
PCA chooses the unit direction that makes this quantity as large as possible. The eigenvector with the largest eigenvalue of maximizes it; the SVD supplies that eigenvector as the first column of . PCA then finds the next direction subject to being perpendicular to the first, and continues.
A worked example
Consider three observations on two features:
Both columns already have mean zero. Their cross-product matrix is
The larger eigenvalue is , along the second feature axis; the other is , along the first. Accordingly, the singular values are and , and the right singular vectors are the two feature axes, ordered second feature first.
Projecting the data onto those directions gives scores
where the first score column corresponds to the second original feature. Using the sample covariance convention, the component variances are and . The first component therefore accounts for of the total variance, and the second accounts for .
What changes with scaling or conventions?
Dividing covariance by gives sample variances; dividing by gives population variances. This changes the numerical variance values by a common factor, but not the principal directions or the fractions of variance explained.
If features have very different units or scales, you may standardize each feature before PCA. That means PCA is then performed on the centered, scaled data (equivalently, a correlation-based analysis), so the SVD directions can differ from those obtained using unscaled data. Whether to scale depends on what differences between features are meaningful for your problem.
Common mistakes
- Applying SVD to uncentered data and calling it ordinary PCA. Without centering, the leading direction may reflect the data’s offset from zero rather than variation around its mean.
- Confusing singular values with variances. The variance along a component is proportional to , not . For sample covariance, it is .
- Assuming SVD and PCA are identical in every use. SVD factors any matrix; PCA is a statistical analysis with choices such as centering and scaling. SVD gives the PCA result when applied to the suitably prepared data matrix.
- Treating a component’s sign as meaningful. If a singular vector and its scores are both multiplied by , the same component is represented. The direction and its reverse describe the same axis.
- Expecting a unique direction when values are tied. If singular values are repeated, the individual directions within that tied subspace may not be unique, even though the subspace is.
In computation, SVD is often used to obtain PCA because it works directly on the data matrix and avoids explicitly forming the covariance matrix. The underlying relationship remains the same: covariance eigenvectors are right singular vectors, and covariance eigenvalues are squared singular values scaled by the variance convention.
References
- Principal Component Analysis: A Review and Recent Developments — Ian T. Jolliffe and Jorge Cadima
- Matrix Computations — Gene H. Golub and Charles F. Van Loan
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.