Intermediate Topic 27 of 51 AI & Machine Learning
PCA
Projecting data onto directions of maximal variance.
How it works
Principal component analysis finds orthogonal directions, the principal components, along which data varies the most, by computing the eigenvectors of the covariance matrix or the singular value decomposition of the centered data. The first component captures the greatest variance, the second the most remaining variance orthogonal to the first, and so on. Projecting onto the top k components reduces dimensionality, and the explained-variance ratio shows how much information is kept.
Step-by-step walkthrough
- Centre the data.
- Find the direction with the most variance.
- The next direction is perpendicular to it.
- Project the data onto the top few axes.
- Most information is kept in fewer dimensions.
Where it is used
Visualization, noise reduction, decorrelating features, compressing images, preprocessing for regression or clustering and exploring genomics or finance data use PCA.
Common pitfall
Features must be centered and usually scaled, otherwise large-valued features dominate. PCA is linear, so it misses nonlinear structure, and high-variance directions are not necessarily the most predictive. Components are hard to interpret. Outliers can distort directions. Choose the number of components by explained variance or a scree plot, and fit on training data only.
Where it fits in the course
PCA is topic 27 of 51 in AI & Machine Learning, rated Intermediate. It follows Dimensionality Reduction. The next topic is Hyperparameter Tuning.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the AI & Machine Learning quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is PCA?
Where do people use PCA?
What is the most common mistake with PCA?
What should I learn before this topic?
How can I practice it?
Is PCA hard to learn?
How long does it take to learn PCA?
Which topics are related to PCA?
What should I study after PCA?
Related topics
- Dimensionality Reduction (AI & Machine Learning)
- Hyperparameter Tuning (AI & Machine Learning)
- Feature Engineering (AI & Machine Learning)
- Neural Networks (AI & Machine Learning)