Monday , November 16 2026
PCA

Principal Component Analysis (PCA) in Python with Scikit-Learn

Principal Component Analysis (PCA) is an unsupervised dimensionality-reduction technique. It converts a set of correlated features into a smaller set of uncorrelated variables called principal components, ordered by how much of the data’s variance each one explains. You keep the first few components, so the dataset becomes smaller while losing as little information as possible.

Key takeaways

  • PCA works on standardized data, so scale your features before applying it.
  • The principal components are the eigenvectors of the covariance matrix; their eigenvalues tell you how much variance each component explains.
  • Choose the number of components from the explained variance ratio (for example, enough components to keep 90–95% of the variance).
  • In Python, sklearn.decomposition.PCA handles the full process in a few lines.
PCA – ITRONIX SOLUTIONS

Summary

PCA reduces the number of features by projecting the data onto the directions of maximum variance. The workflow is: standardize the data, build the covariance matrix, compute eigenvectors and eigenvalues, sort them by eigenvalue and keep the top components. Scikit-Learn wraps these steps in the PCA class, which makes it easy to speed up models, remove multicollinearity and visualize high-dimensional data in 2D or 3D.

Frequently asked questions

What is PCA used for in machine learning?

PCA is used to reduce the number of input features, speed up training, remove correlated (redundant) features and visualize high-dimensional data in two or three dimensions.

Is PCA supervised or unsupervised?

PCA is unsupervised. It only looks at the input features and their variance; it does not use the target labels.

Why do we standardize data before PCA?

PCA is driven by variance, so features measured on larger scales would dominate the components. Standardizing gives every feature mean 0 and variance 1, so each one contributes fairly.

How many principal components should I keep?

Plot the cumulative explained variance ratio and keep the smallest number of components that reaches your target, commonly 90–95% of the total variance.

Related tutorials

Learn it step by step

Want a structured path? Take the free Unsupervised Machine Learning with Python course, then earn the Artificial Intelligence with Python Professional Certification.

About Machine Learning