The covariance matrix of a 4-dimensional dataset has eigenvalues 5, 3, 1.5 and 0.5. (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 j-th principal component is its eigenvalue λj, so the ratio is λj/∑iλi, and the mean squared reconstruction error after keeping k components is ∑j>kλj.

Steps

  1. The total variance is the sum of the eigenvalues, which equals the trace of the covariance matrix: 5+3+1.5+0.5=10.
  2. Explained-variance ratios: 5/10=0.50, 3/10=0.30, 1.5/10=0.15 and 0.5/10=0.05.
  3. Cumulative ratios: 0.50 for k=1, 0.80 for k=2, 0.95 for k=3, 1.00 for k=4.
  4. The first k for which the cumulative ratio is at least 0.90 is k=3 (since 0.80<0.90≤0.95).
  5. Dropping the last component loses variance λ4=0.5, so the average squared reconstruction error is 0.5 per point (the sum of the squared distances between x and its reconstruction, averaged over the data). This is 5% of the total variance.

Common mistakes

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 w1=(0,0), w2=(2,0) and w3=(5,0). The input is x=(3,1), the learning rate is η=0.5 and the neighbourhood is h=exp⁡(−d2/(2σ2)) with σ=1, where d 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 (1,2), (2,1), (3,4) and (4,3). 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?