2.5.8 · HinglishUnsupervised Learning

Principal Component Analysis (PCA) theory

2,661 words12 min readRead in English

2.5.8 · AI-ML › Unsupervised Learning

PCA Actually Kya Karta Hai

Principal Component Analysis high-dimensional data ko ek nayi coordinate system mein transform karta hai jahan:

  1. Pehla axis (1st principal component) maximum variance ki direction mein point karta hai
  2. Doosra axis (2nd PC) maximum baachi hui variance ki direction mein point karta hai, pehle se orthogonal
  3. Har agla axis poori variance ko maximize karta hai, pehle waale sab se orthogonal hokar

Kyun orthogonal? Hum chahte hain ki components variation ke independent sources capture karein. Orthogonality ensure karta hai koi redundancy nahi—har PC nayi information add karta hai.

Mathematics: PCA Scratch Se Derive Karna

Step 1: Data ko Center Karo (KYUN)

Data matrix ( samples, features) diya hai, pehle use center karo: jahan mean vector hai.

Kyun center karein? PCA data ke "center of mass" se directions dhundta hai. Center kiye bina, pehla PC sirf mean ki taraf point kar sakta hai variance structure capture karne ki jagah. Centering coordinate origin ko data ka centroid bana deta hai.

Step 2: Variance Maximization Problem Formulate Karo

Hum ek unit vector (pehla PC) dhundhna chahte hain jis par data project karne se variance maximize ho.

ka par projection:

Projections ka variance:

Kyunki data centered hai, :

Yeh step kyun? Hum squared scalar projection expand kar rahe hain. Property use kar rahe hain jab result scalar ho.

Rearrange karke:

jahan covariance matrix hai.

Step 3: Lagrange Multipliers Se Solve Karo

Hum chahte hain:

Constraint kyun? Iske bina, ko scale karke variance arbitrarily bada kar sakte hain. Unit constraint ka matlab hai hum ek direction dhundh rahe hain, magnitude nahi.

Lagrangian:

ke saath derivative leke zero par set karo:

Derivative kyun? Hum critical points dhundh rahe hain. 2 ka factor quadratic forms differentiate karne se aata hai: jab symmetric ho.

Isse milta hai:

Yeh eigen-equation hai! ko ka eigenvector hona chahiye eigenvalue ke saath.

Kaun sa eigenvector? Apne objective mein wapas substitute karo:

Captured variance ke barabar hai! Variance maximize karne ke liye, sabse bade eigenvalue wala eigenvector choose karo.

Baad Wale Components Orthogonal Kyun Hote Hain

Doosre PC ke liye, hum variance maximize karte hain subject to:

  • (unit length)
  • (pehle PC se orthogonal)

Mathematical reason: Ek symmetric matrix (jaise covariance matrices) ke eigenvectors jo distinct eigenvalues se correspond karte hain, automatically orthogonal hote hain. Kyunki covariance matrices symmetric real matrices hain, inke paas orthonormal eigenvectors ka ek complete set hota hai.

Intuitive reason: Agar mein ke saath koi component hota, woh component woh variance capture karta jo pehle se ne capture kar liya hai (redundant). Orthogonality ensure karta hai ki har PC nayi, uncorrelated variance capture kare.

Reconstruction aur Dimensionality Reduction

Forward Transform (Encoding)

Data ko pehle PCs par project karo:

Har row sample ki k-dimensional representation hai.

Reconstruction (Decoding)

Reduced representation se original data approximate karo:

Phir mean wapas add karo:

Reconstruction error (mean squared error):

Yeh formula kyun? Frobenius norm squared un eigenvalues ka sum hai jo humne include nahi kiye. Har discarded PC apna eigenvalue error mein contribute karta hai.

Mathematical Properties

1. PCA Reconstruction Error Minimize Karta Hai

components wala PCA Frobenius norm ke under ka best rank-k approximation deta hai:

Kyun? Yeh Eckart-Young theorem hai. Best low-rank approximation SVD/eigendecomposition se aati hai.

2. Singular Value Decomposition Se PCA

Alternative computation: centered data ka SVD:

Tab:

  • Principal components: (right singular vectors)
  • Eigenvalues: (squared singular values divided by )
  • Projected data:

SVD kyun? explicitly compute karne se zyada numerically stable hai, especially jab ho.

3. PC Space Mein Covariance

Projection ke baad, ka covariance diagonal hota hai:

Matlab: Principal components uncorrelated hain. Humne data ko decorrelate kar diya hai.

Recall 12-Saal-Ke Bachche Ko Samjhao

Socho tumhari class ek photo leti hai. Tumhare paas 3D space mein sabki position hai (left-right, forward-back, up-down). Lekin jab tum photo dekhte ho, tumhe ehsaas hota hai ki zyaadatar information sirf 2 dimensions mein hai—photo plane mein! Teesra dimension (depth) barely matter karta hai kyunki sab roughly ek hi distance par camera se khade the.

PCA data ke liye "photo angle" dhundne jaisa hai. Yeh tumhare data cloud ko dekhta hai aur poochta hai: "Agar mujhe photo leni hoti (kam dimensions par project karna hota), kaun sa angle sabse zyada information rakhega?" Pehla principal component camera ki main direction jaisa hai—yeh capture karta hai jahan log sabse zyada spread hain. Doosra PC side se dekhne jaisa hai koi remaining spread pakadne ke liye.

Hum kam dimensions kyun chahte hain? Socho sabki position describe karna. "3.2m left, 1.8m forward, 0.1m Sarah se upar" kehne ki jagah tum bas "Row 3, Position 7" keh sakte ho agar sab seedhi rows mein khade hain. Teen ki jagah do numbers! PCA messy data mein wahi "seedhi rows" dhundta hai.

Connections

  • Covariance Matrix — PCA isse decompose karke variance structure dhundta hai
  • Eigendecomposition — PCA ke neeche ka mathematical tool
  • Singular Value Decomposition — PCA compute karne ka alternative (zyada stable) tarika
  • Linear Autoencoders — Neural networks jo linear hone par PCA-jaisi representations seekhte hain
  • Kernel PCA — Kernel trick use karke nonlinear extension
  • Factor Analysis — PCA se related probabilistic model, explicit noise ke saath
  • Independent Component Analysis — Statistically independent (sirf uncorrelated nahi) components dhundta hai
  • Feature Scaling — Mixed units wale PCA ke liye zaroori preprocessing
  • Dimensionality Reduction — PCA ek technique hai; t-SNE, UMAP se compare karo
  • Variance — Woh quantity jo PCA successive orthogonal directions mein maximize karta hai

#flashcards/ai-ml

PCA ka goal kya hai? :: Data mein orthogonal directions dhundna jo variance maximize karein, jisse dimensionality reduction kiya ja sake aur zyaadatar information preserve ho.

PCA se pehle data center kyun karna chahiye?
Taaki pehla PC variance structure capture kare na ki sirf mean ki taraf point kare; PCA centroid ke around variance dhundta hai, origin se nahi.
Mathematically principal component kya hota hai?
Covariance matrix ka eigenvector; k-th PC woh eigenvector hai jo k-th sabse bade eigenvalue se correspond karta hai.
PCA mein eigenvalue kya represent karta hai?
Corresponding principal component dwara captured variance; bada eigenvalue = zyada variance explained.
PCA ke liye covariance matrix kaise compute karte hain?
jahan centered data matrix hai (rows samples hain, columns features hain).
Principal components orthogonal kyun hote hain?
(1) Distinct eigenvalues wale symmetric matrices ke eigenvectors orthogonal hote hain. (2) Ensure karta hai ki har PC independent variance capture kare, koi redundancy nahi.
Pehle k principal components par data project kaise karte hain?
jahan mein pehle k eigenvectors columns ke roop mein hain.
PCA mein reconstruction formula kya hai?
, phir mean wapas add karo: .
k components rakhne par reconstruction error kya hota hai?
— discarded eigenvalues ka sum squared error ke barabar hota hai.
k components kitni variance explain karte hain?
— rakhe gaye eigenvalues ke sum ka total sum se ratio.
Kya PCA feature selection hai ya feature extraction?
Feature extraction; yeh nayi features create karta hai (sab originals ke linear combinations), koi subset select nahi karta.
PCA se pehle features standardize kyun karte hain?
Kyunki PCA scale-invariant nahi hai; bade numeric scales wale features variance mein dominate karte hain. Standardizing sab features ko barabar footing par laata hai.
Covariance-based aur correlation-based PCA mein kya fark hai?
Covariance PCA raw data use karta hai; correlation PCA standardized data use karta hai (correlation matrix ke eigenvectors compute karne ke equivalent). Correlation use karo jab features alag units mein hon.
SVD ka PCA se kya relation hai?
; principal components right singular vectors hain, eigenvalues hain. Zyada numerically stable hai.
PC space mein covariance structure kya hoti hai?
Diagonal — . Principal components construction se uncorrelated hote hain.

Concept Map

center by mean

compute

of projections

variance equals

constrained w unit norm

yields

solutions are

eigen-decomposition

ordered by eigenvalue

orthogonal for

keep top k

no redundancy

High-dim data X

Centered data Xc

Covariance matrix C

Maximize variance

Projection z = wTx

wT C w

Lagrangian optimization

Eigenvector equation C w = lambda w

Principal components

Eigenvalue lambda equals variance

Independent variation

Dimensionality reduction