Machine Learning
Intermediate
4.5

PCA for Dimensionality Reduction

Compress many features into a few while keeping the signal.

0h 25m
1 lesson
1.2K students

What You'll Learn

Learning objectives will be added soon.

Tutorial Content

Why reduce dimensions

Too many features slow training, invite overfitting, and resist visualization. PCA finds new axes that capture the most variance, letting you keep a handful and drop the rest.

from sklearn.decomposition import PCA
pca = PCA(n_components=2)
reduced = pca.fit_transform(X_scaled)
print(pca.explained_variance_ratio_.sum())

Practical notes

  • Scale first — PCA is sensitive to feature magnitude.
  • Use the explained-variance ratio to pick how many components to keep.
  • Great for visualization (reduce to 2D) and as a preprocessing step before modeling.

Your Progress

Sign in to track your progress

Tags

Machine Learning
Data Science
scikit-learn