Principal Component Analysis (PCA)
PCA finds the most informative axes in your data, letting you compress many features into a few "principal components." Use it to visualize high-dimensional datasets or preprocess features for machine learning, but beware: the components are hard to interpret.
THE MENTAL MODEL: Imagine your data as a cloud of points in a high-dimensional space. PCA finds the single line that passes through this cloud and captures the most variance (the longest axis of the cloud). This is the first principal component. It then finds the next-longest axis, perpendicular to the first, and so on. This process gives you a new, more efficient coordinate system for your data, ordered by how much information each new axis captures.
HOW IT WORKS: PCA is a linear transformation technique. First, it standardizes the data so that each feature has a mean of 0 and a standard deviation of 1. This prevents features with large scales from dominating the analysis. Second, it computes the covariance matrix to understand how different features vary with each other. Third, it calculates the eigenvectors and eigenvalues of this matrix. The eigenvectors are the principal components (the new axes), and their corresponding eigenvalues indicate how much variance each component explains. You can then select the top 'k' components to represent the data in a lower-dimensional space.
WHEN TO USE IT: PCA is powerful for dimensionality reduction. Three key use cases are: first, data visualization, where you project data with dozens of features onto 2 or 3 principal components to create a scatter plot; second, machine learning preprocessing, where you reduce the number of input features to speed up training and mitigate overfitting; third, noise reduction, by discarding components with low variance that often represent noise.
WHEN NOT TO USE IT: Avoid PCA when the interpretability of individual features is critical. Because principal components are combinations of original features (e.g., 0.6*age - 0.3*income), they lack a direct real-world meaning. Also, PCA assumes linear relationships. If your data has complex, non-linear structures (like a spiral), PCA will fail to capture the underlying pattern effectively.
ONE CANONICAL EXAMPLE: Image compression with "eigenfaces." A dataset of facial images, where each pixel is a feature, can have thousands of dimensions. PCA can identify a small set of principal components, or "eigenfaces," which are template faces that capture the most common variations in the dataset. Any original face can then be approximated as a weighted sum of a few dozen eigenfaces, dramatically reducing storage size.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.