6.2 Explained Variance Ratio, Trace Conservation, and Choosing k Principal Components

When you run PCA on a 100-dimensional dataset, it returns 100 orthogonal principal components ordered by their eigenvalues λ1≥λ2≥⋯≥λ100≥0\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_{100} \ge 0. If you keep all 100 components, you have merely rotated your coordinate system without compressing anything! How do you decide how many components kk to retain?

The mathematical foundation for choosing kk is trace conservation: because the trace of a matrix is invariant under orthogonal similarity transformations, the sum of all eigenvalues equals the total variance of the original features.

In this Article

1. Proving Trace Conservation: tr(C) = Σ Var(xⱼ) = Σ λⱼ

For any two matrices AA and BB of compatible dimensions, the cyclic property of the trace states that tr(AB)=tr(BA)\text{tr}(AB) = \text{tr}(BA). Applying this to the spectral decomposition C=QΛQTC = Q \Lambda Q^T (where QTQ=IQ^T Q = I) yields:

tr(C)=tr(QΛQT)=tr(ΛQTQ)=tr(ΛI)=tr(Λ)=∑j=1dλj\text{tr}(C) = \text{tr}(Q \Lambda Q^T) = \text{tr}(\Lambda Q^T Q) = \text{tr}(\Lambda I) = \text{tr}(\Lambda) = \sum_{j=1}^d \lambda_j

Geometrically, rotating a rigid cloud of points neither creates nor destroys variance: it simply redistributes the total variance tr(C)\text{tr}(C) across the principal axes so that the leading axes pack as much variance as possible.

2. Explained Variance Ratio (EVR) and Scree Plots

  • Individual Explained Variance Ratio of Component jj:

    EVRj=λjtr(C)=λj∑m=1dλm\text{EVR}_j = \frac{\lambda_j}{\text{tr}(C)} = \frac{\lambda_j}{\sum_{m=1}^d \lambda_m}

  • Cumulative Explained Variance Ratio of Top kk Components:

    CEVR(k)=∑j=1kEVRj=∑j=1kλj∑m=1dλm=1−Mean Squared Reconstruction Error(k)Total Variance\text{CEVR}(k) = \sum_{j=1}^k \text{EVR}_j = \frac{\sum_{j=1}^k \lambda_j}{\sum_{m=1}^d \lambda_m} = 1 - \frac{\text{Mean Squared Reconstruction Error}(k)}{\text{Total Variance}}

   SCREE PLOT (Eigenvalue vs. Component Index k):
   lambda_k ^
       12.0 |  *  (PC1: Big signal)
        8.0 |     *  (PC2: Big signal)
        2.0 |        *  <-- "Elbow" at k = 2 or 3
        0.5 |           *   *   *   *   *   (Noise floor: flat tail of tiny eigenvalues)
            +-------------------------------> Component k
               1  2  3  4   5   6   7   8

3. Practical Rules for Selecting k in Machine Learning and Science

  1. Cumulative Variance Threshold (e.g., 90%90\%, 95%95\%, or 99%99\%): Choose the smallest kk such that CEVR(k)≥0.95\text{CEVR}(k) \ge 0.95. In scikit-learn, passing a float PCA(n_components=0.95) automatically selects this kk.
  2. Scree Plot Elbow (Cattell's Criterion): Plot λk\lambda_k versus kk and truncate where the steep cliff of signal eigenvalues transitions into a flat rubble ("scree") of background noise.
  3. Kaiser Criterion (for Standardized Correlation PCA): When all features are standardized to variance 1.01.0 (so tr(R)=d\text{tr}(R) = d and the average eigenvalue is 1.01.0), retain components with λk>1.0\lambda_k > 1.0 (components that explain more variance than a single original variable).

4. Worked 5D Scree Table and Reconstruction Error Calculation

Suppose a 5D dataset has diagonal covariance entries 3.2,4.8,2.5,5.5,4.03.2, 4.8, 2.5, 5.5, 4.0 (so tr(C)=20.0\text{tr}(C) = 20.0), and its eigenvalues are λ1=13.0,λ2=5.0,λ3=1.2,λ4=0.5,λ5=0.3\lambda_1 = 13.0, \lambda_2 = 5.0, \lambda_3 = 1.2, \lambda_4 = 0.5, \lambda_5 = 0.3.

Component kkEigenvalue λk\lambda_kIndividual EVRk\text{EVR}_kCumulative CEVR(k)\text{CEVR}(k)Relative Reconstruction Error
113.013.065.0%65.0\%65.0%65.0\%35.0%35.0\%
25.05.025.0%25.0\%90.0%90.0\%10.0%10.0\%
31.21.26.0%6.0\%96.0%96.0\%4.0%4.0\%
40.50.52.5%2.5\%98.5%98.5\%1.5%1.5\%
50.30.31.5%1.5\%100.0%100.0\%0.0%0.0\%

If our engineering target is ≥95%\ge 95\% variance retention (or ≤5%\le 5\% relative squared reconstruction error), we select k=3k = 3 components, capturing 96.0%96.0\% of the variance while compressing storage by 40%40\%.

5. Active Recall Check and Key Takeaways

Quick Check: Test Your Understanding

Question: You run PCA on a standardized correlation matrix of d=12d = 12 features (so every feature has variance 1.01.0). Without computing a single eigenvalue, what is the exact sum of all 12 eigenvalues?

Answer: By trace conservation, ∑j=112λj=tr(R)=12×1.0=12\sum_{j=1}^{12} \lambda_j = \text{tr}(R) = 12 \times 1.0 = 12.

  • Trace Conservation: ∑j=1dλj=tr(C)\sum_{j=1}^d \lambda_j = \text{tr}(C) holds for every symmetric covariance matrix.
  • Dual Meaning of 1−CEVR(k)1 - \text{CEVR}(k): The uncaptured variance fraction 1−CEVR(k)1 - \text{CEVR}(k) equals the relative mean squared reconstruction error.
  • Canonical References: See Wikipedia Reference on Scree Plots.

Take a Quiz Based on This Article

Test your understanding with AI-generated questions tailored to this content

Adaptive Learning with SynLearn

Explore this article through guided practice that adapts to your answers

✓Step-by-step concepts & lessons
✓Active recall & adaptive feedback
✓Personalized spaced repetition
explained-variance-ratio
matrix-trace
scree-plot
feature-scaling
standardization
pca