Summary
SVD identifies input directions, output directions, and nonnegative scaling factors for any real matrix. PCA applies that decomposition to centered observations, retaining directions that minimize Euclidean squared reconstruction error. Large retained variance does not guarantee retained label information.
The decomposition
has . Full factors have orthogonal , orthogonal , and rectangular diagonal .
- The first columns of span the row space; remaining columns span the nullspace.
- The first columns of span the column space; remaining columns span the left nullspace.
- Singular values satisfy ; rank counts strictly positive values in exact arithmetic.
The orthogonal factors can include reflections, not just rotations. For an invertible square map, the spectral condition number is . Null directions prevent unrestricted inversion; describes conditioning only on the retained nonzero subspace.
Truncated SVD and low-rank approximation
For rank at most , a best approximation in Frobenius or spectral norm is
Keep the leading singular values and their corresponding directions. Orthogonal changes of basis preserve these norms, reducing the error calculation to discarded diagonal entries:
Take omitted singular values as zero when none remain. This is the Eckart–Young result; a low-rank model constraint does not automatically prescribe truncating an unrelated matrix.
PCA as SVD
For observations in rows, fit a training mean and center .
- Decompose .
- Use leading columns as feature-space principal directions.
- Compute scores and reconstruct .
- Component sample variance is .
The covariance is ; its eigenvectors are these same principal directions. Direct SVD avoids explicitly forming a Gram matrix, which squares the nonzero singular-value condition ratio.
For an exact numerical companion to the schematic, use rows . They are centered, and , giving singular values and . Rank-one scores are ; reconstruct each second coordinate as zero. Four unit residuals give squared error , while retained variance is .
Keep the coordinate along PC1; discard the perpendicular reconstruction error
Derivation
Does the perpendicular displacement remain in the rank-one reconstruction?
Change the Requirement
Retain Ninety Percent of Variance
New task: Choose the smallest rank retaining at least of total squared singular-value mass.
Picture and change: Accumulate in descending order; change scores and reconstruction dimensions together.
Check: The fixture’s first component retains only ; rank two retains and reconstructs exactly.
Use when: A declared reconstruction requirement determines storage or representation size.
Standardize the Features
New task: Give both features equal sample variance before fitting PCA.
Picture and change: Divide centered columns by their training sample standard deviations, changing the feature-space metric.
Check: Fixture covariance becomes ; every unit direction is a possible first component, retaining .
Use when: Units or domain priorities justify equalized feature weighting. Carry the fitted mean, scales, and directions into inference; refitting on test data changes the transformation.
Common pitfalls
- Different objective. Uncentered SVD includes the mean’s contribution; its leading direction need not equal the mean direction.
- Automatic scaling. Standardization changes the objective and is undefined for zero-variance columns without a policy.
- Whitening confusion. PCA scores are uncorrelated, not generally unit variance. Dividing by positive component standard deviations whitens them; zero singular values need exclusion or regularization.
- Direction ambiguity. Singular-vector signs and tied-eigenvalue bases can vary without changing the reconstructed subspace.
- Data geometry. Centering sparse matrices can destroy sparsity; categorical data need a justified metric.
Reconstruct
What if the label is the sign of the second feature?
The rank-one fixture discards that feature completely despite retaining eighty percent of variance. Unsupervised reconstruction quality is not a guarantee of predictive sufficiency.
Related
- Matrices as linear maps. The geometry.
- Eigenvalues and the spectral theorem. For symmetric matrices.