MST0052 · Lecture 9 · Fall 2026
01
(X, y) — minimise error against y.
X only. No observed target; the method defines its objective.
Compress many correlated columns into few informative ones — today.
Group rows using a chosen similarity measure, without supplied group labels — Lecture 13.
200 questions — maybe 5 underlying attitudes.
No segments defined — yet.
Most pixels move together.
The L1 rule · support, not headline
02
Without the constraint, doubling $w$ quadruples the "variance" — scale must be pinned.
Derivation · step 1 of 2
Derivation · step 2 of 2
03
The pattern · L7 machinery, new step
PCA learns its rotation from the data — inside a Pipeline it is refit on each CV fold. No leakage.
Pipeline
2 or 3 — human eyes are the constraint.
PCA(n_components=0.9) keeps just enough for 90%.
PCA(n_components=0.9)
The downstream CV score decides — L7's rule.
04
Pitfall 1 · Curved structure
Linear combinations — straight directions through the cloud.
Curves, rings, manifolds — distorted or hidden.
Pitfall 2 · Interpreting components
Calling PC1 a "size" axis is defensible.
A name is not supported by the loadings. Call it PC1.
Pitfall 3 · The most costly in projects
Before you reach for PCA
TruncatedSVD
05
load_digits() · 8×8 images · 80/20 stratified · random_state=42
Step 1 · Fit PCA, read the cumsum
Step 1 · Under the hood
Step 2 · Project to 2D
Step 3 · Let CV choose n_components
n_components is a hyperparameter like any other — L7's machinery, unchanged.
n_components
Step 4 · Read the numbers
06
The derivation · drawn
The SVD view
Fine print · the spectral theorem
One matrix · three lectures
Ridge barely shrinks directions whose eigenvalues of XᵀX are much larger than α.
Pitfall 3 and feature weighting · in the objective
The objective never mentions y. Nothing stops the predictive direction from being component 40.
Variance has units. Large raw spreads can dominate; standardisation gives nonconstant features equal variance.
Beyond linear · introduced here for visualisation
Beyond linear · the kernel trick
Sparse data · TF-IDF
Option · PCA(whiten=True)
Pitfall 3 · the construction
Diagnostic · reconstruction error
Reconstruction · the same answer from the other side