PCA: Tackling the Curse of Dimensionality

fakhir hassanfakhir hassan
3 min read

In the world of data science and machine learning, we often deal with datasets that have dozens, sometimes even hundreds of features. While it might feel like "the more features, the better," reality often proves otherwise. This challenge is known as the curse of dimensionality.

Imagine predicting house prices with features like square footage, number of bedrooms, location, age of the house, neighborhood crime rates, and so on. The more features we add, the more complex our model becomes. But at the same time, the data becomes sparse in high-dimensional space, which can lead to overfitting and poor generalization.

So, how do we keep the useful information while reducing the number of features?
That’s where Principal Component Analysis (PCA) comes to the rescue.


PCA in Simple Terms

At its core, PCA is about feature extraction. Instead of blindly dropping features (like in feature selection), PCA combines features in a smart way to create new ones, called principal components.

Think of it like this:

  • If you have two features — say room size and number of rooms — they both carry similar information about the house.

  • PCA combines them into a single new feature that captures the most variance (spread of information) from both.

  • In geometric terms, it’s like taking 2D data (room size on the x-axis, number of rooms on the y-axis) and projecting it into a 1D line that best represents the data.

This way, instead of handling redundant features, PCA creates a compact version that still carries the essence of the dataset.


Geometric Intuition

Visualize PCA as finding new axes to represent your data:

  • The first principal component (PC1) is the direction where the data varies the most.

  • The second principal component (PC2) is perpendicular (orthogonal) to the first and captures the next highest variance.

  • And so on.

By projecting the data onto these new axes, we can reduce the number of dimensions while retaining as much information as possible.


The Math Behind PCA (Simplified)

Here’s the typical workflow:

  1. Standardize the data (make all features comparable).

  2. Compute the covariance matrix to understand relationships between features.

  3. Find eigenvectors and eigenvalues of the covariance matrix.

    • Eigenvectors → directions of new principal components.

    • Eigenvalues → how much variance each component explains.

  4. Select the top components with the largest eigenvalues.

  5. Project the data onto these components.


Why Use PCA?

  • Reduces Overfitting: Fewer features → less noise → better generalization.

  • Improves Accuracy: Models often perform better with reduced, informative features.

  • Better Visualization: You can plot complex high-dimensional data into 2D or 3D without losing much information.

  • Speeds Up Training: Fewer dimensions = faster computation.


Real-Life Example

Suppose you’re working with an e-commerce dataset with features like:

  • Number of items in cart

  • Cart total value

  • Time spent on site

  • Number of clicks

  • Page views

Some of these features overlap in meaning. For instance, "cart value" and "number of items" are related. PCA can combine these correlated features into one principal component, giving the model a clearer representation.


Final Thoughts

Think of PCA as a compression tool for your data. Instead of dealing with hundreds of features, you keep only the most important combinations that explain the variance.

If I were to put it in one line:
👉 PCA is like merging multiple similar features into one, preserving the story your data wants to tell while cutting out the noise.

So next time you face a high-dimensional dataset, don’t panic. Remember, PCA has your back!


0
Subscribe to my newsletter

Read articles from fakhir hassan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

fakhir hassan
fakhir hassan

Student at Comsats Islamabad Will be completing my degree in 2026 here you will find all my daily learnings