The covariance matrix of a 4-dimensional dataset has eigenvalues , , and . (a) What fraction of the variance does each principal component explain? (b) How many components are needed to keep at least 90% of the variance? (c) What is the average squared reconstruction error per point when you keep that many?
Unsupervised learning, Principal component analysis
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can turn eigenvalues into explained-variance ratios and a reconstruction error.
Key idea
The variance along the -th principal component is its eigenvalue , so the ratio is , and the mean squared reconstruction error after keeping components is .
Steps
- The total variance is the sum of the eigenvalues, which equals the trace of the covariance matrix: .
- Explained-variance ratios: , , and .
- Cumulative ratios: for , for , for , for .
- The first for which the cumulative ratio is at least is (since ).
- Dropping the last component loses variance , so the average squared reconstruction error is per point (the sum of the squared distances between and its reconstruction, averaged over the data). This is of the total variance.
Common mistakes
- Dividing by the largest eigenvalue instead of the sum.
- Using singular values instead of eigenvalues: the eigenvalues of the covariance are , so the singular values must be squared first.
- Reporting the error as or as . The error is the sum of the discarded eigenvalues, not the retained fraction.
How long your answer should be
A few lines of arithmetic; 2 minutes.
Last checked on 4 December 2026.
Read this
Previous in Unsupervised learning: A self-organising map has three neurons on a line with weight vectors , and . The input is , the learning rate is and the neighbourhood is with , where is the distance on the map between neurons (neurons 1, 2, 3 are at positions 1, 2, 3). Which neuron wins, and what are the three weight vectors after one update?
Next in Unsupervised learning: Four 2-D points are , , and . What are the sample covariance matrix, the first principal component, the fraction of variance it explains, and the coordinate of the first point along it?