1. The goal and the set-up
Dimensionality reduction replaces features by new features while keeping as much information as possible. PCA does this with a linear map chosen to keep the most variance. It is unsupervised: it never looks at labels.
Set-up for points :
- Centre the data: subtract the mean from every point. Stack the centred points as rows of ().
- Form the covariance matrix (, symmetric, positive semidefinite). Some books divide by ; the directions do not change, only the eigenvalues scale.
- For a unit vector , the projections have variance .
PCA picks to maximise subject to . With a Lagrange multiplier this gives : the best is the eigenvector with the largest eigenvalue, and the variance captured is that eigenvalue .
The second component is the best direction orthogonal to the first; it is the eigenvector for , and so on. Because is symmetric, its eigenvectors can always be chosen orthonormal and its eigenvalues are real and .