Skip to content
Glacius
StatisticsConcept reference

Explained variance

The retained-variance fraction is the retained squared singular-value sum divided by the complete squared sum.

On this page 9 sections
  1. Overview
  2. After choosing PCA directions, you need to decide how many to keep
  3. For scales (5,4,3), keeping two retains (25+16)/50=41/50
  4. A retained fraction describes variation in the centered data
  5. A variance target gives a reproducible compression rule
  6. Key takeaway
  7. Further questions
  8. Sources & further reading
  9. Concept connections

01After choosing PCA directions, you need to decide how many to keep#

After choosing PCA directions, you need to decide how many to keep. Explained variance reports the share of the centered dataset’s variation represented by selected components. It is a property of this dataset and transformation, not the fraction of future predictions that will be correct.

Singular values measure lengths. Variance measures squared spread, so each component contributes its squared singular value. For sample covariance there is also a common divisor n1n-1; it cancels in a fraction because retained and total variance use the same observations.

Retained variance compares squared singular scales. Square the complete list, add the retained squares, and divide by the sum of all squares. The total must be positive.

fraction=ikσi2iσi2\text{fraction}=\frac{\sum_{i\le k}\sigma_i^2}{\sum_i\sigma_i^2}

For singular values (4,3)(4,3), total squared scale is 16+9=2516+9=25. Keeping the first component retains 16/2516/25 of the variance, not 4/74/7.

Singular values 4 and 3 contribute squared scales 16 and 9. A 250-pixel strip uses 10 pixels per squared-scale unit: the retained segment is 160px and the discarded segment is 90px. Retaining the first component gives 16/25.Singular values 4 and 3 contribute squared scales 16 and 9. A 250-pixel strip uses 10 pixels per squared-scale unit: the retained segment is 160px and the discarded segment is 90px. Retaining the first component gives 16/25.
Figure 1Singular values 4 and 3 contribute squared scales 16 and 9. A 250-pixel strip uses 10 pixels per squared-scale unit: the retained segment is 160px and the discarded segment is 90px. Retaining the first component gives 16/25.
Link to this figure ↗Download SVGDownload PNG

With complete singular values (4,3)(4,3), square first to obtain (16,9)(16,9). Total variation is proportional to 2525; keeping the first component retains 16/25=0.6416/25=0.64, or 64%. The discarded share is 9/25=0.369/25=0.36. Using 4/(4+3)4/(4+3) would compare lengths instead of variation.

Check your reasoning

Centered-data singular values (8,6)(8,6) (complete). Keep 11. Retained variance fraction (use /)?

Show answer and explanation
16/25

Retained squares 6464; total 100100.

02For scales (5,4,3), keeping two retains (25+16)/50=41/50#

For scales (5,4,3)(5,4,3), keeping two retains (25+16)/50=41/50(25+16)/50=41/50. The discarded fraction is 9/509/50. These add to 1 because they partition the same squared total.

Check your reasoning

Centered-data singular values (3,2)(3,2) (complete). Keep 11. Claimed fraction 0.60.6. Repair.

  1. A0.6
  2. B9/13
  3. C4/13
Show answer and explanation
9/13

Squared sums: 9/139/13.

03A retained fraction describes variation in the centered data#

A retained fraction describes variation in the centered data. It does not guarantee predictive quality. Compare it to a target only after squaring: a target of at least 4/54/5 includes equality.

For scales (5,4,3)(5,4,3), total squared scale is 25+16+9=5025+16+9=50. One component retains 25/50=0.525/50=0.5; two retain 41/50=0.8241/50=0.82. A target of at least 80% therefore needs two components in this example. Compare the cumulative fraction to the target after computing it.

Check your reasoning

Centered-data singular values (6,3)(6,3) (complete). Keep 11. Target: at least 0.80.8 of variance. Target met?

  1. ANo: 2/3
  2. BNo: 0.2
  3. CYes: 0.8
Show answer and explanation
Yes: 0.8

Retained fraction 0.80.8.

04A variance target gives a reproducible compression rule#

A variance target gives a reproducible compression rule. Before using it for prediction, validate the model with the chosen transformation fitted only on training data. A component carrying little feature variation may still carry useful label information.

Key takeaway

Square the singular values. Divide the retained sum by the full positive sum; compare that fraction with the target.

  • Compute a retained-variance fraction from supplied singular values.

Further questions

What if every singular value is zero?
Then the centered data have zero total variance. The usual retained fraction is undefined because its denominator is zero.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Explained variance.” Math behind ML. /learn/s-pca-variance