LA 101
M10 · Lab
Hands-on lab
Keep the few directions your data actually uses

Reduce a matrix to a handful of principal components in the sandbox, and predict — before the screen tells you — how much variance the top k PCs explain, the smallest k that keeps 95% of the variance, and the dimensionality-reduction ratio that buys.

The explained-variance ratio
\mathrm{EVR}(k) = \frac{\sum_{i\le k}\sigma_i^2}{\sum_i \sigma_i^2}

Principal-component analysis rotates the axes to line up with the directions your data varies in most. Each singular value squared σi2 is the variance along one PC, so the explained-variance ratio EVR(k) = (Σi≤k σi2) / (Σi σi2) says how much of the total variance the top k components keep. The usual rule keeps the smallest k reaching a threshold — k* = min{k : EVR(k) ≥ 0.95} — and everything past it is dropped.

1 / 7
LA 101
M10 · Lab
Set it up
One threshold

Open the sandbox. Choose the image “Sharp geometry” and leave the defaults (size 64×64, no noise, seed 1). Each step names the number of components k to set; read the “energy kept” readout — that is the explained-variance ratio EVR(k).

Set these values
Image = Sharp geometry size = 64x64 noise = 0 seed = 1 Read: energy kept at k smallest k for 95% ratio n / k

The “energy kept” percentage is the explained-variance ratio, and the numerical rank tells you how many components are non-zero at all — every number you predict is on screen.

2 / 7
LA 101
M10 · Lab
Step 1 of 3
Variance concentrates in the top PCs

Set k = 5 and read the “energy kept” readout — the explained-variance ratio EVR(5). This image has 40 non-zero components; predict whether the top 5 already explain most of the variance.

Expected

The top 5 PCs explain 0.9764 of the total variance — over 97% — even though 40 components are non-zero. Variance concentrates in the leading directions, which is the whole reason PCA works.

3 / 7
LA 101
M10 · Lab
Step 2 of 3
How many PCs reach 95%

The usual PCA rule keeps just enough components to retain 95% of the variance: k* = min{k : EVR(k) ≥ 0.95}. Step k up from 1 and watch “energy kept” cross the threshold. Predict the smallest k that reaches 95%.

Expected

Just 3 PCs reach 95% (EVR = 0.9549), and only 2 reach 90% (EVR = 0.9165). You drop 61 of the 64 directions and still keep 95% of the variance.

4 / 7
LA 101
M10 · Lab
Step 3 of 3
The dimensionality-reduction ratio

Keeping k* = 3 of the 64 dimensions is a reduction ratio n / k* = 64 / 3. Predict that ratio — how many times smaller the representation is while it still holds 95% of the variance.

Expected

The ratio is 64 / 3 = 21.33× — three principal components stand in for 64 original dimensions while keeping 95% of the variance. Relax the threshold to 90% (k = 2) and it climbs to 32×. That is the payoff PCA exists for.

5 / 7
LA 101
M10 · Lab
Your turn
Open the sandbox

Everything above is waiting in the sandbox. Pick any image, drag the size and the number of components k, and watch the explained-variance ratio, the numerical rank and the reconstruction all update at once — a low k is a projection onto the top PCs.

6 / 7
LA 101
M10 · Lab
Wrap-up
What you did
  • Read the explained-variance ratio: the top 5 PCs hold 0.9764 of the variance
  • Found the smallest k for a threshold — 3 for 95%, 2 for 90%
  • Turned that into a dimensionality-reduction ratio 64 / 3 = 21.33× at 95%
  • Every value you predicted is the demo's own explained-variance arithmetic, not a picture
7 / 7