← Back to all experiments
Dimensionality ReductionIntermediateStandardScalerPCA

EXP3: PCA Dimensionality Reduction

Reduce Iris dataset from 4D to 2D and visualize class separation.

Key highlights

  • Standardizes features before PCA
  • Projects to 2 components for visualization
  • Color-coded by species

Metrics

EigenvaluesExplained variance

Outputs

PCA scatter plot
Iris PCA projection in 2D

Full Python Code

The complete Python script directly from the repository.

Python
df_scaled = scaler.fit_transform(df[features])
pca = PCA(n_components=2)
principal_components = pca.fit_transform(df_scaled)

Next steps

Want to explore further? Try the full gallery or open the raw script to tweak parameters.