ধরুন আপনার dataset-এ 100টি numerical feature আছে।

কিন্তু অনেক feature একে অপরের সাথে highly correlated।

উদাহরণ:

Height
Weight
BMI
Waist Size
Body Fat Percentage

এগুলো পুরোপুরি একই information না দিলেও একে অপরের সাথে strong relationship থাকতে পারে।

এখন যদি সব 100টি feature model-এ ব্যবহার করি, তাহলে:

  • dimensionality বাড়ে

  • computation বাড়ে

  • redundant information থাকে

  • visualization কঠিন হয়

  • কিছু algorithm-এর performance খারাপ হতে পারে

এই ধরনের situation-এ Principal Component Analysis বা PCA useful।

PCA-এর Core Idea

PCA original features সরাসরি select করে না।

বরং original features-এর combination থেকে নতুন features তৈরি করে।

এই নতুন features-কে বলা হয়:

Principal Components

যেমন:

Original Features:

X1
X2
X3
X4
...
X100

↓ PCA

PC1
PC2
PC3
...
PC20

এই Principal Components এমনভাবে তৈরি হয় যাতে কম সংখ্যক component দিয়ে data-এর যতটা সম্ভব variation preserve করা যায়।

সহজ Intuition

ধরুন 2-dimensional data এমনভাবে ছড়িয়ে আছে:

•
    •
   •
 •
•

Data মূলত একটি diagonal direction বরাবর বেশি spread করেছে।

PCA চেষ্টা করবে সেই direction খুঁজতে।

এই direction-টাই হতে পারে:

First Principal Component — PC1

অর্থাৎ PC1 হলো সেই direction যেখানে data-এর variance maximum।

First Principal Component

First Principal Component এমন direction খোঁজে যেখানে projected data-এর variance সবচেয়ে বেশি।

সহজভাবে:

Data কোন direction-এ সবচেয়ে বেশি ছড়িয়ে আছে, PCA প্রথমে সেই direction খুঁজে বের করে।

Second Principal Component

Second Principal Component আবার next highest variance-এর direction খুঁজবে।

কিন্তু একটি গুরুত্বপূর্ণ constraint আছে:

PC2 ⟂ PC1

অর্থাৎ PC2, PC1-এর সাথে orthogonal বা perpendicular হবে।

এর ফলে দুইটি component একই information যতটা সম্ভব repeat না করে।

একইভাবে:

PC3
PC4
...

পরবর্তী directions capture করে।

Example

ধরুন:

Original features = 100

PCA করার পরে দেখা গেল:

20 Principal Components

দিয়েই original data-এর:

95% variance

retain করা যাচ্ছে।

তাহলে 100-dimensional data-কে আমরা 20-dimensional representation-এ reduce করতে পারি।

100 dimensions
      ↓
     PCA
      ↓
20 dimensions

এটাই PCA-এর প্রধান use case।

Explained Variance

প্রতিটি Principal Component কতটুকু variance explain করছে সেটা measure করা যায়।

ধরুন:

PC1 → 45%
PC2 → 25%
PC3 → 15%
PC4 → 8%
PC5 → 3%

প্রথম 3টি component:

45 + 25 + 15 = 85%

variance explain করছে।

এটাকে cumulative explained variance দিয়ে দেখা যায়।

PCA করার আগে Scaling কেন গুরুত্বপূর্ণ?

ধরুন feature দুটি:

Age    → 18–70
Salary → 20,000–500,000

Salary-এর numerical scale অনেক বড়।

Scaling না করলে PCA salary feature-এর variance-কে disproportionately বেশি importance দিতে পারে।

তাই PCA-এর আগে সাধারণত numerical features standardize করা হয়।

Standardization
      ↓
     PCA

Benefits

PCA useful হতে পারে:

dimensionality reduction redundant information কমাতে noise reduction visualization model training speed বাড়াতে high-dimensional data simplify করতে

Drawback

PCA-এর সবচেয়ে বড় limitation হলো interpretability।

Original feature:

Age
Income
Weight
Temperature

সহজে explain করা যায়।

কিন্তু PCA-এর পরে:

PC1
PC2
PC3

business meaning সরাসরি বোঝা কঠিন।

কারণ একটি component অনেক original feature-এর weighted combination।

উদাহরণ:

PC1 =
0.42 × Height
+ 0.38 × Weight
+ 0.31 × Waist
- 0.12 × Age

এটি mathematically useful হলেও business-wise explain করা কঠিন।

PCA Feature Selection নয়

এটা একটা common confusion।

Feature Selection existing features থেকে কিছু feature রাখে।

100 features
↓
Select
↓
20 original features

কিন্তু PCA:

100 original features
↓
Transform
↓
20 new features

তৈরি করে।

Interview-ready Explanation

PCA is an unsupervised dimensionality reduction technique
that transforms correlated numerical features into a new
set of uncorrelated variables called principal components.

The first principal component captures the direction of
maximum variance, and each subsequent component captures
the next highest variance while remaining orthogonal to
the previous components.

PCA can reduce dimensionality, noise, and computation,
but the resulting components are usually less interpretable
than the original features.

Features are typically standardized before applying PCA,
especially when they have different scales.

সহজে মনে রাখুন:

PCA
→ Find important directions
→ Preserve variance
→ Reduce dimensions
→ Lose some interpretability