← Back to all experiments
Dimensionality ReductionIntermediateStandardScalerPCA

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

Code snapshot

Key lines that anchor the experiment workflow.

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.