The Projection Perspective
§10.2 asked what to keep. §10.3 asks what you pay:
In the following, we will derive PCA as an algorithm that directly minimizes the average reconstruction error. This perspective allows us to interpret PCA as implementing an optimal linear auto-encoder.
Page 1002 already measured the punchline — the reconstruction error came out as the leftover eigenvalues without anyone asking for it. This page is the first half of the derivation that explains why, and it has a structure worth noticing: the coordinates are settled before the basis is.
What you’ll learn
Section titled “What you’ll learn”- Equation 10.29’s objective , and the two-step plan: coordinates first, basis second.
- Equations 10.30–10.32: the derivative that produces . Checked against a -point grid search and against BFGS in dimensions — agreement to , with identical objective values to decimals.
- Why it is the minimum and not merely a stationary point, by an exact identity rather than a search: , verified over random to .
- Equation 10.34, and the thing it quietly assumes. Applying to a basis that spans the right subspace but is not orthonormal gives error where was available.
- Equation 10.38: the displacement lies entirely in — measured, of its squared norm, with never above across images.
- Why for : the coordinates of and of are the same numbers in the retained directions. Measured gap: exactly .
Intuition: two questions, and only one of them is hard
Section titled “Intuition: two questions, and only one of them is hard”Minimising looks like one optimisation over two unknowns — where the subspace sits, and where in it to land. It is not. Given any subspace, the best point in it is forced: drop a perpendicular. That is a fact about Euclidean geometry, true before you know anything about the data.
So the two unknowns separate cleanly. §10.3.2 disposes of the coordinates in half a page and hands a much smaller problem to §10.3.3: of all the -dimensional subspaces, which one has the shortest perpendiculars on average?
flowchart TD J["J_M = average of ||x_n - x~_n||^2
Equation 10.29"] J --> Q1["given a basis, which z?
Section 10.3.2"] J --> Q2["which basis?
Section 10.3.3"] Q1 --> A1["z_in = b_i' x_n
Equation 10.32 -- geometry, not data"] A1 --> R["J_M = trace of S on the
orthogonal complement
Equation 10.43b"] Q2 --> R R --> A2["the top M eigenvectors
Equation 10.44 -- same answer as 10.2"]
§10.3.1 The objective
Section titled “§10.3.1 The objective”Assume an ordered ONB of . Any splits along it:
The reconstruction is restricted to the first of them, in the principal subspace :
and the objective is the average squared Euclidean distance — the reconstruction error, due to Pearson (1901):
§10.3.2 The coordinates, settled by one derivative
Section titled “§10.3.2 The coordinates, settled by one derivative”By the chain rule, with
so that, using ,
Setting it to :
The book states the three consequences flatly, and they are worth keeping:
- The optimal linear projection of is an orthogonal projection.
- The coordinates of are the coordinates of the orthogonal projection of onto the principal subspace.
- An orthogonal projection is the best linear mapping given the objective (10.29).
The same check where there is no picture to appeal to — , , BFGS started from with a gradient tolerance of :
| value | |
|---|---|
| iterations | |
| at the optimiser’s answer | |
| at Equation 10.32 |
Where the orthonormality assumption is spent
Section titled “Where the orthonormality assumption is spent”Equation 10.33 recaps the general orthogonal projection from §3.8, and Equation 10.34 gives the -dimensional case:
The brace is doing real work. Take five columns spanning exactly the same subspace as — rescale them and add a multiple of one to another, so is off the identity by — and reconstruct one image three ways:
| coordinate rule | |
|---|---|
| , Equation 10.32 applied anyway | |
| , Equation 10.34 | |
| an orthonormal basis for the identical span |
Equation 10.38 and what a residual is made of
Section titled “Equation 10.38 and what a residual is made of”Writing in the full basis and splitting the sum at ,
so the displacement is exactly the second piece:
The displacement vector lies in the subspace that is orthogonal to the principal subspace.
And the coordinates agree where they overlap. For ‘s full coordinate vector and ‘s at :
| values | |
|---|---|
| difference | exactly |
| , the discarded tail | |
Projecting does not recompute the coordinates you keep — it deletes the ones you don’t. That is the sentence the book reaches at the top of §10.3.3, and it is what makes the whole thing a truncation rather than a re-fit.
Two forms of the objective, and where the next page starts
Section titled “Two forms of the objective, and where the next page starts”Equation 10.39 names as a symmetric rank- matrix, so
— “finding orthonormal basis vectors which minimize the difference between the original data and their projections is equivalent to finding the best rank- approximation of the identity matrix.”
Measured both ways, as a per-point sum and as one Frobenius norm:
Those are page 1002’s values, reached from the opposite direction. The next page finishes the job: it turns Equation 10.40b into a trace, and the trace into a statement about eigenvalues.
-
Why does Section 10.3 optimise the coordinates before the basis?
Equation 10.32 gives z = b-transpose x with no reference to which subspace was chosen. Verified by BFGS in 64 dimensions: eight iterations, agreeing with the closed form to 1.6e-06, identical objective values to eight decimals. That leaves Section 10.3.3 the genuinely hard half.
pch.quizShowAnswer
B — Because for ANY subspace the best point in it is forced — the orthogonal projection — so that half needs no knowledge of the data — Equation 10.32 gives z = b-transpose x with no reference to which subspace was chosen. Verified by BFGS in 64 dimensions: eight iterations, agreeing with the closed form to 1.6e-06, identical objective values to eight decimals. That leaves Section 10.3.3 the genuinely hard half.
-
Equation 10.32 sets a derivative to zero. What makes that a minimum rather than just a stationary point?
The cross term vanishes because the residual is orthogonal to the subspace, leaving ||x - Bz||^2 = ||x - BB'x||^2 + ||B'x - z||^2. Measured over 200,000 random z at scales from 0.1 to 1000, the worst relative gap was 1.7e-15. The second term is zero exactly at Equation 10.32 and positive everywhere else.
pch.quizShowAnswer
B — An exact identity: the objective splits into a term with no z in it plus the squared distance from z to B-transpose x — The cross term vanishes because the residual is orthogonal to the subspace, leaving ||x - Bz||^2 = ||x - BB'x||^2 + ||B'x - z||^2. Measured over 200,000 random z at scales from 0.1 to 1000, the worst relative gap was 1.7e-15. The second term is zero exactly at Equation 10.32 and positive everywhere else.
-
You have five columns spanning the right subspace, but they are not orthonormal. What does z = G-transpose x give you?
Equation 10.34 is B (B-transpose B)-inverse B-transpose x, and the inverse factor is the identity ONLY when the columns are orthonormal. Rescaling components by the square root of their eigenvalue is enough to break it, and there is no error message — the reconstruction is still in the subspace, just in the wrong place within it. np.linalg.qr fixes it.
pch.quizShowAnswer
B — A point in the right subspace, but not the closest one — measured at error 24.728409 against an available 16.316272 — Equation 10.34 is B (B-transpose B)-inverse B-transpose x, and the inverse factor is the identity ONLY when the columns are orthonormal. Rescaling components by the square root of their eigenvalue is enough to break it, and there is no error message — the reconstruction is still in the subspace, just in the wrong place within it. np.linalg.qr fixes it.
-
What does Equation 10.38 say about the displacement x minus x-tilde?
Measured across 174 images at M = 1, 2, 5, 10, 20 and 40: the largest component of any displacement inside U is 2.5e-14, and 100 percent of the squared error sits in the complement. That exact orthogonality is what kills the cross terms in Equations 10.42a and 10.42b, and it is why the coordinates you keep are untouched by the projection — the measured gap between zeta and z is exactly zero.
pch.quizShowAnswer
B — It lies entirely in the orthogonal complement of the principal subspace — Measured across 174 images at M = 1, 2, 5, 10, 20 and 40: the largest component of any displacement inside U is 2.5e-14, and 100 percent of the squared error sits in the complement. That exact orthogonality is what kills the cross terms in Equations 10.42a and 10.42b, and it is why the coordinates you keep are untouched by the projection — the measured gap between zeta and z is exactly zero.
Exercises
Section titled “Exercises”Exercise 1 – Search for the best coordinate, then stop searching
Section titled “Exercise 1 – Search for the best coordinate, then stop searching”Exercise 2 – Prove it is the minimum, without searching
Section titled “Exercise 2 – Prove it is the minimum, without searching”Exercise 3 – What Equation 10.34’s inverse is for
Section titled “Exercise 3 – What Equation 10.34’s inverse is for”Exercise 4 – The residual has no component you kept
Section titled “Exercise 4 – The residual has no component you kept”Exercise 5 – Projecting deletes coordinates, it does not recompute them
Section titled “Exercise 5 – Projecting deletes coordinates, it does not recompute them”Recall card
Section titled “Recall card”- Section 10.3 minimises the reconstruction error rather than maximising the variance, and reaches the same basis. The objective is Equation 10.29, the average squared distance between each point and its reconstruction.
- The problem splits into coordinates and basis, and only the second half is hard: for any subspace the best point in it is the orthogonal projection, which is geometry rather than a fact about the data.
- Equation 10.32 gives the optimal coordinate as b-transpose x. Checked against a hundred-thousand-point grid search and against BFGS in 64 dimensions, agreeing to about one part in a million with identical objective values.
- It is a minimum, not merely a stationary point, by an exact identity: the objective equals a term with no z in it plus the squared distance from z to B-transpose x. Verified to 1.7e-15 over 200,000 random z.
- Equation 10.34’s inverse factor is the identity only because the columns are orthonormal. Apply Equation 10.32 to a non-orthonormal basis spanning the same subspace and the error goes from 16.316272 to 24.728409, with no warning.
- Rescaling components by the square root of their eigenvalue is enough to break it. A QR factorisation restores the guarantee at negligible cost.
- Equation 10.38: the displacement lies entirely in the orthogonal complement. Measured across 174 images, the largest component inside the retained subspace is 2.5e-14, and the share of squared error in the complement is 1 to twelve decimals.
- Projecting deletes the coordinates you discard and leaves the ones you keep untouched — measured difference exactly zero. Compression here is truncation, not refitting.
- The squared error equals the sum of the squared discarded coordinates, 266.220741 for one image at M equal to five.
- Equation 10.40b rewrites the objective as the identity minus B B-transpose applied to the data, which makes finding the basis the same as finding the best rank-M approximation of the identity matrix.
Next: Finding the Principal Subspace — §10.3.3 turns Equation 10.40b into a trace and the trace into the leftover eigenvalues, meeting §10.2 from the far side.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading