Problem Setting
Chapter 9 fitted a function to labelled data. Chapter 10 has no labels at all — only , and a request: “find projections of data points that are as similar to the original data points as possible, but which have a significantly lower intrinsic dimensionality.”
This page is §10.1: three equations, one worked example, and a phrase in Equation 10.1’s preamble that decides whether any of it works.
What you’ll learn
Section titled “What you’ll learn”- Equations 10.1–10.3: the data covariance matrix, the code , and the projection matrix .
- The four words “with mean ” attached to Equation 10.1 — and what breaks without them. Measured on images of the digit “8”: the leading direction moves , landing from the mean image, which says nothing about how the digits differ.
- Why and are different objects. The first is exactly; the second is with — §10.3 will call it “the best rank- approximation of the identity”.
- Example 10.1, run three ways: the same budget gives reconstruction errors , and . Choosing is the entire rest of the chapter.
- The book’s own notation warning: data points are the columns of here, not the rows. Every matrix shape in Chapter 10 depends on it.
- What “overcomplete” measures out to: rank of , pixels with exactly zero variance, and of pixel pairs correlated above .
Intuition: a bottleneck you choose the shape of
Section titled “Intuition: a bottleneck you choose the shape of”Compression is a promise about what you are allowed to forget. Figure 10.2 draws it as a funnel: goes in, a code comes out the narrow part, and a reconstruction comes out the far side. The reconstruction has numbers in it again — but only of them are free.
Two decisions live in that picture and they are not the same decision:
How narrow is the neck? That is , and it is yours to pick. It fixes the storage bill and nothing else.
Which directions survive it? That is , and §10.1 does not answer it. It only says the columns are orthonormal. Example 10.1 below shows two bases with the identical budget producing errors of and on the same vector — and a third reaching . §10.2 and §10.3 are two derivations of the same answer to this second question.
flowchart LR X["x in R^D
original"] -->|"encoder B'"| Z["z in R^M
code"] Z -->|"decoder B"| XT["x~ = BB'x in R^D
reconstructed"] X -.->|"the error we pay"| XT Z --> S1["10.1 fixes M
and says B'B = I"] XT --> S2["10.2 maximise the variance kept
10.3 minimise the error paid
same B"]
§10.1 The three equations
Section titled “§10.1 The three equations”The dataset is i.i.d., with , with mean , and it “possesses the data covariance matrix”
There is assumed to exist a low-dimensional compressed representation (code)
with the projection matrix
whose columns are orthonormal: for and . The projected data are , living in a subspace with .
| symbol | shape | what it is |
|---|---|---|
| one data point | ||
| all of them, as columns | ||
| Equation 10.1 | ||
| Equation 10.3, orthonormal columns | ||
| the code, Equation 10.2 | ||
| exactly | ||
| a projection, rank |
The four words that carry the weight
Section titled “The four words that carry the weight”Equation 10.1 is introduced as “the data covariance matrix”. It is one only because of the clause before it: “with mean ”. Written out, is the matrix of second moments, and the covariance is
The two agree exactly when and not otherwise. §10.6 will list centring as “Step 1” and call it “not strictly necessary but reduces the risk of numerical problems” — which understates it. Measured on the running dataset:
| quantity | value |
|---|---|
| of the raw images | |
| and that gap is , to | |
| — the total variance | |
| , a factor of |
The trace is what §10.2 is about to start maximising, so inflating it by is not a rounding concern. Where it actually lands:
| angle between | degrees |
|---|---|
| centred and the mean image | |
| uncentred and the mean image | |
| centred and uncentred |
Example 10.1, and the question §10.1 does not answer
Section titled “Example 10.1, and the question §10.1 does not answer”The book’s example is deliberately plain: in with the canonical basis, , while any vector of the form needs only the single coordinate with respect to . The set of such vectors is a subspace with , because .
Run it as a compression problem instead, on the vector itself, with throughout:
| basis | code | ||
|---|---|---|---|
The bottleneck, on a real image
Section titled “The bottleneck, on a real image”The book’s running example is MNIST: handwritten digits at pixels, so
. The pages here use the version of the same corpus that
ships inside scikit-learn, which needs no download and reproduces to the digit — , and
images of the digit “8”. Everything on this page scales; only the numbers change.
The storage arithmetic is worth doing once, because it is the only reason to compress at all. Keeping the codes and the basis costs numbers against raw:
| rank of | numbers stored | share of | |
|---|---|---|---|
Two matrices that are easy to confuse
Section titled “Two matrices that are easy to confuse”and are built from the same matrix and are nothing alike.
The first is the orthonormality assumption restated. The second is the projection onto — §10.3 arrives at it as Equation 10.39 and notes it is “the best rank- approximation of the identity matrix”. Measured, using the same tests page 909 ran on the linear-regression hat matrix:
The trace of a projection is its rank, which is the same fact page 909 used to explain Equation 9.22’s bias. Chapter 10 will use it again in Equation 10.43b.
What “overcomplete” actually measures
Section titled “What “overcomplete” actually measures”The chapter’s opening claim is that high-dimensional data “is often overcomplete, i.e., many dimensions are redundant and can be explained by a combination of other dimensions”, and that dimensions “are often correlated so that the data possesses an intrinsic lower-dimensional structure.” On the digit-”8” images:
| claim | measurement |
|---|---|
| dimensions are redundant | the centred matrix has rank , not |
| some carry nothing at all | pixels have exactly zero variance; have variance below |
| dimensions are correlated | mean between live pixels |
| strongly, in places | of pixel pairs exceed |
Twelve dead pixels is a free dimensionality reduction that needs no eigendecomposition: they are the image border, always black in every “8”. The other lost ranks are the interesting part — no single pixel is redundant, but the live directions span everything.
-
Equation 10.1 defines S as the average of x x-transpose. When is that the data covariance matrix?
Measured on 174 images of the digit 8: the gap between the raw second-moment matrix and the true covariance matches mu mu-transpose to 5.7e-14, the trace is inflated by a factor of 5.4245, and the leading direction rotates 87.9996 degrees onto the mean image itself — 0.2851 degrees from it.
pch.quizShowAnswer
B — Only when the data has mean zero; otherwise it exceeds the covariance by mu mu-transpose — Measured on 174 images of the digit 8: the gap between the raw second-moment matrix and the true covariance matches mu mu-transpose to 5.7e-14, the trace is inflated by a factor of 5.4245, and the leading direction rotates 87.9996 degrees onto the mean image itself — 0.2851 degrees from it.
-
B is D-by-M with orthonormal columns. What is B-transpose times B, and what is B times B-transpose?
Measured at M = 1, 2, 5 and 10: B-transpose B matches the identity to 1.3e-15 at worst, while B B-transpose is exactly symmetric, idempotent to 4.2e-16, and has trace exactly M. The trace of a projection is its rank — the same fact page 909 used on the regression hat matrix.
pch.quizShowAnswer
B — B-transpose B is the M-by-M identity; B B-transpose is D-by-D with rank M and trace M — Measured at M = 1, 2, 5 and 10: B-transpose B matches the identity to 1.3e-15 at worst, while B B-transpose is exactly symmetric, idempotent to 4.2e-16, and has trace exactly M. The trace of a projection is its rank — the same fact page 909 used on the regression hat matrix.
-
Section 10.1 fixes M and requires orthonormal columns. What does it NOT do?
Example 10.1 run as a compression problem: the vector [5, 3] with M = 1 gives reconstruction errors 5.000000 with b = e2, 3.000000 with b = e1, and 0.000000 with b along x itself. Same budget, same orthonormality, three answers. Sections 10.2 and 10.3 are two derivations of the same choice.
pch.quizShowAnswer
B — It does not choose the basis — nothing in Section 10.1 prefers one orthonormal B over another — Example 10.1 run as a compression problem: the vector [5, 3] with M = 1 gives reconstruction errors 5.000000 with b = e2, 3.000000 with b = e1, and 0.000000 with b along x itself. Same budget, same orthonormality, three answers. Sections 10.2 and 10.3 are two derivations of the same choice.
-
For the 174 digit-8 images with D = 64, at what M does storing codes plus basis stop saving anything?
M(N + D) < N*D fails at M >= 11136/238 = 46.79. The basis is a fixed cost paid once, so it only disappears when N is large — with 60,000 MNIST images it is negligible and the ratio is essentially M/D. When N is comparable to D it is not, which is the regime Section 10.5 addresses.
pch.quizShowAnswer
B — M = 47, because the basis costs D*M numbers on top of the N*M codes — M(N + D) < N*D fails at M >= 11136/238 = 46.79. The basis is a fixed cost paid once, so it only disappears when N is large — with 60,000 MNIST images it is negligible and the ratio is essentially M/D. When N is comparable to D it is not, which is the regime Section 10.5 addresses.
Exercises
Section titled “Exercises”Exercise 1 – Equation 10.1 is a covariance only if you centre
Section titled “Exercise 1 – Equation 10.1 is a covariance only if you centre”Exercise 2 – Where the uncentred direction actually points
Section titled “Exercise 2 – Where the uncentred direction actually points”Exercise 3 – Two matrices, two shapes, one projection
Section titled “Exercise 3 – Two matrices, two shapes, one projection”Exercise 4 – Example 10.1 as a compression problem
Section titled “Exercise 4 – Example 10.1 as a compression problem”Exercise 5 – When does compressing stop saving anything?
Section titled “Exercise 5 – When does compressing stop saving anything?”Recall card
Section titled “Recall card”- Chapter 10 has no labels. The data is just x, and the request is a projection of it that keeps most of what the original said while needing far fewer numbers.
- Equation 10.1’s S is the data covariance matrix only because the data is assumed to have mean zero. Applied to raw data it is the second-moment matrix, larger by the outer product of the mean with itself.
- Measured on 174 images of the digit eight, skipping the centring moves the leading direction by 87.9996 degrees, to within 0.2851 degrees of the mean image — a direction on which every point has nearly the same coordinate.
- It also inflates the total variance by a factor of 5.4245, and the total variance is exactly what Section 10.2 is about to maximise.
- The code is z = B-transpose x and the reconstruction is x-tilde = B B-transpose x. B is D by M with orthonormal columns.
- B-transpose B is the M by M identity; B B-transpose is D by D with rank M. They are built from the same matrix and are not the same object.
- The trace of B B-transpose is exactly M, measured at M equal to 1, 2, 5 and 10. The trace of a projection is its rank, which is the same fact page 909 used on the regression hat matrix.
- Section 10.1 fixes the code length and requires orthonormality, and chooses nothing else. Example 10.1’s vector with M equal to one gives errors of 5, 3 and 0 under three different orthonormal bases.
- Chapter 10 stores data points as the columns of X, not the rows, so X is D by N and every shape in the chapter follows from that.
- Storage costs M times N plus D, against N times D raw. With 174 images and 64 pixels, a code of length 47 already saves nothing, because the basis is a fixed cost paid once.
- Overcomplete, measured: the 64 by 174 centred matrix has rank 52, twelve pixels have exactly zero variance, and 57 of 1326 pixel pairs are correlated above one half.
Next: The Maximum Variance Perspective — the first of two derivations that answer the question §10.1 leaves open, by asking which direction keeps the most variance.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading