Skip to content

Dimensionality Reduction Overview

Chapter 9 fitted a function to labelled data. Chapter 10 has no labels — only x\mathbf{x}, and the second of the book’s four pillars: “dimensionality reduction exploits structure and correlation and allows us to work with a more compact representation of the data, ideally without losing information.”

PCA is over a hundred years old, and the chapter derives it twice.

§10.2 maximum variance§10.3 projection
what you maximise or minimisethe variance you keepthe error you pay
the objectivetr(BBS)\mathrm{tr}(\mathbf{B}\mathbf{B}^\top\mathbf{S})tr(BBS)\mathrm{tr}(\mathbf{B}_\perp\mathbf{B}_\perp^\top\mathbf{S})
at the optimummMλm\sum_{m\le M}\lambda_mj>Mλj\sum_{j>M}\lambda_j
the answerthe top MM eigenvectorsthe top MM eigenvectors

They are not two methods that happen to agree. VM+JM=tr(S)V_M + J_M = \mathrm{tr}(\mathbf{S}) for every MM and every orthonormal B\mathbf{B} — measured constant to 2.3×10132.3\times10^{-13} against a trace of 741.158872741.158872. One quantity, read from either end of a fixed total. That is why the book can write “we omit a derivation that is identical to the one presented in Section 10.2” and lose nothing.

Everything in this chapter has a closed form, so every claim can be checked exactly. Five that turned up something:

The four words “with mean 0\mathbf{0} carry Equation 10.1. Applied to raw data it is the second-moment matrix, not the covariance. Measured on 174174 images of the digit “8”: the trace inflates by 5.42455.4245 and the leading direction swings 87.999687.9996^\circ — landing 0.28510.2851^\circ from the mean image, a direction on which every data point has nearly the same coordinate.

§10.5 contains an off-by-one that centred data contradicts. The book says the Gram matrix “has rank NN and is invertible”. For the centred data it assumes in its own first sentence, the rank is N1N-1 and the condition number is 4.15×10174.15\times10^{17} — the all-ones vector sits in the null space. The adjacent claim of DN+1D-N+1 zero eigenvalues is the correct one.

Held-out reconstruction error cannot choose MM. Chapter 9’s test RMSE rose past the right degree, which is what made it usable. This one falls monotonically to zero, because a larger subspace can never project a point further away — on any data. Four defensible rules applied to the same spectrum give M=1M = 1, 1818, 2525 and 3838.

Equation 10.32 is not a general formula for coordinates. It is what Equation 10.34’s (BB)1(\mathbf{B}^\top\mathbf{B})^{-1} collapses to when the columns are orthonormal. Applied to a basis spanning the identical subspace but rescaled, the reconstruction error goes from 16.31627216.316272 to 24.72840924.728409, with nothing raised.

Standardising is a modelling decision, not tidiness. Changing height from metres to millimetres rotates the leading direction 77.398277.3982^\circ on data that never moved. After Step 2 the three unit choices agree to 1.2×1061.2\times10^{-6} degrees — and the standardised covariance is the correlation matrix, with trace exactly DD.

#pagebook sectionthe measured claim
1001Problem Setting§10.1skip the centring and b1\mathbf{b}_1 moves 87.999687.9996^\circ
1002The Maximum Variance Perspective§10.2V1=λ1V_1 = \lambda_1 to 8.5×10148.5\times10^{-14}; random search reaches 37.18%37.18\%
1003The Projection Perspective§10.3.1–10.3.2the residual is 100%100\% in UU^\perp, to twelve decimals
1004Finding the Principal Subspace§10.3.3200,000200{,}000 random bases, zero beat the eigenbasis
1005Eigenvector Computation and Low-Rank Approximations§10.4eigh returns 1818 negative eigenvalues at κ=1010\kappa = 10^{10}
1006PCA in High Dimensions§10.54565×4565\times faster at D=4000D = 4000, and the book is off by one
1007Key Steps of PCA in Practice§10.6a unit change costs 77.398277.3982^\circ; the leak makes it look better
1008The Latent Variable Perspective§10.7C=σ2Λ1\mathbf{C} = \sigma^2\boldsymbol\Lambda^{-1}, and it never sees the data
1009Chapter 10 Worked Problemseight problems, this module’s own
1010Chapter 10 Formula Sheetevery equation and every measured constant

One number appears on four pages by four routes, and noticing that is most of understanding the chapter:

where it appearspagevalue
j>5λj\sum_{j>5}\lambda_j, Equation 10.441002320.123369320.123369
the measured reconstruction error, Equation 10.291002320.123369320.123369
tr(BBS)\mathrm{tr}(\mathbf{B}_\perp\mathbf{B}_\perp^\top\mathbf{S}), Equation 10.43b1004320.123369320.123369
XX~5F2/N\lVert\mathbf{X}-\tilde{\mathbf{X}}_5\rVert_F^2/N, Eckart–Young1005320.123369320.123369

It is J5J_5, the price of a five-number code. §10.2 reached it without ever forming a projection, §10.3 by deriving it, §10.4 as a theorem about matrix approximation. Three literatures, one number.

§10.7 puts a generative model behind all of it — the same move §9.3 made for regression — and the payoff is measurable rather than rhetorical:

capabilitymeasured
fill in pixels never observed36.8%36.8\% better than mean-filling at 10%10\% missing
score noveltyevery digit “0” above the 88s’ 9595th percentile
a posterior whose width you know in advanceC=σ2Λ1\mathbf{C} = \sigma^2\boldsymbol\Lambda^{-1}, unchanged across 200200 observations
estimate the noise you are discardingσML2=JM/(DM)\sigma^2_{\mathrm{ML}} = J_M/(D-M), exact to 88 decimals

And it recovers everything before it: PPCA is PCA with shrinkage, each axis scaled by (λmσ2)/λm(\lambda_m-\sigma^2)/\lambda_m — measured to six decimals — converging to PCA as σ0\sigma\to0.

Two limits are worth carrying forward, because both are load-bearing for later chapters.

PCA finds the subspace, not the signals. The objective depends on BB\mathbf{B}\mathbf{B}^\top alone, so rotating B\mathbf{B} by any orthogonal R\mathbf{R} leaves the error at 320.123369320.123369 and the projector identical to 1.1×10161.1\times10^{-16} — while moving the codes by 39.24353739.243537 and destroying their uncorrelatedness (5.1×10145.1\times10^{-14} becomes 37.04685237.046852). That is Equation 10.78’s arbitrary R\mathbf{R}, and it is why independent component analysis exists.

PCA is linear, and some data is not. A noisy circle in R2\mathbb{R}^2 has one intrinsic degree of freedom and two nearly equal eigenvalues, 0.5010380.501038 and 0.4976060.497606; no line keeps more than 50.17%50.17\%. But §10.5’s N×NN\times N matrix is built entirely from inner products, and DD appears nowhere in it — so swapping the Gram matrix for a kernel matrix takes one line and separates two concentric rings from 0.05970.0597 to 7.52997.5299. Kernel PCA is this chapter with one substitution, and Chapter 12 makes the same one.

§10.8’s pointerand where it already appeared
kernel PCA — infinite-dimensional featurespage 1006 measured that DD never enters the N×NN\times N matrix; page 1009 ran it
deep auto-encoders — PCA is the identity-activation caseEquation 10.76, and page 1004’s rotation ambiguity
factor analysis — a different σd2\sigma^2_d per dimensionpage 1007’s 1212 zero-variance pixels are the degenerate case
ICA — a non-Gaussian prior on z\mathbf{z}page 1004’s R\mathbf{R}, measured to leave JMJ_M exactly unchanged
Bayesian PCA — integrate the parameters outChapter 9’s §9.3, and page 908’s marginal likelihood

And the remaining pillars: Chapter 11 applies the same machinery to density estimation, Chapter 12 to classification.

  • Chapter 10 has no labels. The data is just x, and the task is a compact representation of it that loses as little as possible.
  • The chapter derives PCA twice — by maximising the variance kept and by minimising the reconstruction error — and reaches the same eigenvectors both times.
  • That is not a coincidence: the variance kept and the error paid always sum to the trace of the covariance matrix, measured constant to 2.3e-13.
  • Equation 10.1 is a covariance only because the data is assumed centred. Skip that and the leading direction swings 87.9996 degrees onto the mean image itself.
  • One number, 320.123369, appears by four independent routes — the leftover eigenvalues, the measured error, a trace, and the Eckart-Young theorem.
  • Two hundred thousand random orthonormal bases, and not one beats the eigenbasis.
  • The objective sees only the projection matrix, so rotating the basis changes the codes by 39.243537 and the error by nothing. PCA finds the subspace, not the signals.
  • Held-out reconstruction error cannot choose the code length, because it falls monotonically to zero. Four defensible rules give four different answers.
  • Use the SVD of the data, not the eigendecomposition of the covariance, whenever the small eigenvalues matter — squaring the condition number returns 18 negative eigenvalues at 1e10.
  • When there are fewer points than dimensions, decompose the N-by-N Gram matrix instead — 4565 times faster at D equal to 4000.
  • And that matrix is built from inner products with no D in it, which is the whole of kernel PCA.
  • Standardising is a decision: a change of unit costs 77.3982 degrees without it, and it throws away real information with it.
  • Probabilistic PCA adds a generative story, which buys imputation, novelty scoring and a posterior covariance known before any data arrives — and recovers plain PCA as the noise-free limit.

Start here: Problem Setting

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading