Dimensionality Reduction Calculator
Determine how many principal components to retain based on eigenvalues and target explained variance. Includes scree plot data, Kaiser criterion, and cumulative variance analysis.
About this calculator
This calculator takes up to five eigenvalues, sorts them from largest to smallest regardless of which numbered slot you typed them into (line 12), and walks the running cumulative share of total variance until it clears your Target Variance Explained threshold (lines 26-31) — that crossing point is Components to Keep. The Total Variance field is not part of that arithmetic at all: the variance total the percentages are measured against is recomputed from the five eigenvalues themselves (line 15's `eigenSum`), so changing Total Variance alone moves nothing. A negative eigenvalue is not clamped to zero either — the collection loop only keeps entries where `v >= 0` (line 8), so a negative value is dropped from the count entirely rather than contributing a zero-variance component.
At the defaults (45, 25, 15, 10, 5), the first four eigenvalues already cover 95% of the total, so Components to Keep is 4 and Dimension Reduction reports 20% (1 of 5 dropped); the Kaiser criterion separately flags 2 components (those above the mean eigenvalue of 20). Raising Eigenvalue 5 — the smallest — actually raises Components to Keep, because it inflates the variance total every share is normalized against (line 15) enough to push the first four components' cumulative share just under the 95% line, forcing a fifth component in. What this does not account for: negative-eigenvalue inputs contributing anything to the total, or the Kaiser criterion changing which components it flags once a perturbation is large enough to cross the running average — this calculator's Target Variance field, unlike some others on the site, uses `??` rather than `||` (line 4), so a literal 0 there is respected and then clamped into the 1-100 range rather than silently replaced.
Inputs
Results
Components to Keep
4
Variance Explained
95%
How to Use This Calculator
- Enter the total variance and each principal component's eigenvalue (up to five).
- Set the minimum explained variance threshold (e.g., 95%).
- Review the number of components needed to reach your variance threshold.
- Plot the scree plot to identify the elbow and confirm the component count.
- Use the selected components as input features for downstream modeling.
How the result changes with Eigenvalue 1 (Largest)
| Eigenvalue 1 (Largest) | Components to Keep | Variance Explained |
|---|---|---|
| 23 | 5 | 100% |
| 34 | 5 | 100% |
| 68 | 4 | 95.93% |
| 113 | 4 | 97.02% |
What each input means
- Total Variance
- The total variance across all original features (sum of all eigenvalues ideally).
- Eigenvalue 1 (Largest)
- Eigenvalue for the first principal component (largest variance direction).
- Eigenvalue 2
- Eigenvalue for the second principal component.
- Eigenvalue 3
- Eigenvalue for the third principal component.
- Eigenvalue 4
- Eigenvalue for the fourth principal component.
- Eigenvalue 5 (Smallest)
- Eigenvalue for the fifth principal component (smallest variance direction).
- Target Variance Explained (%)
- The minimum percentage of total variance you want your retained components to explain. 95% is common.
How this is calculated
Worked example, using the default values
- Identify Input Parameters4 parametersTotal Variance = 100, Eigenvalue 1 (Largest) = 45, Eigenvalue 2 = 25, Eigenvalue 3 = 15 = 7 input(s) provided
- Calculate Components to KeepComponents to Keep4 = 4
- Calculate Variance Explained95 = 95
- Calculate Dimension ReductionDimension Reduction20 = 20
- Calculate Kaiser Criterion ComponentsKaiser Criterion Components2 = 2
Engine last updated . Checked against 1 independently-derived test — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
Does changing Total Variance change Components to Keep or Explained Variance?
No. Every percentage this calculator reports is measured against a variance total it recomputes itself from the five eigenvalues you enter (line 15), never from the Total Variance field — that input plays no role in the arithmetic at all, so changing it alone leaves Components to Keep, Explained Variance, and every other output unchanged.
Why does raising Eigenvalue 5, the smallest one, increase how many components I need to keep?
Every component's share of variance is normalized against the sum of all five eigenvalues (line 15), and Eigenvalue 5 contributes to that sum even though it rarely gets kept itself. Growing it inflates the total enough that the first four components' combined share dips just under the 95% target (lines 26-31), so the running total has to reach a fifth component before it crosses the threshold.
Does it matter which numbered slot (Eigenvalue 1 through 5) I put each value in?
No — the calculator re-sorts all five eigenvalues from largest to smallest before doing anything else (line 12), so principal components are always ranked by their actual magnitude rather than by which input box you typed them into. Labeling one entry "Eigenvalue 1 (Largest)" is a convenience for you, not a requirement the code enforces.
What happens if I enter a negative eigenvalue?
It is dropped from the analysis entirely rather than being treated as zero variance. The collection loop only keeps a value when `v !== undefined && v !== null && v >= 0` (line 8), so a negative entry reduces Total Components by one instead of adding a component that explains no variance — the two are not the same outcome.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Feature Scaling Calculator
Scale raw feature values using min-max normalization, z-score standardization, robust scaling, and max-abs normalization for machine learning preprocessing.
Data ScienceClustering Quality Score Calculator
Evaluate clustering quality using silhouette score, Calinski-Harabasz index, Davies-Bouldin index, and Dunn index from cluster distance metrics.
MLOps & AI CostingFeature Importance Calculator
Estimate how many features to keep, overfitting risk, and expected variance retention based on dataset size, model type, and correlation threshold.
Data ScienceA/B Test Calculator
Determine statistical significance of A/B test results. Calculate z-score, p-value, conversion lift, and whether your variant beats the control at your chosen confidence level.
More in Math & Statistics.