Skip to content
CampusEduX

Problem 3: Determine Components Needed for 95% Variance

Easypython
Learn the Concept: PCA (Principal Component Analysis)

Problem Description

Write a Python program that applies PCA without limiting the number of components, then calculates the minimum number of components needed to explain at least 95% of the total variance.

Input

A dataset with several numeric features.

Output

The minimum number of components needed, and the cumulative variance explained.

Constraints

  • At least 5 features.

Example Input

text
(A dataset with 5 numeric features)

Example Output

text
Components needed for 95% variance: 3 Cumulative variance explained: 0.96

Concepts Covered

PCA, cumulative sum, np.cumsum().

Related Problems

  • Problem 1: Apply Basic PCA and Check Explained Variance
    Easy · python
    Solve Problem
  • Problem 2: Scale Data Before Applying PCA
    Easy · python
    Solve Problem
  • Problem 4: Visualize High-Dimensional Data in 2D Using PCA
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...