Skip to content
C

Problem 1: Apply Basic PCA and Check Explained Variance

Easypython

Problem Description

Write a Python program that applies PCA to reduce a dataset with 4 features down to 2 components, and prints the explained variance ratio for each.

Input

A dataset with 4 numeric features.

Output

The explained variance ratio for each of the 2 retained components.

Constraints

  • At least 5 data rows.

Example Input

text
(A dataset with 4 correlated numeric features across 5 rows)

Example Output

text
Explained variance ratio: [0.85, 0.10]

Concepts Covered

PCA, n_components, .explained_variance_ratio_.

Input (stdin)

Output

Run your code to see output here...