How do you derive PCA as finding the direction of maximum variance?
Unsupervised learning, Principal component analysis
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can set up a constrained optimisation with a Lagrange multiplier and recognise an eigenvalue problem.
Key idea
Maximise subject to , where is the direction and is the covariance matrix of the centred data. The Lagrangian gives , and the variance captured is , so take the eigenvector with the largest eigenvalue.
Steps
- Centre the data (subtract the mean) and define .
- The variance of the projections onto a unit vector is .
- Form , where is the Lagrange multiplier. Set its gradient to zero to get .
- Then , so choose the eigenvector with the largest eigenvalue.
- For components, repeat with orthogonality constraints (or use the SVD of the data matrix ). Mention the equivalent view that PCA minimises the reconstruction error.
Common mistakes
- Forgetting to centre the data.
- Dropping the unit-norm constraint, which leaves the objective unbounded.
- Not standardising features measured on very different scales before interpreting the components.
How long your answer should be
About 5 minutes; half a page.
Last checked on 4 December 2026.
Read this
Previous in Unsupervised learning: Six points on a line are 1, 2, 3, 10, 11 and 12. Using a flat kernel of radius 2.5 (all points within distance 2.5 get equal weight), run mean shift by hand from the starting positions and . Where does each run stop, and what do you learn about the number of clusters?
Next in Unsupervised learning: A data matrix has one feature per column. Its covariance matrix decomposes as with and . (a) What is the shape of ? (b) What steps compute from , and what is explicitly? (c) To what dimension would you reduce the data with PCA, onto which direction, and why?