Chapter 11

Principal component analysis

PCA constructs orthogonal directions of large variance without class labels. Centre the data before forming its covariance matrix. Decide whether to scale features: covariance PCA and correlation PCA solve different problems.

11.1 Covariance, principal directions and scores

Past papers · DA 2024–2026 (3 papers): 2 questions, 3 marks

Let X\mathbf X have n>1n>1 observations in rows and dd features. Write xˉ\bar{\mathbf x} for the training mean and Xc=X−1xˉ⊤\mathbf X_c=\mathbf X-\mathbf1\bar{\mathbf x}^\top. Choose divisor q=nq=n for mean-square covariance or q=n−1q=n-1 for sample covariance.

The directions are orthonormal, so two distinct selected directions have a 90∘90^\circ angle. Scores are uncorrelated under the same covariance convention, but need not be statistically independent. A direction's sign is arbitrary. Repeated eigenvalues make individual directions in that eigenspace nonunique; an orthonormal basis can still be chosen. Changing nn to n−1n-1 rescales eigenvalues, not directions or explained-variance ratios.

11.2 Reconstruction, explained variance and SVD

Use the centred data, eigenvalues and orthonormal directions from Section 11.1. Retaining rr components gives the best rank-at-most-rr approximation to centred data under squared Frobenius error.

Orthogonal projection onto the first principal direction; dashed segments show reconstruction residuals.Orthogonal projection onto the first principal direction; dashed segments show reconstruction residuals.

Last-minute recall

  • PCA uses centred inputs and does not use labels.
  • Specify the covariance divisor before interpreting an eigenvalue numerically.
  • Principal directions are orthogonal; scores are uncorrelated.
  • The first component maximises variance under a unit-norm constraint.
  • Explained variance is an eigenvalue sum divided by total variance.
  • Reconstruction error is the discarded variance with the matching divisor.
  • Whitening divides only positive-variance scores by their standard deviations.

Revise offline: the whole Machine Learning handbook as one PDF

42 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections