Machine Learning 📂 Dimensionality reduction · 2 of 3 129 min read

PCA Dimensional Reduction Numerical

🌐
SectionSection第 01 节

The Story That Explains PCAवह कहानी जो PCA समझाती है一个解释 PCA 的故事

Projecting a Shadow on the Wallदीवार पर परछाई डालना把影子投到墙上
Imagine you are holding a 3D sculpture and shining a torch at it from different angles. Depending on the angle, the shadow on the wall captures more or less of the sculpture's interesting shape. From some angles, the shadow is just a thin line — almost no information. From one special angle, the shadow captures the widest, most descriptive outline of the object.

PCA finds that special angle. It rotates your coordinate system so the first new axis — called the first principal component — points in the direction of maximum variance in your data. The shadow on that axis contains as much information as possible. Each subsequent component captures the next highest variance, perpendicular to all previous ones.

The result: you can describe your data in fewer dimensions while losing as little information as possible.
कल्पना करें कि आपके हाथ में एक 3D मूर्ति है और आप उस पर अलग-अलग कोणों से torch की रोशनी डाल रहे हैं। कोण के हिसाब से, दीवार पर पड़ी परछाई मूर्ति के दिलचस्प आकार का कम या ज़्यादा हिस्सा दिखाती है। कुछ कोणों से परछाई बस एक पतली line होती है — लगभग कोई जानकारी नहीं। एक ख़ास कोण से परछाई चीज़ की सबसे चौड़ी और सबसे साफ़ रूपरेखा दिखाती है।

PCA वही ख़ास कोण खोजता है। यह आपके coordinate system को घुमाता है ताकि पहला नया axis — जिसे first principal component कहते हैं — आपके data में maximum variance की दिशा में हो। उस axis पर पड़ी परछाई में जितनी हो सके उतनी जानकारी होती है। हर अगला component बचा हुआ सबसे ज़्यादा variance पकड़ता है, और पिछले सभी components से 90° (perpendicular) पर होता है।

नतीजा: आप अपने data को कम dimensions में लिख सकते हैं और बहुत कम जानकारी खोते हैं।
想象你手里拿着一座三维雕塑,从不同的角度用手电筒照它。 角度不同,墙上的影子能表现出雕塑有趣形状的多少也不同。 从某些角度看,影子只是一条细线 —— 几乎没有信息。 而从某一个特殊角度看,影子能呈现出物体最宽、最有代表性的轮廓。

PCA 找的就是这个特殊角度。它旋转你的坐标系,使第一条新坐标轴 —— 叫作第一主成分(first principal component)—— 指向数据中方差最大(maximum variance)的方向。 投在这条轴上的影子包含尽可能多的信息。之后的每个主成分捕获剩下最大的方差,并且与之前所有主成分互相垂直。

结果是:你可以用更少的维度描述数据,同时尽可能少地丢失信息。

Principal Component Analysis (PCA) is an unsupervised linear transformation that projects data onto a new set of orthogonal axes (principal components), ordered by the amount of variance they explain. It is the workhorse of dimensionality reduction — used in data visualisation, noise filtering, feature extraction, and preprocessing before clustering or classification.

Principal Component Analysis (PCA) एक unsupervised linear transformation है जो data को नए orthogonal axes (principal components) पर project करता है, और इन axes को इस क्रम में रखता है कि हर एक कितना variance समझाता है। यह dimensionality reduction का सबसे भरोसेमंद औज़ार है — इसका इस्तेमाल data visualisation, noise filtering, feature extraction, और clustering या classification से पहले preprocessing में होता है।

主成分分析(Principal Component Analysis,PCA)是一种无监督(unsupervised)的线性变换。 它把数据投影到一组新的正交(orthogonal)坐标轴上,这些轴就是主成分(principal components), 并按各自解释的方差大小排序。它是降维(dimensionality reduction)的主力工具,常用于 数据可视化、噪声过滤、特征提取(feature extraction),以及聚类或分类之前的预处理。

💡
The Core Goalमुख्य लक्ष्य核心目标

Given a dataset with p features, find a new set of k < p axes (principal components) such that the projected data retains maximum variance. The original p-dimensional data is represented in k dimensions with minimal information loss.

p features वाले dataset के लिए, k < p axes (principal components) का ऐसा नया set खोजें कि project किया गया data ज़्यादा से ज़्यादा variance बचाए। Original p-dimensional data को k dimensions में, कम से कम जानकारी खोकर, लिखा जाता है।

给定一个有 p 个特征(features)的数据集,找到一组新的 k < p 条坐标轴(主成分), 使投影后的数据保留最大的方差。原来的 p 维数据就能用 k 维表示,而信息损失最小。


SectionSection第 02 节

The Problem — Dataset & Goalसमस्या — Dataset और लक्ष्य问题 — 数据集与目标

We have a small dataset with 4 samples and 2 features (x₁, x₂). The goal is to reduce it from 2D to 1D using PCA, retaining the maximum variance possible. We will solve every step by hand — exactly as you would in a Data Science exam notebook.

हमारे पास एक छोटा dataset है जिसमें 4 samples और 2 features (x₁, x₂) हैं। लक्ष्य है PCA से इसे 2D से 1D में घटाना, और जितना हो सके उतना variance बचाना। हम हर step हाथ से हल करेंगे — ठीक वैसे जैसे आप Data Science की exam copy में करते हैं।

我们有一个小数据集,包含 4 个样本(samples)和 2 个特征(x₁, x₂)。 目标是用 PCA 把它从二维降到一维,并尽可能多地保留方差。我们会手算每一步 —— 就像在数据科学考试的答题本上那样。

📋 Given Dataset — X (4 samples × 2 features)दिया गया Dataset — X (4 samples × 2 features)已知数据集 — X(4 个样本 × 2 个特征)
S1
x₁ = 1, x₂ = 2 x₁ = 1, x₂ = 2 x₁ = 1,x₂ = 2
S2
x₁ = 3, x₂ = 4 x₁ = 3, x₂ = 4 x₁ = 3,x₂ = 4
S3
x₁ = 5, x₂ = 4 x₁ = 5, x₂ = 4 x₁ = 5,x₂ = 4
S4
x₁ = 3, x₂ = 6 x₁ = 3, x₂ = 6 x₁ = 3,x₂ = 6
SampleSample样本Feature x₁Feature x₁特征 x₁Feature x₂Feature x₂特征 x₂
S112
S234
S354
S436
✍️
PCA Roadmap — 7 StepsPCA Roadmap — 7 StepsPCA 路线图 — 7 个步骤

① Compute the mean of each feature  →  ② Mean-centre the data  →  ③ Compute the covariance matrix  →  ④ Solve for eigenvalues  →  ⑤ Compute eigenvectors  →  ⑥ Select principal components (explained variance)  →  ⑦ Project data onto chosen components

① हर feature का mean निकालें  →  ② Data को mean-centre करें  →  ③ Covariance matrix निकालें  →  ④ Eigenvalues हल करें  →  ⑤ Eigenvectors निकालें  →  ⑥ Principal components चुनें (explained variance)  →  ⑦ Data को चुने हुए components पर project करें

① 计算每个特征的均值(mean)  →  ② 对数据做均值中心化(mean-centre)  →  ③ 计算协方差矩阵(covariance matrix)  →  ④ 求特征值(eigenvalues)  →  ⑤ 求特征向量(eigenvectors)  →  ⑥ 选择主成分(解释方差,explained variance)  →  ⑦ 把数据投影到选中的主成分上


SectionSection第 03 节

Step 1 — Compute the Mean of Each FeatureStep 1 — हर Feature का Mean निकालें第 1 步 — 计算每个特征的均值

PCA is sensitive to the spread of data, not its absolute position. We must first shift the data so it is centred at the origin. Before that, we need the mean of each feature.

PCA data के फैलाव (spread) पर ध्यान देता है, उसकी असली जगह पर नहीं। इसलिए पहले हमें data को खिसकाना होगा ताकि उसका केंद्र origin पर आ जाए। उससे पहले हमें हर feature का mean चाहिए।

PCA 关心的是数据的散布(spread),而不是它的绝对位置。 所以我们必须先平移数据,使它以原点为中心。 在此之前,我们需要每个特征的均值。

FormulaFormula公式: x̄ⱼ = (1/n) × Σᵢ xᵢⱼ
Mean of feature x₁:
x̄₁ = (x₁₁ + x₂₁ + x₃₁ + x₄₁) / 4
x̄₁ = (1 + 3 + 5 + 3) / 4
x̄₁ = 12 / 4
x̄₁ = 3

Mean of feature x₂:
x̄₂ = (x₁₂ + x₂₂ + x₃₂ + x₄₂) / 4
x̄₂ = (2 + 4 + 4 + 6) / 4
x̄₂ = 16 / 4
x̄₂ = 4

Mean vector: μ = [3, 4]
Feature x₁ का mean:
x̄₁ = (x₁₁ + x₂₁ + x₃₁ + x₄₁) / 4
x̄₁ = (1 + 3 + 5 + 3) / 4
x̄₁ = 12 / 4
x̄₁ = 3

Feature x₂ का mean:
x̄₂ = (x₁₂ + x₂₂ + x₃₂ + x₄₂) / 4
x̄₂ = (2 + 4 + 4 + 6) / 4
x̄₂ = 16 / 4
x̄₂ = 4

Mean vector: μ = [3, 4]
特征 x₁ 的均值:
x̄₁ = (x₁₁ + x₂₁ + x₃₁ + x₄₁) / 4
x̄₁ = (1 + 3 + 5 + 3) / 4
x̄₁ = 12 / 4
x̄₁ = 3

特征 x₂ 的均值:
x̄₂ = (x₁₂ + x₂₂ + x₃₂ + x₄₂) / 4
x̄₂ = (2 + 4 + 4 + 6) / 4
x̄₂ = 16 / 4
x̄₂ = 4

均值向量:μ = [3, 4]
Mean of x₁x₁ का Meanx₁ 的均值
x̄₁ = 12 / 4 = 3
Sum of all x₁ values divided by number of samples (n = 4)
सभी x₁ values का जोड़, samples की संख्या (n = 4) से भाग
所有 x₁ 值之和除以样本数(n = 4)
Mean of x₂x₂ का Meanx₂ 的均值
x̄₂ = 16 / 4 = 4
Sum of all x₂ values divided by number of samples (n = 4)
सभी x₂ values का जोड़, samples की संख्या (n = 4) से भाग
所有 x₂ 值之和除以样本数(n = 4)

SectionSection第 04 节

Step 2 — Mean-Centre the Data (Subtract the Mean)Step 2 — Data को Mean-Centre करें (Mean घटाएँ)第 2 步 — 数据均值中心化(减去均值)

We subtract the mean vector μ = [3, 4] from every data point to produce the centred matrix B. This shifts the data cloud so its centroid sits exactly at the origin — a prerequisite for covariance analysis.

हम हर data point में से mean vector μ = [3, 4] घटाते हैं और centred matrix B बनाते हैं। इससे data का बादल खिसक जाता है और उसका केंद्र (centroid) ठीक origin पर आ जाता है — covariance निकालने के लिए यह ज़रूरी है।

我们从每个数据点中减去均值向量 μ = [3, 4],得到中心化矩阵 B。 这样数据点云整体平移,它的中心(centroid)正好落在原点 —— 这是计算协方差的前提。

Formula: B = X − μ (subtract mean row-by-row)Formula: B = X − μ (हर row से mean घटाएँ)公式:B = X − μ(逐行减去均值)
B₁ = (1 − 3, 2 − 4) = (−2, −2)
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
B₁ = (1 − 3, 2 − 4) = (−2, −2)
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
B₁ = (1 − 3, 2 − 4) = (−2, −2)
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
Original Matrix XOriginal Matrix X原始矩阵 X
SampleSample样本x₁x₂
S112
S234
S354
S436
Centred Matrix B = X − μCentred Matrix B = X − μ中心化矩阵 B = X − μ
SampleSample样本b₁b₂
S1−2−2
S2 0 0
S3 2 0
S4 0 2
✓
Sanity Check — Column Sums Must Equal Zeroजाँच — हर Column का जोड़ Zero होना चाहिए自检 — 每列之和必须为零

Sum of b₁: −2 + 0 + 2 + 0 = 0 ✓
Sum of b₂: −2 + 0 + 0 + 2 = 0 ✓
If either sum ≠ 0, you've made an arithmetic error in the mean or subtraction.

b₁ का जोड़: −2 + 0 + 2 + 0 = 0 ✓
b₂ का जोड़: −2 + 0 + 0 + 2 = 0 ✓
अगर कोई भी जोड़ ≠ 0 है, तो mean या घटाने में हिसाब की गलती हुई है।

b₁ 之和:−2 + 0 + 2 + 0 = 0 ✓
b₂ 之和:−2 + 0 + 0 + 2 = 0 ✓
如果任何一个和 ≠ 0,说明均值或减法算错了。


SectionSection第 05 节

Step 3 — Compute the Covariance MatrixStep 3 — Covariance Matrix निकालें第 3 步 — 计算协方差矩阵

The covariance matrix C captures how much each pair of features varies together. It is a symmetric p × p matrix. For our 2-feature dataset it is 2 × 2.

Covariance matrix C बताता है कि features का हर जोड़ा साथ-साथ कितना बदलता है। यह एक symmetric p × p matrix है। हमारे 2-feature dataset के लिए यह 2 × 2 है।

协方差矩阵 C 描述每一对特征一起变化的程度。它是一个对称的 p × p 矩阵。 我们的数据集有 2 个特征,所以它是 2 × 2。

📚
FormulaFormula公式

C = (1 / (n−1)) × BᵀB
where B is the mean-centred matrix and n is the number of samples. We divide by (n−1) for the unbiased sample covariance estimate. With n = 4, the divisor is 3.

C = (1 / (n−1)) × BᵀB
जहाँ B mean-centred matrix है और n samples की संख्या है। Unbiased sample covariance के लिए हम (n−1) से भाग देते हैं। n = 4 है, इसलिए भाजक 3 है।

C = (1 / (n−1)) × BᵀB
其中 B 是中心化后的矩阵,n 是样本数。 除以 (n−1) 是为了得到无偏(unbiased)的样本协方差估计。 n = 4,所以除数是 3。

Matrix Multiplication: Bᵀ (2×4) × B (4×2) → BᵀB (2×2)Matrix गुणा: Bᵀ (2×4) × B (4×2) → BᵀB (2×2)矩阵乘法:Bᵀ (2×4) × B (4×2) → BᵀB (2×2)
Bᵀ =
Row 1 (b₁ column): [−2, 0, 2, 0]
Row 2 (b₂ column): [−2, 0, 0, 2]

BᵀB[1,1] = (−2)(−2) + (0)(0) + (2)(2) + (0)(0) = 4 + 0 + 4 + 0 = 8
BᵀB[1,2] = (−2)(−2) + (0)(0) + (2)(0) + (0)(2) = 4 + 0 + 0 + 0 = 4
BᵀB[2,1] = (−2)(−2) + (0)(0) + (0)(2) + (2)(0) = 4 + 0 + 0 + 0 = 4
BᵀB[2,2] = (−2)(−2) + (0)(0) + (0)(0) + (2)(2) = 4 + 0 + 0 + 4 = 8

BᵀB = [[8, 4], [4, 8]]
Bᵀ =
Row 1 (b₁ column): [−2, 0, 2, 0]
Row 2 (b₂ column): [−2, 0, 0, 2]

BᵀB[1,1] = (−2)(−2) + (0)(0) + (2)(2) + (0)(0) = 4 + 0 + 4 + 0 = 8
BᵀB[1,2] = (−2)(−2) + (0)(0) + (2)(0) + (0)(2) = 4 + 0 + 0 + 0 = 4
BᵀB[2,1] = (−2)(−2) + (0)(0) + (0)(2) + (2)(0) = 4 + 0 + 0 + 0 = 4
BᵀB[2,2] = (−2)(−2) + (0)(0) + (0)(0) + (2)(2) = 4 + 0 + 0 + 4 = 8

BᵀB = [[8, 4], [4, 8]]
Bᵀ =
第 1 行(b₁ 列):[−2, 0, 2, 0]
第 2 行(b₂ 列):[−2, 0, 0, 2]

BᵀB[1,1] = (−2)(−2) + (0)(0) + (2)(2) + (0)(0) = 4 + 0 + 4 + 0 = 8
BᵀB[1,2] = (−2)(−2) + (0)(0) + (2)(0) + (0)(2) = 4 + 0 + 0 + 0 = 4
BᵀB[2,1] = (−2)(−2) + (0)(0) + (0)(2) + (2)(0) = 4 + 0 + 0 + 0 = 4
BᵀB[2,2] = (−2)(−2) + (0)(0) + (0)(0) + (2)(2) = 4 + 0 + 0 + 4 = 8

BᵀB = [[8, 4], [4, 8]]
C = (1/3) × BᵀB
C = (1/3) × [[8, 4], [4, 8]]

C[1,1] = 8/3 ≈ 2.667    ← Variance of x₁
C[1,2] = 4/3 ≈ 1.333    ← Covariance of x₁ and x₂
C[2,1] = 4/3 ≈ 1.333    ← Covariance of x₂ and x₁ (symmetric)
C[2,2] = 8/3 ≈ 2.667    ← Variance of x₂

C = [[8/3, 4/3], [4/3, 8/3]]
C = (1/3) × [[8, 4], [4, 8]]

C[1,1] = 8/3 ≈ 2.667    ← x₁ का variance
C[1,2] = 4/3 ≈ 1.333    ← x₁ और x₂ का covariance
C[2,1] = 4/3 ≈ 1.333    ← x₂ और x₁ का covariance (symmetric)
C[2,2] = 8/3 ≈ 2.667    ← x₂ का variance

C = [[8/3, 4/3], [4/3, 8/3]]
C = (1/3) × [[8, 4], [4, 8]]

C[1,1] = 8/3 ≈ 2.667    ← x₁ 的方差
C[1,2] = 4/3 ≈ 1.333    ← x₁ 与 x₂ 的协方差
C[2,1] = 4/3 ≈ 1.333    ← x₂ 与 x₁ 的协方差(对称)
C[2,2] = 8/3 ≈ 2.667    ← x₂ 的方差

C = [[8/3, 4/3], [4/3, 8/3]]
Covariance Matrix CCovariance Matrix C协方差矩阵 Cx₁x₂
x₁8/3 ≈ 2.6674/3 ≈ 1.333
x₂4/3 ≈ 1.3338/3 ≈ 2.667
🔑
Reading the Covariance MatrixCovariance Matrix कैसे पढ़ें如何解读协方差矩阵

Diagonal entries (C[1,1] and C[2,2]) = variance of each feature individually. Off-diagonal entries (C[1,2] = C[2,1]) = how much x₁ and x₂ change together. A positive off-diagonal (1.333) means as x₁ increases, x₂ tends to increase too — they are positively correlated. If the matrix were diagonal, features would be uncorrelated and PCA would produce the original axes unchanged.

Diagonal entries (C[1,1] और C[2,2]) = हर feature का अपना variance. Off-diagonal entries (C[1,2] = C[2,1]) = x₁ और x₂ साथ-साथ कितना बदलते हैं। Positive off-diagonal (1.333) का मतलब है कि x₁ बढ़ने पर x₂ भी बढ़ने की ओर जाता है — दोनों positively correlated हैं। अगर matrix diagonal होता, तो features uncorrelated होते और PCA वही original axes बिना बदले लौटा देता।

对角线元素(C[1,1] 和 C[2,2])= 每个特征各自的方差。 非对角线元素(C[1,2] = C[2,1])= x₁ 和 x₂ 一起变化的程度。 非对角线为正(1.333)表示 x₁ 增大时 x₂ 也倾向于增大 —— 两者正相关。 如果矩阵是对角矩阵,特征之间就不相关,PCA 得到的就是原来的坐标轴,不会改变。


SectionSection第 06 节

Step 4 — Solve for EigenvaluesStep 4 — Eigenvalues हल करें第 4 步 — 求特征值

The eigenvalues of the covariance matrix tell us how much variance each principal component explains. We find them by solving the characteristic equation: det(C − λI) = 0

Covariance matrix के eigenvalues बताते हैं कि हर principal component कितना variance समझाता है। इन्हें हम characteristic equation हल करके निकालते हैं: det(C − λI) = 0

协方差矩阵的特征值(eigenvalues)告诉我们每个主成分解释了多少方差。 我们通过求解特征方程(characteristic equation)得到它们:det(C − λI) = 0

Subtract λ from the diagonal, take the determinant, set to zeroDiagonal से λ घटाएँ, determinant लें, zero के बराबर रखें对角线减去 λ,求行列式,令其为零
C − λI = [[8/3 − λ, 4/3], [4/3, 8/3 − λ]]

det(C − λI) = (8/3 − λ)(8/3 − λ) − (4/3)(4/3)
              = (8/3 − λ)² − 16/9

Set equal to zero:
(8/3 − λ)² − 16/9 = 0
(8/3 − λ)² = 16/9
8/3 − λ = ± 4/3
C − λI = [[8/3 − λ, 4/3], [4/3, 8/3 − λ]]

det(C − λI) = (8/3 − λ)(8/3 − λ) − (4/3)(4/3)
              = (8/3 − λ)² − 16/9

Zero के बराबर रखें:
(8/3 − λ)² − 16/9 = 0
(8/3 − λ)² = 16/9
8/3 − λ = ± 4/3
C − λI = [[8/3 − λ, 4/3], [4/3, 8/3 − λ]]

det(C − λI) = (8/3 − λ)(8/3 − λ) − (4/3)(4/3)
              = (8/3 − λ)² − 16/9

令其等于零:
(8/3 − λ)² − 16/9 = 0
(8/3 − λ)² = 16/9
8/3 − λ = ± 4/3
Two solutions from the ± sign± चिह्न से दो हल± 号带来两个解
Case 1 (positive sign):
8/3 − λ = +4/3
λ = 8/3 − 4/3 = 4/3

Case 2 (negative sign):
8/3 − λ = −4/3
λ = 8/3 + 4/3 = 12/3 = 4

We sort largest first:
λ₁ = 4    (larger → PC1)
λ₂ = 4/3 ≈ 1.333    (smaller → PC2)
Case 1 (positive चिह्न):
8/3 − λ = +4/3
λ = 8/3 − 4/3 = 4/3

Case 2 (negative चिह्न):
8/3 − λ = −4/3
λ = 8/3 + 4/3 = 12/3 = 4

बड़े से छोटे क्रम में रखें:
λ₁ = 4    (बड़ा → PC1)
λ₂ = 4/3 ≈ 1.333    (छोटा → PC2)
情况 1(取正号):
8/3 − λ = +4/3
λ = 8/3 − 4/3 = 4/3

情况 2(取负号):
8/3 − λ = −4/3
λ = 8/3 + 4/3 = 12/3 = 4

按从大到小排序:
λ₁ = 4   (较大 → PC1)
λ₂ = 4/3 ≈ 1.333   (较小 → PC2)
λ₁
Eigenvalue 1Eigenvalue 1特征值 1
λ₁ = 4.000
Corresponds to the first principal component (PC1). Larger value = more variance captured.
पहले principal component (PC1) से जुड़ा है। बड़ी value = ज़्यादा variance पकड़ा गया।
对应第一主成分(PC1)。数值越大 = 捕获的方差越多。
λ₂
Eigenvalue 2Eigenvalue 2特征值 2
λ₂ = 4/3 ≈ 1.333
Corresponds to the second principal component (PC2). Smaller value = less variance.
दूसरे principal component (PC2) से जुड़ा है। छोटी value = कम variance.
对应第二主成分(PC2)。数值越小 = 方差越少。
Σλ
Total Varianceकुल Variance总方差
4 + 4/3 = 16/3 ≈ 5.333
Sum of all eigenvalues equals total variance in the dataset. Used to compute explained variance %.
सभी eigenvalues का जोड़ dataset के कुल variance के बराबर है। Explained variance % निकालने में इसका इस्तेमाल होता है।
所有特征值之和等于数据集的总方差,用于计算解释方差百分比。
⚠️
Common Mistake — Always Sort Eigenvalues Descendingआम गलती — Eigenvalues को हमेशा बड़े से छोटे क्रम में रखें常见错误 — 特征值一定要按降序排列

PCA requires eigenvalues to be sorted from largest to smallest. PC1 always corresponds to the largest eigenvalue (most variance), PC2 to the second largest, and so on. Never assign PCs in the order the solver returns them without sorting first.

PCA में eigenvalues को सबसे बड़े से सबसे छोटे क्रम में रखना ज़रूरी है। PC1 हमेशा सबसे बड़े eigenvalue (सबसे ज़्यादा variance) से जुड़ा होता है, PC2 दूसरे सबसे बड़े से, और इसी तरह आगे। Solver जिस क्रम में values लौटाए, बिना sort किए उसी क्रम में PCs कभी न दें।

PCA 要求特征值按从大到小排序。 PC1 总是对应最大的特征值(方差最多),PC2 对应第二大的,依此类推。 不要不排序就直接按求解器返回的顺序来分配主成分。


SectionSection第 07 节

Step 5 — Compute Eigenvectors (Principal Directions)Step 5 — Eigenvectors निकालें (Principal दिशाएँ)第 5 步 — 求特征向量(主方向)

Eigenvectors give us the directions of the new axes. For each eigenvalue λ, we solve (C − λI)v = 0 and then normalise the resulting vector to unit length.

Eigenvectors हमें नए axes की दिशाएँ देते हैं। हर eigenvalue λ के लिए हम (C − λI)v = 0 हल करते हैं और फिर मिले vector को unit length पर normalise करते हैं।

特征向量给出新坐标轴的方向。 对每个特征值 λ,我们求解 (C − λI)v = 0,再把得到的向量归一化(normalise)为单位长度。

(C − 4I)v = 0 → Find the null space(C − 4I)v = 0 → Null space खोजें(C − 4I)v = 0 → 求零空间
C − 4I = [[8/3 − 4, 4/3], [4/3, 8/3 − 4]]
         = [[8/3 − 12/3, 4/3], [4/3, 8/3 − 12/3]]
         = [[−4/3, 4/3], [4/3, −4/3]]

Take row 1:   −4/3 · v₁ + 4/3 · v₂ = 0
             → −v₁ + v₂ = 0
             → v₁ = v₂

Choose v = [1, 1], then normalise:
‖v‖ = √(1² + 1²) = √2
e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]
C − 4I = [[8/3 − 4, 4/3], [4/3, 8/3 − 4]]
         = [[8/3 − 12/3, 4/3], [4/3, 8/3 − 12/3]]
         = [[−4/3, 4/3], [4/3, −4/3]]

Row 1 लें:   −4/3 · v₁ + 4/3 · v₂ = 0
             → −v₁ + v₂ = 0
             → v₁ = v₂

v = [1, 1] चुनें, फिर normalise करें:
‖v‖ = √(1² + 1²) = √2
e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]
C − 4I = [[8/3 − 4, 4/3], [4/3, 8/3 − 4]]
         = [[8/3 − 12/3, 4/3], [4/3, 8/3 − 12/3]]
         = [[−4/3, 4/3], [4/3, −4/3]]

取第 1 行:  −4/3 · v₁ + 4/3 · v₂ = 0
             → −v₁ + v₂ = 0
             → v₁ = v₂

取 v = [1, 1],再归一化:
‖v‖ = √(1² + 1²) = √2
e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]
(C − 4/3 · I)v = 0 → Find the null space(C − 4/3 · I)v = 0 → Null space खोजें(C − 4/3 · I)v = 0 → 求零空间
C − (4/3)I = [[8/3 − 4/3, 4/3], [4/3, 8/3 − 4/3]]
            = [[4/3, 4/3], [4/3, 4/3]]

Take row 1:   4/3 · v₁ + 4/3 · v₂ = 0
             → v₁ + v₂ = 0
             → v₁ = −v₂

Choose v = [1, −1], then normalise:
‖v‖ = √(1² + (−1)²) = √2
e₂ = [1/√2, −1/√2] ≈ [0.707, −0.707]
C − (4/3)I = [[8/3 − 4/3, 4/3], [4/3, 8/3 − 4/3]]
            = [[4/3, 4/3], [4/3, 4/3]]

Row 1 लें:   4/3 · v₁ + 4/3 · v₂ = 0
             → v₁ + v₂ = 0
             → v₁ = −v₂

v = [1, −1] चुनें, फिर normalise करें:
‖v‖ = √(1² + (−1)²) = √2
e₂ = [1/√2, −1/√2] ≈ [0.707, −0.707]
C − (4/3)I = [[8/3 − 4/3, 4/3], [4/3, 8/3 − 4/3]]
            = [[4/3, 4/3], [4/3, 4/3]]

取第 1 行:  4/3 · v₁ + 4/3 · v₂ = 0
             → v₁ + v₂ = 0
             → v₁ = −v₂

取 v = [1, −1],再归一化:
‖v‖ = √(1² + (−1)²) = √2
e₂ = [1/√2, −1/√2] ≈ [0.707, −0.707]
➡
PC1 DirectionPC1 की दिशाPC1 的方向
e₁ = [0.707, 0.707]
Points diagonally up-right at 45°. This is the direction in feature space along which the data spreads the most. Both features contribute equally and positively to this component.
45° पर तिरछा ऊपर-दाईं ओर इशारा करता है। Feature space में यही वह दिशा है जिसमें data सबसे ज़्यादा फैला है। दोनों features इस component में बराबर और positive योगदान देते हैं।
沿 45° 斜向右上方。这是特征空间中数据散布最大的方向。两个特征对这个主成分的贡献相等且为正。
←
PC2 DirectionPC2 की दिशाPC2 的方向
e₂ = [0.707, −0.707]
Orthogonal to PC1, pointing diagonally down-right at −45°. Captures the remaining variance. One feature is positive, the other negative — it captures the contrast between them.
PC1 से 90° पर, −45° पर तिरछा नीचे-दाईं ओर। बचा हुआ variance पकड़ता है। एक feature positive है, दूसरा negative — यह दोनों के बीच का अंतर (contrast) पकड़ता है।
与 PC1 垂直,沿 −45° 斜向右下方,捕获剩余的方差。一个特征为正,另一个为负 —— 它捕获的是两者之间的差异(contrast)。
☉
Orthogonality CheckOrthogonality जाँच正交性检验
e₁ · e₂ = 0
e₁ · e₂ = (0.707)(0.707) + (0.707)(−0.707) = 0.5 − 0.5 = 0 ✓
Principal components are always perpendicular to each other. Non-zero dot product means calculation error.
e₁ · e₂ = (0.707)(0.707) + (0.707)(−0.707) = 0.5 − 0.5 = 0 ✓
Principal components हमेशा एक-दूसरे से 90° पर होते हैं। Dot product zero न हो तो हिसाब में गलती है।
e₁ · e₂ = (0.707)(0.707) + (0.707)(−0.707) = 0.5 − 0.5 = 0 ✓
主成分之间总是互相垂直。点积不为零说明计算有错。

SectionSection第 08 节

Step 6 — Explained Variance & Choosing ComponentsStep 6 — Explained Variance और Components चुनना第 6 步 — 解释方差与选择主成分

The eigenvalue tells us how much variance each principal component captures. We express this as a percentage of total variance to decide how many components to keep. This is the heart of the dimensionality reduction decision.

Eigenvalue बताता है कि हर principal component कितना variance पकड़ता है। कितने components रखने हैं, यह तय करने के लिए हम इसे कुल variance के प्रतिशत में लिखते हैं। Dimensionality reduction के फ़ैसले का यही दिल है।

特征值告诉我们每个主成分捕获了多少方差。我们把它写成占总方差的百分比, 以决定保留几个主成分。这是降维决策的核心。

Formula: Explained Variance (PCₖ) = λₖ / Σλᵢ × 100%Formula: Explained Variance (PCₖ) = λₖ / Σλᵢ × 100%公式:解释方差 (PCₖ) = λₖ / Σλᵢ × 100%
Total variance:
Σλ = λ₁ + λ₂ = 4 + 4/3 = 12/3 + 4/3 = 16/3 ≈ 5.333

PC1 explained variance:
EV₁ = λ₁ / Σλ = 4 / (16/3) = 4 × (3/16) = 12/16 = 3/4 = 75.0 %

PC2 explained variance:
EV₂ = λ₂ / Σλ = (4/3) / (16/3) = 4/16 = 1/4 = 25.0 %

Cumulative (PC1 + PC2) = 75% + 25% = 100% ✓
कुल variance:
Σλ = λ₁ + λ₂ = 4 + 4/3 = 12/3 + 4/3 = 16/3 ≈ 5.333

PC1 का explained variance:
EV₁ = λ₁ / Σλ = 4 / (16/3) = 4 × (3/16) = 12/16 = 3/4 = 75.0 %

PC2 का explained variance:
EV₂ = λ₂ / Σλ = (4/3) / (16/3) = 4/16 = 1/4 = 25.0 %

Cumulative (PC1 + PC2) = 75% + 25% = 100% ✓
总方差:
Σλ = λ₁ + λ₂ = 4 + 4/3 = 12/3 + 4/3 = 16/3 ≈ 5.333

PC1 的解释方差:
EV₁ = λ₁ / Σλ = 4 / (16/3) = 4 × (3/16) = 12/16 = 3/4 = 75.0 %

PC2 的解释方差:
EV₂ = λ₂ / Σλ = (4/3) / (16/3) = 4/16 = 1/4 = 25.0 %

累计(PC1 + PC2)= 75% + 25% = 100% ✓
ComponentComponent主成分EigenvalueEigenvalue特征值Explained VarianceExplained Variance解释方差Cumulative VarianceCumulative Variance累计方差Keep?रखें?保留?
PC14.00075.0 %75.0 %YESहाँ是
PC21.33325.0 %100.0 %OPTIONALवैकल्पिक可选
🎯
Decision — Keep 1 Componentफ़ैसला — 1 Component रखें决定 — 保留 1 个主成分

PC1 alone captures 75% of the total variance. By keeping only 1 component we reduce the data from 2D to 1D, losing just 25% of the information. In practice, a threshold of ≥ 95% cumulative variance is common for larger datasets. For this demo, we proceed with PC1 only.

अकेला PC1 कुल variance का 75% पकड़ता है। सिर्फ़ 1 component रखकर हम data को 2D से 1D में घटाते हैं और सिर्फ़ 25% जानकारी खोते हैं। व्यवहार में, बड़े datasets के लिए ≥ 95% cumulative variance की सीमा आम है। इस demo में हम सिर्फ़ PC1 के साथ आगे बढ़ते हैं।

仅 PC1 就捕获了总方差的 75%。只保留 1 个主成分, 我们就把数据从二维降到一维,只损失 25% 的信息。 实际中,对于较大的数据集,常用的门槛是累计方差 ≥ 95%。 在这个演示中,我们只保留 PC1。


SectionSection第 09 节

Step 7 — Project Data onto PC1 (Reduce to 1D)Step 7 — Data को PC1 पर Project करें (1D में घटाएँ)第 7 步 — 把数据投影到 PC1(降到一维)

We now project the mean-centred data matrix B onto the first principal component direction e₁. The projection is simply a dot product: multiply each centred data row by the eigenvector.

अब हम mean-centred data matrix B को पहले principal component की दिशा e₁ पर project करते हैं। Projection बस एक dot product है: हर centred data row को eigenvector से गुणा करें।

现在我们把中心化后的数据矩阵 B 投影(project)到第一主成分方向 e₁ 上。 投影就是一个点积(dot product):用每一行中心化数据乘以特征向量。

Formula: Z = B · e₁ where e₁ = [1/√2, 1/√2]Formula: Z = B · e₁ जहाँ e₁ = [1/√2, 1/√2]公式:Z = B · e₁,其中 e₁ = [1/√2, 1/√2]
Remember B = [[−2,−2], [0,0], [2,0], [0,2]] and e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]

Z₁ = (−2)(1/√2) + (−2)(1/√2) = −2/√2 − 2/√2 = −4/√2 = −4 × (√2/2) = −2√2 ≈ −2.828

Z₂ = (0)(1/√2) + (0)(1/√2) = 0 + 0 = 0.000

Z₃ = (2)(1/√2) + (0)(1/√2) = 2/√2 + 0 = 2/√2 = √2 ≈ 1.414

Z₄ = (0)(1/√2) + (2)(1/√2) = 0 + 2/√2 = 2/√2 = √2 ≈ 1.414

Projected Data Z = [−2.828, 0, 1.414, 1.414]
याद रखें B = [[−2,−2], [0,0], [2,0], [0,2]] और e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]

Z₁ = (−2)(1/√2) + (−2)(1/√2) = −2/√2 − 2/√2 = −4/√2 = −4 × (√2/2) = −2√2 ≈ −2.828

Z₂ = (0)(1/√2) + (0)(1/√2) = 0 + 0 = 0.000

Z₃ = (2)(1/√2) + (0)(1/√2) = 2/√2 + 0 = 2/√2 = √2 ≈ 1.414

Z₄ = (0)(1/√2) + (2)(1/√2) = 0 + 2/√2 = 2/√2 = √2 ≈ 1.414

Project किया गया Data Z = [−2.828, 0, 1.414, 1.414]
回顾 B = [[−2,−2], [0,0], [2,0], [0,2]],e₁ = [1/√2, 1/√2] ≈ [0.707, 0.707]

Z₁ = (−2)(1/√2) + (−2)(1/√2) = −2/√2 − 2/√2 = −4/√2 = −4 × (√2/2) = −2√2 ≈ −2.828

Z₂ = (0)(1/√2) + (0)(1/√2) = 0 + 0 = 0.000

Z₃ = (2)(1/√2) + (0)(1/√2) = 2/√2 + 0 = 2/√2 = √2 ≈ 1.414

Z₄ = (0)(1/√2) + (2)(1/√2) = 0 + 2/√2 = 2/√2 = √2 ≈ 1.414

投影后的数据 Z = [−2.828, 0, 1.414, 1.414]
Original 2D Data (X)Original 2D Data (X)原始二维数据 (X)
SampleSample样本x₁x₂
S112
S234
S354
S436
Reduced 1D Data (Z on PC1)घटाया हुआ 1D Data (PC1 पर Z)降维后的一维数据(PC1 上的 Z)
SampleSample样本PC1 ScorePC1 ScorePC1 得分
S1−2.828
S2 0.000
S3 1.414
S4 1.414
🎉
Result — Dimensionality Reduced!नतीजा — Dimensionality घट गई!结果 — 降维成功!

We successfully transformed 4 data points from 2 dimensions down to 1 dimension, retaining 75% of the total variance. S3 and S4 map to the same PC1 score (1.414) — they overlap in the principal direction, but differ in PC2 (the discarded component). This is the inherent trade-off of dimensionality reduction.

हमने 4 data points को 2 dimensions से 1 dimension में सफलतापूर्वक बदल दिया, और कुल variance का 75% बचाया। S3 और S4 का PC1 score एक ही है (1.414) — principal दिशा में वे एक-दूसरे पर आ जाते हैं, पर PC2 (हटाया गया component) में अलग हैं। Dimensionality reduction में यह समझौता हमेशा रहता है।

我们成功地把 4 个数据点从二维降到了一维,保留了总方差的 75%。 S3 和 S4 的 PC1 得分相同(1.414)—— 它们在主方向上重叠, 但在 PC2(被丢弃的主成分)上不同。这正是降维固有的取舍。


SectionSection第 10 节

Full Solution Summary — One Viewपूरे हल का सार — एक नज़र में完整解答汇总 — 一览

Here is the complete PCA solution in condensed form, exactly as you would write it in a final exam answer:

यह PCA का पूरा हल छोटे रूप में है, ठीक वैसे जैसे आप final exam के जवाब में लिखेंगे:

下面是浓缩版的完整 PCA 解答,就像你在期末考试答卷里写的那样:

📄 Complete Worked Solution at a Glanceपूरा हल एक नज़र में完整解答一览
Step 1
Means: x̄₁ = 3, x̄₂ = 4  →  μ = [3, 4] Means: x̄₁ = 3, x̄₂ = 4  →  μ = [3, 4] 均值:x̄₁ = 3,x̄₂ = 4  →  μ = [3, 4]
Step 2
Centred B: [−2,−2], [0,0], [2,0], [0,2] Centred B: [−2,−2], [0,0], [2,0], [0,2] 中心化 B:[−2,−2], [0,0], [2,0], [0,2]
Step 3
Covariance: C = [[8/3, 4/3], [4/3, 8/3]] Covariance: C = [[8/3, 4/3], [4/3, 8/3]] 协方差:C = [[8/3, 4/3], [4/3, 8/3]]
Step 4
Eigenvalues: λ₁ = 4, λ₂ = 4/3   (from det(C−λI)=0) Eigenvalues: λ₁ = 4, λ₂ = 4/3   (det(C−λI)=0 से) 特征值:λ₁ = 4,λ₂ = 4/3  (由 det(C−λI)=0 得到)
Step 5
Eigenvectors: e₁ = [0.707, 0.707], e₂ = [0.707, −0.707] Eigenvectors: e₁ = [0.707, 0.707], e₂ = [0.707, −0.707] 特征向量:e₁ = [0.707, 0.707],e₂ = [0.707, −0.707]
Step 6
Variance: PC1 = 75%, PC2 = 25%  →  Keep PC1 only Variance: PC1 = 75%, PC2 = 25%  →  सिर्फ़ PC1 रखें 方差:PC1 = 75%,PC2 = 25%  →  只保留 PC1
Step 7
Projection Z: [−2.828, 0.000, 1.414, 1.414] Projection Z: [−2.828, 0.000, 1.414, 1.414] 投影 Z:[−2.828, 0.000, 1.414, 1.414]

SectionSection第 11 节

Key Formulae at a Glanceमुख्य Formulas एक नज़र में关键公式一览

Mean CenteringMean Centering均值中心化
B = X − μ
Subtract the feature-wise mean from every row. Shifts data centroid to origin.
हर row में से हर feature का mean घटाएँ। Data का केंद्र origin पर आ जाता है।
每一行减去对应特征的均值,把数据中心移到原点。
Covariance MatrixCovariance Matrix协方差矩阵
C = BᵀB / (n−1)
Symmetric p×p matrix. Diagonal = variances. Off-diagonal = covariances.
Symmetric p×p matrix. Diagonal = variances. Off-diagonal = covariances.
对称的 p×p 矩阵。对角线 = 方差,非对角线 = 协方差。
Characteristic EquationCharacteristic Equation特征方程
det(C − λI) = 0
Solve for eigenvalues λ. Each λ is the variance explained by its corresponding PC.
Eigenvalues λ हल करें। हर λ अपने PC द्वारा समझाया गया variance है।
求解特征值 λ。每个 λ 就是对应主成分解释的方差。
Eigenvector EquationEigenvector Equation特征向量方程
(C − λI)v = 0
Solve for each eigenvector v. Normalise to unit length: e = v / ‖v‖
हर eigenvector v हल करें। Unit length पर normalise करें: e = v / ‖v‖
求每个特征向量 v,并归一化为单位长度:e = v / ‖v‖
Explained VarianceExplained Variance解释方差
EVₖ = λₖ / Σλᵢ
Fraction of total variance captured by principal component k. Sum to 1 (100%).
Principal component k द्वारा पकड़ा गया कुल variance का हिस्सा। सबका जोड़ 1 (100%)।
第 k 个主成分捕获的总方差比例,全部加起来等于 1(100%)。
ProjectionProjection投影
Z = B · W
W = matrix of selected eigenvectors (columns). Z is the reduced dataset.
W = चुने गए eigenvectors का matrix (columns में)। Z घटाया हुआ dataset है।
W = 由选中的特征向量(作为列)组成的矩阵。Z 是降维后的数据集。

SectionSection第 12 节

Three Concepts Every PCA Student Must Understandतीन बातें जो हर PCA Student को समझनी चाहिए每个学 PCA 的学生都必须理解的三个概念

📈
Variance = InformationVariance = जानकारी方差 = 信息
Why we maximise itहम इसे सबसे ज़्यादा क्यों करते हैं为什么要最大化它
PCA defines "information" as variance. A feature with zero variance tells you nothing — every sample is identical on that axis. The principal component with the most variance is the single axis that spreads your data points the furthest apart — it is the most discriminating direction in the data.
PCA "जानकारी" को variance मानता है। जिस feature का variance zero है वह कुछ नहीं बताता — उस axis पर हर sample एक जैसा है। सबसे ज़्यादा variance वाला principal component वह axis है जो आपके data points को सबसे ज़्यादा दूर-दूर फैलाता है — data में अंतर दिखाने वाली सबसे अच्छी दिशा यही है।
PCA 把"信息"定义为方差。方差为零的特征什么也告诉不了你 —— 所有样本在那条轴上都一样。 方差最大的主成分,就是能把数据点拉得最开的那条轴 —— 它是数据中区分能力最强的方向。
⚊
OrthogonalityOrthogonality正交性
Why PCs are uncorrelatedPCs uncorrelated क्यों होते हैं为什么主成分互不相关
Each principal component is perpendicular (orthogonal) to all others. This means PCs are completely uncorrelated — zero covariance between them. PCA eliminates redundancy. The original features may be correlated; the PCs never are.
हर principal component बाकी सभी से 90° (orthogonal) पर होता है। इसका मतलब PCs पूरी तरह uncorrelated हैं — उनके बीच covariance zero है। PCA दोहराव (redundancy) हटाता है। Original features correlated हो सकते हैं; PCs कभी नहीं।
每个主成分都与其他所有主成分垂直(正交)。这意味着主成分之间完全不相关 —— 协方差为零。 PCA 消除了冗余。原始特征可能相关,但主成分永远不相关。
🕑
Scree PlotScree Plot碎石图
How to pick kk कैसे चुनें如何选 k
Plot eigenvalues in descending order. Look for the elbow — the point where the drop-off flattens. Components before the elbow explain most variance; components after are mostly noise. Alternatively, keep components until cumulative variance ≥ 95%.
Eigenvalues को बड़े से छोटे क्रम में plot करें। Elbow देखें — वह जगह जहाँ गिरावट सपाट हो जाती है। Elbow से पहले वाले components ज़्यादातर variance समझाते हैं; बाद वाले ज़्यादातर noise हैं। दूसरा तरीका: तब तक components रखें जब तक cumulative variance ≥ 95% न हो जाए।
把特征值按降序画出来,找肘部(elbow)—— 下降开始变平的地方。 肘部之前的主成分解释了大部分方差;之后的大多是噪声。另一种方法:一直保留主成分,直到累计方差 ≥ 95%。

SectionSection第 13 节

When to Use PCA — and When Not ToPCA कब इस्तेमाल करें — और कब नहीं什么时候用 PCA — 什么时候不用

📊
VisualisationVisualisation可视化
2D/3D plotting2D/3D plotting二维/三维作图
Reduce 100-feature data to 2 or 3 PCs for scatter plots. Makes cluster structures visible that are invisible in high dimensions.
100-feature data को scatter plots के लिए 2 या 3 PCs में घटाएँ। जो clusters ज़्यादा dimensions में नहीं दिखते, वे दिखने लगते हैं।
把 100 个特征的数据降到 2 或 3 个主成分来画散点图,让高维中看不见的聚类结构显现出来。
🔈
Noise FilteringNoise Filtering噪声过滤
Drop low-variance PCsकम variance वाले PCs हटाएँ丢掉低方差主成分
Small eigenvalues often correspond to noise. Discarding the last few PCs removes noise while preserving signal — used in image compression and genetics.
छोटे eigenvalues अक्सर noise होते हैं। आख़िरी कुछ PCs हटाने से noise हटता है और signal बचता है — image compression और genetics में इस्तेमाल होता है।
小特征值通常对应噪声。丢掉最后几个主成分可以去除噪声、保留信号 —— 用于图像压缩和遗传学。
🔗
Multicollinearity FixMulticollinearity का इलाज解决多重共线性
Before regressionRegression से पहले回归之前
Highly correlated features break OLS regression. PCA creates uncorrelated PCs, eliminating multicollinearity before fitting a linear model (PCR).
बहुत correlated features OLS regression को बिगाड़ देते हैं। PCA uncorrelated PCs बनाता है और linear model (PCR) fit करने से पहले multicollinearity हटा देता है।
高度相关的特征会破坏 OLS 回归。PCA 生成互不相关的主成分,在拟合线性模型(PCR)之前消除多重共线性。
⌛
Speed Up TrainingTraining तेज़ करें加快训练
PreprocessingPreprocessing预处理
Reduce 500 features to 50 PCs before training SVM or kNN. Runtime drops dramatically with minimal accuracy loss on well-structured data.
SVM या kNN train करने से पहले 500 features को 50 PCs में घटाएँ। अच्छे ढाँचे वाले data पर runtime बहुत घटता है और accuracy बहुत कम गिरती है।
在训练 SVM 或 kNN 之前把 500 个特征降到 50 个主成分。对结构良好的数据,运行时间大幅下降,准确率损失很小。
❌
Avoid: Tree Modelsबचें: Tree Models避免:树模型
Not helpfulफ़ायदेमंद नहीं没有帮助
Random Forest and XGBoost handle high dimensions and correlated features natively. PCA removes feature interpretability with no performance benefit for trees.
Random Forest और XGBoost ज़्यादा dimensions और correlated features खुद संभाल लेते हैं। Trees के लिए PCA performance नहीं बढ़ाता, बस features की समझ ख़त्म कर देता है।
Random Forest 和 XGBoost 本身就能处理高维和相关特征。对树模型来说,PCA 不会提升性能,只会让特征失去可解释性。
❌
Avoid: Non-linear Dataबचें: Non-linear Data避免:非线性数据
Use kernel PCA insteadइसकी जगह kernel PCA改用 kernel PCA
PCA only captures linear relationships. Curved or spiral data structures require kernel PCA, t-SNE, or UMAP to reveal the true low-dimensional manifold.
PCA सिर्फ़ linear रिश्ते पकड़ता है। मुड़े हुए या spiral data ढाँचों के असली low-dimensional manifold को दिखाने के लिए kernel PCA, t-SNE या UMAP चाहिए।
PCA 只能捕获线性关系。弯曲或螺旋形的数据结构需要 kernel PCA、t-SNE 或 UMAP 才能揭示真实的低维流形。

SectionSection第 14 节

Python Implementation — Verify Our Hand CalculationPython Implementation — हाथ के हिसाब की जाँचPython 实现 — 验证手算结果

Let us reproduce the exact numerical example above in Python — both manually and using scikit-learn. The outputs should match our hand-solved values to within floating-point precision.

चलिए ऊपर वाला ठीक यही numerical example Python में दोबारा करते हैं — हाथ वाले तरीके से भी और scikit-learn से भी। Outputs हमारे हाथ से हल किए values से floating-point precision तक मेल खाने चाहिए।

我们用 Python 重现上面这个数值例子 —— 既手动实现,也用 scikit-learn。 输出应与手算结果在浮点精度范围内一致。

import numpy as np
from sklearn.decomposition import PCA

# ── Original dataset ──────────────────────────────────────────
X = np.array([
    [1, 2],   # S1
    [3, 4],   # S2
    [5, 4],   # S3
    [3, 6],   # S4
], dtype=float)

# ── MANUAL PCA ────────────────────────────────────────────────
# Step 1: Mean vector
mu = X.mean(axis=0)
print(f"Mean vector μ: {mu}")   # [3. 4.]

# Step 2: Mean-centre
B = X - mu
print(f"\nCentred matrix B:\n{B}")

# Step 3: Covariance matrix (ddof=1 → divide by n-1)
C = np.cov(B, rowvar=False)     # equivalent to BᵀB / (n-1)
print(f"\nCovariance matrix C:\n{C}")

# Step 4 & 5: Eigendecomposition
eigenvalues, eigenvectors = np.linalg.eigh(C)

# eigh returns ascending order — reverse to descending
idx = np.argsort(eigenvalues)[::-1]
eigenvalues  = eigenvalues[idx]
eigenvectors = eigenvectors[:, idx]

print(f"\nEigenvalues (sorted): {eigenvalues}")   # [4.  1.333]
print(f"Eigenvectors (columns):\n{eigenvectors}")

# Step 6: Explained variance
ev_ratio = eigenvalues / eigenvalues.sum()
print(f"\nExplained variance ratio: {ev_ratio}")  # [0.75  0.25]
print(f"Cumulative:              {ev_ratio.cumsum()}")

# Step 7: Project onto PC1 only
W  = eigenvectors[:, :1]      # take first column only
Z  = B @ W                      # matrix multiply
print(f"\nProjected data Z (1D):\n{Z.flatten()}")
OUTPUT
Mean vector μ: [3. 4.] Centred matrix B: [[-2. -2.] [ 0. 0.] [ 2. 0.] [ 0. 2.]] Covariance matrix C: [[2.66666667 1.33333333] [1.33333333 2.66666667]] Eigenvalues (sorted): [4. 1.33333333] Eigenvectors (columns): [[ 0.70710678 -0.70710678] [ 0.70710678 0.70710678]] Explained variance ratio: [0.75 0.25] Cumulative: [0.75 1. ] Projected data Z (1D): [-2.82842712 0. 1.41421356 1.41421356]
✅
Output Matches Hand Calculation ExactlyOutput हाथ के हिसाब से बिल्कुल मेल खाता है输出与手算结果完全一致

λ₁ = 4.0 ✓   λ₂ = 1.333 ✓   EV = 75%, 25% ✓   Z = [−2.828, 0, 1.414, 1.414] ✓
All values match our step-by-step notebook solution. NumPy uses the same mathematical definitions — this confirms we solved the problem correctly by hand. (NumPy prints the second eigenvector as [−0.707, 0.707]. That is −e₂: the same axis, pointing the other way. See the sign note below.)

λ₁ = 4.0 ✓   λ₂ = 1.333 ✓   EV = 75%, 25% ✓   Z = [−2.828, 0, 1.414, 1.414] ✓
सभी values हमारे step-by-step notebook हल से मेल खाती हैं। NumPy वही गणितीय परिभाषाएँ इस्तेमाल करता है — इससे पक्का होता है कि हमने problem हाथ से सही हल किया। (NumPy दूसरा eigenvector [−0.707, 0.707] छापता है। यह −e₂ है: वही axis, बस उल्टी दिशा में। नीचे sign वाला note देखें।)

λ₁ = 4.0 ✓   λ₂ = 1.333 ✓   EV = 75%, 25% ✓   Z = [−2.828, 0, 1.414, 1.414] ✓
所有数值都与我们逐步手算的结果一致。NumPy 使用的是同样的数学定义 —— 这证明我们手算是正确的。 (NumPy 把第二个特征向量打印为 [−0.707, 0.707],也就是 −e₂:同一条轴,只是方向相反。见下面关于符号的说明。)

# ── SCIKIT-LEARN PCA (one-liner verification) ─────────────────
pca = PCA(n_components=1)
Z_sk = pca.fit_transform(X)    # sklearn centres internally

print(f"sklearn Z:          {Z_sk.flatten()}")
print(f"sklearn EV ratio:   {pca.explained_variance_ratio_}")
print(f"sklearn eigenvalue: {pca.explained_variance_}")
print(f"sklearn component:  {pca.components_}")
OUTPUT
sklearn Z: [-2.82842712 0. 1.41421356 1.41421356] sklearn EV ratio: [0.75] sklearn eigenvalue: [4.] sklearn component: [[0.70710678 0.70710678]]
📚
Note on Sign ConventionsSign (चिह्न) के बारे में Note关于正负号约定的说明

The sign of eigenvectors is arbitrary (both [0.707, 0.707] and [−0.707, −0.707] are valid). Some solvers may flip the sign of the PC scores. This does not affect variance explained, relative distances, or model accuracy — only the direction of the axis label. sklearn's PCA uses a deterministic sign convention; always check consistency when comparing implementations.

Eigenvectors का sign मनमाना होता है ([0.707, 0.707] और [−0.707, −0.707] दोनों सही हैं)। कुछ solvers PC scores का sign उलट सकते हैं। इससे explained variance, आपसी दूरियों या model accuracy पर कोई असर नहीं पड़ता — सिर्फ़ axis की दिशा बदलती है। sklearn का PCA एक तय sign नियम इस्तेमाल करता है; अलग implementations की तुलना करते समय हमेशा मेल जाँचें।

特征向量的正负号是任意的([0.707, 0.707] 和 [−0.707, −0.707] 都正确)。 有些求解器可能会翻转主成分得分的符号。这不会影响解释方差、点之间的相对距离或 model 准确率 —— 只影响坐标轴的方向。 sklearn 的 PCA 使用确定的符号约定;比较不同实现时,一定要检查是否一致。


SectionSection第 15 节

PCA vs Other Dimensionality Reduction MethodsPCA vs दूसरे Dimensionality Reduction तरीकेPCA 与其他降维方法对比

Propertyगुण属性PCAt-SNEUMAPLDA
LinearityLinearity线性LinearLinear线性Non-linearNon-linear非线性Non-linearNon-linear非线性LinearLinear线性
Supervised?Supervised?有监督?No (unsupervised)नहीं (unsupervised)否(无监督)Noनहीं否Noनहीं否Yes (needs labels)हाँ (labels चाहिए)是(需要标签)
Preservesक्या बचाता है保留什么Global varianceGlobal variance全局方差Local clustersLocal clusters局部聚类Local & globalLocal और global局部与全局Class separabilityClasses का अलगाव类别可分性
Output usable for ML?Output ML में काम आता है?输出能用于 ML 吗?Yesहाँ能No (stochastic)नहीं (stochastic)不能(随机性)Sometimesकभी-कभी有时Yesहाँ能
Scales to high-d?ज़्यादा dimensions पर चलता है?能扩展到高维吗?Yes (TruncatedSVD)हाँ (TruncatedSVD)能(TruncatedSVD)Slow (>50k samples)धीमा (>50k samples)慢(>5 万样本)Goodअच्छा良好Yesहाँ能
Best forकिसके लिए सबसे अच्छा最适合Preprocessing, noise removalPreprocessing, noise हटाना预处理、去噪2D/3D visualisation2D/3D visualisation二维/三维可视化Exploration, clusteringExploration, clustering探索、聚类Classification preprocessingClassification preprocessing分类前的预处理

SectionSection第 16 节

Golden Rules — PCA Non-Negotiablesसुनहरे नियम — PCA में ज़रूरी बातें黄金法则 — PCA 必须遵守的原则

🌲 PCA — Rules You Must Never BreakPCA — नियम जो कभी नहीं तोड़नेPCA — 绝不能违反的规则
1
Always standardise features before PCA when features are on different scales (e.g. age in years vs. salary in lakhs). Without standardisation, the feature with the largest numeric range will dominate all principal components — even if it is not the most informative. Use StandardScaler before PCA in every sklearn pipeline.
जब features अलग-अलग scales पर हों (जैसे उम्र सालों में और salary लाखों में), तो PCA से पहले features को हमेशा standardise करें। Standardisation के बिना, सबसे बड़ी numeric range वाला feature सभी principal components पर हावी हो जाएगा — भले ही वह सबसे ज़्यादा जानकारी वाला न हो। हर sklearn pipeline में PCA से पहले StandardScaler इस्तेमाल करें।
当特征的尺度不同时(例如年龄以岁计、薪水以十万卢比计),做 PCA 之前一定要先标准化特征。 不标准化的话,数值范围最大的特征会主导所有主成分 —— 即使它并不是信息量最大的。 在每个 sklearn 流水线中,都要在 PCA 之前使用 StandardScaler。
2
Fit the scaler and PCA on training data only. Apply the learned transform to test data. Fitting on the full dataset leaks future information into the PCA axes — this is data leakage and inflates performance metrics in evaluation.
Scaler और PCA को सिर्फ़ training data पर fit करें। सीखा हुआ transform test data पर लगाएँ। पूरे dataset पर fit करने से भविष्य की जानकारी PCA axes में leak हो जाती है — यह data leakage है और evaluation में performance को ज़रूरत से ज़्यादा अच्छा दिखाता है।
缩放器和 PCA 只能在训练数据上拟合(fit),再把学到的变换应用到测试数据上。 在整个数据集上拟合会把"未来"的信息泄漏到 PCA 坐标轴中 —— 这就是数据泄漏(data leakage),会让评估指标虚高。
3
Sum of all eigenvalues = Trace of covariance matrix = Total variance. Always verify this: if eigenvalues don't sum to the trace, the eigendecomposition went wrong. In our example: λ₁ + λ₂ = 4 + 4/3 = 16/3 = Trace(C) = 8/3 + 8/3 = 16/3 ✓
सभी eigenvalues का जोड़ = covariance matrix का Trace = कुल variance. इसे हमेशा जाँचें: अगर eigenvalues का जोड़ trace के बराबर नहीं है, तो eigendecomposition गलत हुआ है। हमारे example में: λ₁ + λ₂ = 4 + 4/3 = 16/3 = Trace(C) = 8/3 + 8/3 = 16/3 ✓
所有特征值之和 = 协方差矩阵的迹(Trace)= 总方差。 一定要验证这一点:如果特征值之和不等于迹,说明特征分解出错了。 在我们的例子中:λ₁ + λ₂ = 4 + 4/3 = 16/3 = Trace(C) = 8/3 + 8/3 = 16/3 ✓
4
Use a scree plot or cumulative explained variance curve to choose k, not an arbitrary number. The standard threshold for most applications is keeping enough components to explain ≥ 95% cumulative variance. For visualisation, always use exactly 2 or 3 components.
k चुनने के लिए कोई मनमाना number नहीं, बल्कि scree plot या cumulative explained variance curve इस्तेमाल करें। ज़्यादातर कामों में आम सीमा है इतने components रखना कि ≥ 95% cumulative variance समझाया जाए। Visualisation के लिए हमेशा ठीक 2 या 3 components इस्तेमाल करें।
用碎石图或累计解释方差曲线来选 k,而不是随便定一个数。 大多数应用的标准门槛是保留足够多的主成分,使累计方差 ≥ 95%。 做可视化时,始终只用 2 或 3 个主成分。
5
PCA destroys feature interpretability. A PC is a linear combination of all original features — you cannot say "PC1 is height" or "PC2 is weight". If your downstream task requires human-interpretable features (e.g. clinical reporting, regulatory compliance), do NOT use PCA. Use feature selection or manual engineering instead.
PCA features की समझ (interpretability) ख़त्म कर देता है। एक PC सभी original features का linear combination है — आप नहीं कह सकते कि "PC1 लंबाई है" या "PC2 वज़न है"। अगर आगे के काम में इंसान के समझने लायक features चाहिए (जैसे clinical reporting, regulatory compliance), तो PCA इस्तेमाल न करें। उसकी जगह feature selection या manual engineering करें।
PCA 会破坏特征的可解释性。每个主成分都是所有原始特征的线性组合 —— 你不能说"PC1 就是身高"或"PC2 就是体重"。如果后续任务需要人能看懂的特征(例如临床报告、监管合规), 就不要用 PCA,而应使用特征选择或人工特征工程。
6
PCA is linear-only. It cannot capture non-linear structures in data. If your data lies on a curved manifold (e.g. Swiss roll, concentric rings), PCA will produce poor projections. Use kernel PCA (with RBF kernel) or UMAP / t-SNE for non-linear dimensionality reduction.
PCA सिर्फ़ linear है। यह data के non-linear ढाँचे नहीं पकड़ सकता। अगर आपका data किसी मुड़े हुए manifold पर है (जैसे Swiss roll, concentric rings), तो PCA ख़राब projections देगा। Non-linear dimensionality reduction के लिए kernel PCA (RBF kernel के साथ) या UMAP / t-SNE इस्तेमाल करें।
PCA 只能处理线性关系。它无法捕获数据中的非线性结构。 如果数据分布在弯曲的流形上(如瑞士卷、同心圆环),PCA 的投影效果会很差。 做非线性降维请使用 kernel PCA(RBF 核)或 UMAP / t-SNE。
7
For very large datasets (millions of rows, thousands of features), use sklearn.decomposition.TruncatedSVD or PCA(svd_solver='randomized'). The full exact SVD on a 1M × 1000 matrix is prohibitively expensive. Randomised PCA gives nearly identical results at a fraction of the compute cost.
बहुत बड़े datasets (लाखों rows, हज़ारों features) के लिए sklearn.decomposition.TruncatedSVD या PCA(svd_solver='randomized') इस्तेमाल करें। 1M × 1000 matrix पर पूरा exact SVD बहुत महँगा है। Randomised PCA बहुत कम compute में लगभग वही नतीजे देता है।
对于超大数据集(数百万行、数千个特征),请使用 sklearn.decomposition.TruncatedSVD 或 PCA(svd_solver='randomized')。对 1M × 1000 的矩阵做完整精确的 SVD 代价极高。 随机化 PCA 只需很小一部分计算量,就能得到几乎相同的结果。

SectionSection第 17 节

The Real Significance of EigenvectorsEigenvectors का असली महत्व特征向量的真正意义

Most textbooks define eigenvectors as "directions of maximum variance" and move on. That is true but dangerously shallow. Here is what an eigenvector actually means — geometrically, algebraically, and in the context of your data.

ज़्यादातर किताबें eigenvectors को "maximum variance की दिशाएँ" कहकर आगे बढ़ जाती हैं। यह सही है, पर ख़तरनाक रूप से सतही है। यहाँ देखें कि eigenvector का असली मतलब क्या है — geometry में, algebra में, और आपके data के संदर्भ में।

大多数教科书把特征向量定义为"方差最大的方向"就一笔带过。这没错,但浅得危险。 下面讲讲特征向量真正的含义 —— 从几何、代数以及你的数据这三个角度。

What direction does the covariance matrix NOT rotate?Covariance matrix किस दिशा को नहीं घुमाता?协方差矩阵"不旋转"哪个方向?
A matrix is a transformation. When you multiply any vector v by a matrix C, the vector generally changes direction — it gets rotated and stretched.

An eigenvector is a special vector that the matrix does not rotate. It only gets stretched or compressed. The matrix multiplies it by a scalar — the eigenvalue — and that is it.

Cv = λv

Read this as: "When the covariance matrix C acts on eigenvector v, the result is just a scaled version of v itself — same direction, different magnitude."

In PCA: the covariance matrix encodes how your data varies. Its eigenvectors are the directions in feature space where this variation is pure — no mixing, no rotation. They are the natural axes of the data's shape.
Matrix एक transformation है। जब आप किसी vector v को matrix C से गुणा करते हैं, तो आमतौर पर vector की दिशा बदल जाती है — वह घूमता भी है और खिंचता भी है।

Eigenvector एक ख़ास vector है जिसे matrix घुमाता नहीं। वह सिर्फ़ खिंचता या सिकुड़ता है। Matrix उसे एक scalar — eigenvalue — से गुणा करता है, बस।

Cv = λv

इसे ऐसे पढ़ें: "जब covariance matrix C, eigenvector v पर काम करता है, तो नतीजा v का ही scaled रूप होता है — वही दिशा, अलग आकार।"

PCA में: covariance matrix बताता है कि आपका data कैसे बदलता है। इसके eigenvectors feature space की वे दिशाएँ हैं जहाँ यह बदलाव शुद्ध है — न मिलावट, न घुमाव। ये data के आकार के स्वाभाविक axes हैं।
矩阵是一种变换。当你用矩阵 C 去乘任意向量 v 时, 向量通常会改变方向 —— 既被旋转,又被拉伸。

特征向量是一种特殊的向量,矩阵不会旋转它, 只会把它拉长或压缩。矩阵只是把它乘以一个标量 —— 特征值 —— 仅此而已。

Cv = λv

这样读:"当协方差矩阵 C 作用在特征向量 v 上时,结果只是 v 本身的缩放版 —— 方向相同,大小不同。"

在 PCA 中:协方差矩阵描述了数据如何变化。它的特征向量就是特征空间中变化纯粹的方向 —— 没有混合,没有旋转。它们是数据形状的天然坐标轴。
🔭
Geometric Meaning — The Data Cloud Has a ShapeGeometry में मतलब — Data के बादल का एक आकार है几何意义 — 数据点云有它的形状

Imagine your data points as a cloud in 2D space. This cloud is probably not circular — it is likely an ellipse stretched in some direction. The eigenvectors of the covariance matrix point along the axes of that ellipse. The longest axis of the ellipse = first eigenvector (PC1). The shortest axis = second eigenvector (PC2). They are always perpendicular to each other. Always.

अपने data points को 2D space में एक बादल की तरह सोचें। यह बादल शायद गोल नहीं है — ज़्यादा संभावना है कि यह किसी दिशा में खिंचा हुआ ellipse है। Covariance matrix के eigenvectors उसी ellipse के axes की दिशा में होते हैं। Ellipse का सबसे लंबा axis = पहला eigenvector (PC1)। सबसे छोटा axis = दूसरा eigenvector (PC2)। ये हमेशा एक-दूसरे से 90° पर होते हैं। हमेशा।

把你的数据点想象成二维空间里的一团云。这团云很可能不是圆的 —— 更可能是朝某个方向拉长的椭圆。 协方差矩阵的特征向量正好沿着这个椭圆的轴。 椭圆最长的轴 = 第一个特征向量(PC1),最短的轴 = 第二个特征向量(PC2)。 它们永远互相垂直。永远。

📏
Eigenvector = DirectionEigenvector = दिशा特征向量 = 方向
Not a point — a compass bearingPoint नहीं — compass की दिशा不是一个点 —— 而是指南针的方位
An eigenvector tells you which way to look in feature space to see the most spread. In our example, e₁ = [0.707, 0.707] means "look diagonally — equally in the x₁ and x₂ directions simultaneously." It is a new axis drawn through your data at 45°.
Eigenvector बताता है कि सबसे ज़्यादा फैलाव देखने के लिए feature space में किस तरफ़ देखें। हमारे example में, e₁ = [0.707, 0.707] का मतलब है "तिरछा देखें — x₁ और x₂ दोनों दिशाओं में बराबर, एक साथ।" यह आपके data के बीच से 45° पर खींचा गया एक नया axis है।
特征向量告诉你在特征空间里往哪个方向看才能看到最大的散布。 在我们的例子中,e₁ = [0.707, 0.707] 的意思是"斜着看 —— 同时在 x₁ 和 x₂ 方向上各占一半"。 它是一条以 45° 穿过数据的新坐标轴。
⚖
Eigenvector = RotationEigenvector = घुमाव特征向量 = 旋转
It rotates your coordinate systemयह coordinate system को घुमाता है它旋转你的坐标系
The matrix of eigenvectors W is an orthogonal rotation matrix. When you compute Z = B·W, you are rotating the entire dataset so that the axis of maximum spread becomes the new x-axis (PC1), and the next axis of spread becomes the new y-axis (PC2). No stretching — pure rotation.
Eigenvectors का matrix W एक orthogonal rotation matrix है। जब आप Z = B·W निकालते हैं, तो आप पूरे dataset को घुमाते हैं ताकि सबसे ज़्यादा फैलाव वाला axis नया x-axis (PC1) बन जाए, और अगला फैलाव वाला axis नया y-axis (PC2)। कोई खिंचाव नहीं — सिर्फ़ घुमाव।
由特征向量组成的矩阵 W 是一个正交旋转矩阵。计算 Z = B·W 时, 你是在旋转整个数据集,使散布最大的轴成为新的 x 轴(PC1),次大的轴成为新的 y 轴(PC2)。没有拉伸 —— 纯粹的旋转。
🔨
Eigenvector = RecipeEigenvector = Recipe特征向量 = 配方
A linear combination of featuresFeatures का linear combination特征的线性组合
Each eigenvector is a recipe that tells you how to mix your original features to create a new, more informative axis. In our example: PC1 = 0.707·x₁ + 0.707·x₂ — add both features equally. PC2 = 0.707·x₁ − 0.707·x₂ — subtract them. These mixtures are uncorrelated by construction.
हर eigenvector एक recipe है जो बताता है कि original features को कैसे मिलाएँ ताकि एक नया, ज़्यादा जानकारी वाला axis बने। हमारे example में: PC1 = 0.707·x₁ + 0.707·x₂ — दोनों features को बराबर जोड़ें। PC2 = 0.707·x₁ − 0.707·x₂ — उन्हें घटाएँ। ये मिश्रण बनावट से ही uncorrelated होते हैं।
每个特征向量都是一份配方,告诉你如何混合原始特征,得到一条新的、信息量更大的坐标轴。 在我们的例子中:PC1 = 0.707·x₁ + 0.707·x₂ —— 两个特征等量相加;PC2 = 0.707·x₁ − 0.707·x₂ —— 两者相减。 这些组合天生就互不相关。
Because uncorrelated axes must be orthogonal in Euclidean spaceक्योंकि Euclidean space में uncorrelated axes orthogonal होने चाहिए因为在欧氏空间中,不相关的轴必须正交
The covariance matrix C is symmetric (C = Cᵀ). A fundamental theorem of linear algebra — the Spectral Theorem — guarantees that any real symmetric matrix has:

① Real eigenvalues (no complex numbers)
② Eigenvectors that are mutually orthogonal (perpendicular to each other)
③ A complete set of eigenvectors that span the entire feature space

This is why PCA works. If the covariance matrix were not symmetric, eigenvectors could point in complex directions or fail to be orthogonal — and the whole method would break down. Symmetry of C is guaranteed because covariance is symmetric: Cov(x₁,x₂) always equals Cov(x₂,x₁).
Covariance matrix C symmetric है (C = Cᵀ)। Linear algebra का एक बुनियादी theorem — Spectral Theorem — गारंटी देता है कि हर real symmetric matrix में:

① Real eigenvalues होते हैं (कोई complex number नहीं)
② Eigenvectors आपस में orthogonal होते हैं (एक-दूसरे से 90° पर)
③ Eigenvectors का पूरा set होता है जो पूरे feature space को ढकता है

इसीलिए PCA काम करता है। अगर covariance matrix symmetric न होता, तो eigenvectors complex दिशाओं में हो सकते थे या orthogonal न होते — और पूरा तरीका टूट जाता। C का symmetric होना पक्का है क्योंकि covariance symmetric है: Cov(x₁,x₂) हमेशा Cov(x₂,x₁) के बराबर है।
协方差矩阵 C 是对称的(C = Cᵀ)。线性代数的一个基本定理 —— 谱定理(Spectral Theorem)—— 保证任何实对称矩阵都有:

① 实数特征值(没有复数)
② 两两正交(互相垂直)的特征向量
③ 一组完整的特征向量,能张成整个特征空间

这就是 PCA 能成立的原因。如果协方差矩阵不对称,特征向量可能指向复数方向,或者不正交 —— 整个方法就会崩溃。 C 一定对称,因为协方差本身是对称的:Cov(x₁,x₂) 永远等于 Cov(x₂,x₁)。
💡 What Each Eigenvector Component Value Means — Interpreting e₁ = [0.707, 0.707]Eigenvector की हर value का मतलब — e₁ = [0.707, 0.707] को समझना特征向量每个分量的含义 — 解读 e₁ = [0.707, 0.707]
0.707
The loading of feature x₁ on PC1. How much x₁ contributes to this principal component. Large positive value = strong positive contribution. PC1 पर feature x₁ की loading. x₁ इस principal component में कितना योगदान देता है। बड़ी positive value = मज़बूत positive योगदान। 特征 x₁ 在 PC1 上的载荷(loading),即 x₁ 对这个主成分的贡献。正值越大 = 正向贡献越强。
0.707
The loading of feature x₂ on PC1. Both features contribute equally (0.707 = 0.707), so PC1 is purely the sum of both features — it captures their shared movement. PC1 पर feature x₂ की loading. दोनों features बराबर योगदान देते हैं (0.707 = 0.707), इसलिए PC1 दोनों features का सीधा जोड़ है — यह उनकी साझा चाल पकड़ता है। 特征 x₂ 在 PC1 上的载荷。两个特征贡献相等(0.707 = 0.707),所以 PC1 就是两个特征之和 —— 它捕获的是它们的共同变化。
SignSign符号
In e₂ = [0.707, −0.707]: x₁ loads positively, x₂ loads negatively. PC2 captures how the features diverge — when one goes up and the other goes down. e₂ = [0.707, −0.707] में: x₁ की loading positive है, x₂ की negative. PC2 पकड़ता है कि features कैसे अलग होते हैं — जब एक बढ़ता है और दूसरा घटता है। 在 e₂ = [0.707, −0.707] 中:x₁ 载荷为正,x₂ 载荷为负。PC2 捕获的是两个特征如何背离 —— 一个上升而另一个下降。
Magnitudeआकार大小
Larger absolute loading = that feature dominates this PC. A loading near 0 means the feature barely influences this axis. Loadings always satisfy ‖e‖ = 1. बड़ी absolute loading = वह feature इस PC पर हावी है। 0 के पास loading का मतलब feature इस axis पर मुश्किल से असर डालता है। Loadings हमेशा ‖e‖ = 1 मानती हैं। 载荷绝对值越大 = 该特征主导这个主成分。载荷接近 0 表示该特征几乎不影响这条轴。载荷总是满足 ‖e‖ = 1。
⚠️
The Critical Implication — Eigenvectors Destroy Feature Namesअहम नतीजा — Eigenvectors feature के नाम मिटा देते हैं关键影响 — 特征向量会抹掉特征的名字

Once you rotate into PC space, there is no "x₁" or "x₂" anymore. PC1 is a blend of all original features. This is why PCA projects are uninterpretable — you cannot say "a patient scores high on PC1 because their blood pressure is high." If interpretability matters for your task, this is a showstopper. Use feature selection or SHAP-based methods instead.

PC space में घूमने के बाद कोई "x₁" या "x₂" नहीं रहता। PC1 सभी original features का मिश्रण है। इसीलिए PCA projections समझाए नहीं जा सकते — आप नहीं कह सकते कि "मरीज़ का PC1 score ज़्यादा है क्योंकि उसका blood pressure ज़्यादा है।" अगर आपके काम में interpretability ज़रूरी है, तो यह बड़ी रुकावट है। उसकी जगह feature selection या SHAP-based तरीके इस्तेमाल करें।

一旦旋转到主成分空间,就不再有"x₁"或"x₂"了。PC1 是所有原始特征的混合。 这就是 PCA 投影无法解释的原因 —— 你不能说"这位病人的 PC1 得分高是因为他血压高"。 如果你的任务很看重可解释性,这一点是致命的。请改用特征选择或基于 SHAP 的方法。


SectionSection第 18 节

The Real Significance of EigenvaluesEigenvalues का असली महत्व特征值的真正意义

The eigenvalue is often summarised as "the variance explained." That is correct. But why is the eigenvalue the variance? Where does that come from? And what exactly does the number 4 mean in our example? Let us build the answer from scratch.

Eigenvalue को अक्सर "समझाया गया variance" कहा जाता है। यह सही है। पर eigenvalue variance क्यों है? यह कहाँ से आता है? और हमारे example में number 4 का ठीक-ठीक मतलब क्या है? चलिए जवाब शुरू से बनाते हैं।

特征值常被概括为"解释的方差"。这没错。但特征值为什么就是方差?它从哪里来? 我们例子里的数字 4 到底表示什么?我们从头推导答案。

The variance of projected data equals the eigenvalue. Here is the proof.Project किए गए data का variance, eigenvalue के बराबर है। यह रहा proof.投影数据的方差等于特征值。下面是证明。
Let e be a unit eigenvector. The projected data along this direction is z = Be (a column vector).

Variance of the projection:
Var(z) = (1/(n−1)) × zᵀz
        = (1/(n−1)) × (Be)ᵀ(Be)
        = (1/(n−1)) × eᵀBᵀBe
        = eᵀ [(1/(n−1)) BᵀB] e
        = eᵀ C e    ← definition of covariance matrix

Since e is an eigenvector of C:   Ce = λe

        = eᵀ(λe) = λ(eᵀe) = λ × 1 = λ

Therefore: Var(z) = λ

The variance of the data projected onto eigenvector e is exactly equal to the eigenvalue λ. This is not a definition — it is a proven consequence of the eigenvector equation.
मान लें e एक unit eigenvector है। इस दिशा में project किया गया data z = Be है (एक column vector)।

Projection का variance:
Var(z) = (1/(n−1)) × zᵀz
        = (1/(n−1)) × (Be)ᵀ(Be)
        = (1/(n−1)) × eᵀBᵀBe
        = eᵀ [(1/(n−1)) BᵀB] e
        = eᵀ C e    ← covariance matrix की परिभाषा

क्योंकि e, C का eigenvector है:   Ce = λe

        = eᵀ(λe) = λ(eᵀe) = λ × 1 = λ

इसलिए: Var(z) = λ

Eigenvector e पर project किए गए data का variance ठीक eigenvalue λ के बराबर है। यह कोई परिभाषा नहीं — यह eigenvector equation से साबित हुआ नतीजा है।
设 e 是一个单位特征向量。沿这个方向投影的数据为 z = Be(一个列向量)。

投影的方差:
Var(z) = (1/(n−1)) × zᵀz
        = (1/(n−1)) × (Be)ᵀ(Be)
        = (1/(n−1)) × eᵀBᵀBe
        = eᵀ [(1/(n−1)) BᵀB] e
        = eᵀ C e    ← 协方差矩阵的定义

因为 e 是 C 的特征向量:  Ce = λe

        = eᵀ(λe) = λ(eᵀe) = λ × 1 = λ

所以:Var(z) = λ

数据投影到特征向量 e 上的方差,恰好等于特征值 λ。 这不是定义 —— 而是由特征向量方程证明出来的结论。
💡
The Meaning of λ₁ = 4 in Our Exampleहमारे Example में λ₁ = 4 का मतलब我们例子中 λ₁ = 4 的含义

When we project our 4 data points onto PC1 (e₁), the resulting 1D scores are [−2.828, 0, 1.414, 1.414]. The variance of these scores = exactly 4.0.

Verify: mean of scores = (−2.828 + 0 + 1.414 + 1.414) / 4 = 0 ✓ (centred data has zero mean)
Var = [(−2.828)² + 0² + 1.414² + 1.414²] / (4−1) = [8 + 0 + 2 + 2] / 3 = 12/3 = 4.0 ✓

जब हम अपने 4 data points को PC1 (e₁) पर project करते हैं, तो 1D scores [−2.828, 0, 1.414, 1.414] मिलते हैं। इन scores का variance = ठीक 4.0.

जाँच: scores का mean = (−2.828 + 0 + 1.414 + 1.414) / 4 = 0 ✓ (centred data का mean zero होता है)
Var = [(−2.828)² + 0² + 1.414² + 1.414²] / (4−1) = [8 + 0 + 2 + 2] / 3 = 12/3 = 4.0 ✓

把 4 个数据点投影到 PC1(e₁)上,得到的一维得分是 [−2.828, 0, 1.414, 1.414]。 这些得分的方差 = 正好 4.0。

验证:得分均值 = (−2.828 + 0 + 1.414 + 1.414) / 4 = 0 ✓(中心化数据均值为零)
Var = [(−2.828)² + 0² + 1.414² + 1.414²] / (4−1) = [8 + 0 + 2 + 2] / 3 = 12/3 = 4.0 ✓

📊 What the Eigenvalue Number Physically RepresentsEigenvalue का number असल में क्या दिखाता है特征值这个数字的实际含义
λ = 4
The data points, when projected onto PC1, have a spread (variance) of 4. This is the widest the data can be spread by any linear projection. No other direction gives you more than 4. PC1 पर project करने पर data points का फैलाव (variance) 4 है। किसी भी linear projection से data इससे ज़्यादा नहीं फैल सकता। कोई और दिशा 4 से ज़्यादा नहीं देती। 投影到 PC1 上后,数据点的散布(方差)为 4。这是任何线性投影能达到的最大散布,没有其他方向能超过 4。
λ = 4/3
Projected onto PC2, the data has a spread (variance) of only 1.333. This axis captures less information. The data is less spread out in this direction. PC2 पर project करने पर data का फैलाव (variance) सिर्फ़ 1.333 है। यह axis कम जानकारी पकड़ता है। इस दिशा में data कम फैला है। 投影到 PC2 上,数据的散布(方差)只有 1.333。这条轴捕获的信息较少,数据在这个方向上不那么分散。
λ → 0
An eigenvalue near zero means almost zero variance in that direction. The data is nearly flat along that axis — no information there. These are the PCs you discard. Zero के पास eigenvalue का मतलब है उस दिशा में लगभग zero variance। उस axis पर data लगभग सपाट है — वहाँ कोई जानकारी नहीं। यही वे PCs हैं जिन्हें आप हटाते हैं। 特征值接近零意味着该方向上几乎没有方差。数据沿这条轴几乎是平的 —— 没有信息。这些就是要丢弃的主成分。
λ = 0
An exactly zero eigenvalue means the features are perfectly linearly dependent (multicollinear). The matrix is singular and that direction is pure redundancy — discarding it loses nothing. बिल्कुल zero eigenvalue का मतलब है कि features पूरी तरह linearly dependent (multicollinear) हैं। Matrix singular है और वह दिशा सिर्फ़ दोहराव है — उसे हटाने से कुछ नहीं खोता। 特征值恰好为零,说明特征之间完全线性相关(多重共线)。矩阵是奇异的,这个方向纯粹是冗余 —— 丢掉它不会损失任何东西。
📈
Eigenvalue = SpreadEigenvalue = फैलाव特征值 = 散布
It is the variance of the projectionयह projection का variance है它是投影的方差
The bigger the eigenvalue, the more spread out the data is along that eigenvector's direction. Large spread = the PC axis discriminates well between data points. Small spread = data points are nearly identical along that axis — uninformative.
Eigenvalue जितना बड़ा, उस eigenvector की दिशा में data उतना ज़्यादा फैला। ज़्यादा फैलाव = PC axis data points में अच्छा अंतर दिखाता है। कम फैलाव = उस axis पर data points लगभग एक जैसे हैं — कोई जानकारी नहीं।
特征值越大,数据沿该特征向量方向就越分散。 散布大 = 这条主成分轴能很好地区分数据点;散布小 = 数据点在这条轴上几乎一样 —— 没有信息。
🎯
Eigenvalue = ImportanceEigenvalue = महत्व特征值 = 重要性
Ranking tells you what to keepRanking बताती है क्या रखना है排序告诉你该保留什么
Sorting eigenvalues descending gives you a strict importance ranking of axes. The first PC is the single best summary of your data. The second is the next best orthogonal summary. You can objectively decide where to cut using the explained variance ratio.
Eigenvalues को बड़े से छोटे क्रम में रखने से axes की साफ़ importance ranking मिलती है। पहला PC आपके data का अकेला सबसे अच्छा सार है। दूसरा अगला सबसे अच्छा orthogonal सार है। Explained variance ratio से आप निष्पक्ष तरीके से तय कर सकते हैं कि कहाँ काटना है।
把特征值按降序排列,就得到坐标轴严格的重要性排名。 第一个主成分是对数据最好的单一概括,第二个是次好的正交概括。你可以用解释方差比客观地决定在哪里截断。
📵
Eigenvalue = Stretching FactorEigenvalue = खिंचाव का गुणक特征值 = 拉伸倍数
How the covariance matrix deforms spaceCovariance matrix space को कैसे बदलता है协方差矩阵如何让空间变形
The covariance matrix is a linear transformation. It stretches space in the direction of each eigenvector by a factor of λ. Large λ = strong stretch = the data has a lot of structure in that direction. The shape of the data ellipse is drawn by the eigenvalues.
Covariance matrix एक linear transformation है। यह हर eigenvector की दिशा में space को λ गुना खींचता है। बड़ा λ = ज़्यादा खिंचाव = उस दिशा में data का काफ़ी ढाँचा है। Data ellipse का आकार eigenvalues से बनता है।
协方差矩阵是一种线性变换,它沿每个特征向量方向把空间拉伸 λ 倍。 λ 大 = 拉伸强 = 数据在该方向上有很多结构。数据椭圆的形状正是由特征值决定的。

SectionSection第 19 节

Eigenvalue and Eigenvector Together — The Complete PictureEigenvalue और Eigenvector साथ में — पूरी तस्वीर特征值与特征向量合起来 — 完整的图景

They are inseparable. An eigenvalue without its eigenvector is just a number. An eigenvector without its eigenvalue is just a direction. Together they answer two questions that completely describe a principal component:

ये अलग नहीं किए जा सकते। Eigenvector के बिना eigenvalue बस एक number है। Eigenvalue के बिना eigenvector बस एक दिशा है। साथ मिलकर ये दो सवालों के जवाब देते हैं जो एक principal component को पूरी तरह बताते हैं:

它们密不可分。没有特征向量的特征值只是一个数字;没有特征值的特征向量只是一个方向。 合在一起,它们回答了完整描述一个主成分的两个问题:

Eigenvector Answers — WHERE?Eigenvector जवाब देता है — कहाँ?特征向量回答 — 在哪里?
Questionसवाल问题Answer from EigenvectorEigenvector से जवाब特征向量给出的答案
Which direction in feature space?Feature space में कौन सी दिशा?特征空间中的哪个方向?e = [0.707, 0.707] → 45° diagonale = [0.707, 0.707] → 45° तिरछाe = [0.707, 0.707] → 45° 对角线
How do features combine?Features कैसे मिलते हैं?特征如何组合?PC1 = 0.707·x₁ + 0.707·x₂
Which features dominate this axis?इस axis पर कौन से features हावी हैं?哪些特征主导这条轴?Both equally (same loading)दोनों बराबर (एक जैसी loading)两者同等(载荷相同)
Are features increasing or opposing?Features साथ बढ़ते हैं या उल्टे चलते हैं?特征是同向还是反向?Both positive → move togetherदोनों positive → साथ चलते हैं都为正 → 一起变化
Are PCs independent?क्या PCs स्वतंत्र हैं?主成分彼此独立吗?Yes — e₁ · e₂ = 0 (orthogonal)हाँ — e₁ · e₂ = 0 (orthogonal)是 —— e₁ · e₂ = 0(正交)
Eigenvalue Answers — HOW MUCH?Eigenvalue जवाब देता है — कितना?特征值回答 — 有多少?
Questionसवाल问题Answer from EigenvalueEigenvalue से जवाब特征值给出的答案
How much variance along this axis?इस axis पर कितना variance?这条轴上有多少方差?λ₁ = 4.0 units of varianceλ₁ = 4.0 units varianceλ₁ = 4.0 个单位的方差
How important is this PC?यह PC कितना ज़रूरी है?这个主成分有多重要?75% of total varianceकुल variance का 75%总方差的 75%
How many PCs to keep?कितने PCs रखें?保留几个主成分?Until Σλₖ/Σλ ≥ 95%जब तक Σλₖ/Σλ ≥ 95%直到 Σλₖ/Σλ ≥ 95%
Is this axis informative?क्या इस axis में जानकारी है?这条轴有信息吗?λ ≫ 0 → yes; λ ≈ 0 → discardλ ≫ 0 → हाँ; λ ≈ 0 → हटाएँλ ≫ 0 → 有;λ ≈ 0 → 丢弃
What is the total information?कुल जानकारी कितनी है?总信息量是多少?Σλ = Trace(C) = 16/3
Eigenvector is the road. Eigenvalue is how far the road takes you.Eigenvector सड़क है। Eigenvalue बताता है कि सड़क आपको कितनी दूर ले जाती है।特征向量是道路,特征值是这条路能带你走多远。
Imagine you are a traveller in feature space. Your data has spread across this space and you want to build a single highway that carries the most traffic (information).

The eigenvector tells you the road's direction — which angle to build the highway. It could run north-south, east-west, or diagonally. The eigenvector picks the exact angle that maximises the spread of your data along that road.

The eigenvalue tells you how much traffic the road carries — the total variance of data spread along that highway. A large eigenvalue means data points are spread far apart on this road — it is a useful axis. A small eigenvalue means data points are all clustered close together on this road — the highway goes nowhere interesting.

PCA finds the best roads (eigenvectors) ranked by traffic (eigenvalues) and keeps only the busiest ones.
कल्पना करें कि आप feature space में एक यात्री हैं। आपका data इस space में फैला है और आप एक ऐसा highway बनाना चाहते हैं जो सबसे ज़्यादा traffic (जानकारी) ले जाए।

Eigenvector सड़क की दिशा बताता है — highway किस कोण पर बनाना है। यह उत्तर-दक्षिण, पूर्व-पश्चिम या तिरछा हो सकता है। Eigenvector ठीक वह कोण चुनता है जिस पर उस सड़क के साथ आपका data सबसे ज़्यादा फैला हो।

Eigenvalue बताता है कि सड़क कितना traffic ले जाती है — उस highway के साथ फैले data का कुल variance. बड़ा eigenvalue मतलब इस सड़क पर data points दूर-दूर फैले हैं — यह काम का axis है। छोटा eigenvalue मतलब इस सड़क पर data points पास-पास जमा हैं — highway कहीं दिलचस्प नहीं जाता।

PCA सबसे अच्छी सड़कें (eigenvectors) traffic (eigenvalues) के हिसाब से क्रम में खोजता है और सिर्फ़ सबसे व्यस्त सड़कें रखता है।
想象你是特征空间里的一名旅行者。你的数据散布在这个空间里,你想修一条运送最多车流(信息)的高速公路。

特征向量告诉你道路的方向 —— 公路该朝哪个角度修。 它可能是南北向、东西向,或者斜向。特征向量选出的正是能让数据沿这条路散布最大的那个角度。

特征值告诉你这条路承载多少车流 —— 也就是数据沿这条公路散布的总方差。 特征值大,说明数据点在这条路上分得很开 —— 这是一条有用的轴;特征值小,说明数据点在这条路上都挤在一起 —— 这条公路没通向任何有意思的地方。

PCA 找出最好的道路(特征向量),按车流量(特征值)排序,只保留最繁忙的那几条。
Scenarioस्थिति情形EigenvalueEigenvalue特征值EigenvectorEigenvector特征向量What It Meansइसका मतलब含义
Two features perfectly correlatedदो features पूरी तरह correlated两个特征完全相关λ₁ = total variance, λ₂ = 0λ₁ = कुल variance, λ₂ = 0λ₁ = 总方差,λ₂ = 0e₁ = [0.707, 0.707]Data lies on a 1D line. One PC captures everything. Second PC is pure noise.Data एक 1D line पर है। एक PC सब कुछ पकड़ लेता है। दूसरा PC सिर्फ़ noise है।数据落在一条一维直线上。一个主成分就捕获了全部,第二个主成分纯属噪声。
Two features completely uncorrelatedदो features बिल्कुल uncorrelated两个特征完全不相关λ₁ = Var(x₁), λ₂ = Var(x₂)λ₁ = Var(x₁), λ₂ = Var(x₂)λ₁ = Var(x₁),λ₂ = Var(x₂)e₁ = [1, 0], e₂ = [0, 1]PCs = original axes. PCA adds nothing — features are already orthogonal.PCs = original axes. PCA कुछ नहीं जोड़ता — features पहले से orthogonal हैं।主成分 = 原坐标轴。PCA 没有带来任何改变 —— 特征本来就正交。
Two features equal variance, correlatedदो features, बराबर variance, correlated两个特征方差相等且相关λ₁ > λ₂, both non-zeroλ₁ > λ₂, दोनों non-zeroλ₁ > λ₂,都不为零e₁ = [0.707, 0.707]Our exact example. Data is an ellipse tilted at 45°. PCA rotates it upright.यही हमारा example है। Data 45° पर झुका एक ellipse है। PCA उसे सीधा कर देता है।这正是我们的例子。数据是一个倾斜 45° 的椭圆,PCA 把它转正。
Feature with zero varianceZero variance वाला feature方差为零的特征λ = 0 for that directionउस दिशा के लिए λ = 0该方向上 λ = 0Points along that featureउस feature की दिशा में指向该特征方向All samples have the same value for this feature. It is a constant — zero information.इस feature में सभी samples की value एक जैसी है। यह constant है — zero जानकारी।所有样本在该特征上取值相同,它是常数 —— 没有任何信息。
All eigenvalues equalसभी eigenvalues बराबर所有特征值相等λ₁ = λ₂ = ... = λₚAny orthogonal set worksकोई भी orthogonal set चलेगा任何正交基都可以Data cloud is a perfect hypersphere. PCA is undefined — no preferred direction.Data का बादल एक perfect hypersphere है। PCA तय नहीं हो सकता — कोई पसंदीदा दिशा नहीं।数据点云是完美的超球体。PCA 的方向不唯一 —— 没有优先方向。
🔑
The Most Important Identity in PCAPCA की सबसे ज़रूरी समानताPCA 中最重要的恒等式

Trace(C) = Σ eigenvalues = Total variance of all features

In our example: Trace(C) = C[1,1] + C[2,2] = 8/3 + 8/3 = 16/3
Sum of eigenvalues: 4 + 4/3 = 12/3 + 4/3 = 16/3 ✓

This identity means PCA is a conservation law: it never creates or destroys variance. It only redistributes it — concentrating as much as possible into the first few axes. The total information in your data is exactly preserved. What you discard by keeping only k PCs is precisely the variance of the dropped components.

Trace(C) = Σ eigenvalues = सभी features का कुल variance

हमारे example में: Trace(C) = C[1,1] + C[2,2] = 8/3 + 8/3 = 16/3
Eigenvalues का जोड़: 4 + 4/3 = 12/3 + 4/3 = 16/3 ✓

इस समानता का मतलब है कि PCA एक संरक्षण नियम (conservation law) है: यह variance न बनाता है, न मिटाता है। यह उसे सिर्फ़ फिर से बाँटता है — जितना हो सके उतना पहले कुछ axes में इकट्ठा करता है। आपके data की कुल जानकारी पूरी तरह बची रहती है। सिर्फ़ k PCs रखने पर आप ठीक उतना ही खोते हैं जितना हटाए गए components का variance है।

Trace(C) = Σ 特征值 = 所有特征的总方差

在我们的例子中:Trace(C) = C[1,1] + C[2,2] = 8/3 + 8/3 = 16/3
特征值之和:4 + 4/3 = 12/3 + 4/3 = 16/3 ✓

这个恒等式说明 PCA 是一条守恒定律:它既不创造方差,也不消灭方差, 只是把方差重新分配 —— 尽可能集中到前几条轴上。数据中的总信息被完整保留。 只保留 k 个主成分时,你丢掉的恰好就是被舍弃主成分的方差。


SectionSection第 20 节

Practical Significance — What These Numbers Mean for Your Dataव्यावहारिक महत्व — इन Numbers का आपके Data के लिए मतलब实际意义 — 这些数字对你的数据意味着什么

①
Eigenvalue Tells You the Signal-to-Noise Ratio of a ComponentEigenvalue किसी Component का Signal-to-Noise Ratio बताता है特征值告诉你一个主成分的信噪比
In real datasets, the first few eigenvalues are large (signal — genuine patterns in the data) and the rest are small (noise — random measurement error, irrelevant fluctuations). The point where the eigenvalue curve bends sharply downward — the "elbow" in a scree plot — is the boundary between signal PCs and noise PCs. Keep everything before the elbow. Discard everything after. The eigenvectors of large eigenvalues encode real structure; eigenvectors of near-zero eigenvalues encode noise directions.
असली datasets में पहले कुछ eigenvalues बड़े होते हैं (signal — data के असली patterns) और बाकी छोटे (noise — random measurement error, बेकार उतार-चढ़ाव)। जहाँ eigenvalue curve तेज़ी से नीचे मुड़ता है — scree plot का "elbow" — वही signal PCs और noise PCs की सीमा है। Elbow से पहले का सब रखें। बाद का सब हटाएँ। बड़े eigenvalues के eigenvectors असली ढाँचा दिखाते हैं; zero के पास वाले eigenvalues के eigenvectors noise की दिशाएँ दिखाते हैं।
在真实数据集中,前几个特征值很大(信号 —— 数据中真实的规律),其余的很小(噪声 —— 随机测量误差、无关的波动)。 特征值曲线急剧下弯的地方 —— 碎石图中的"肘部"—— 就是信号主成分与噪声主成分的分界。 保留肘部之前的全部,丢掉之后的全部。大特征值对应的特征向量编码了真实结构; 接近零的特征值对应的特征向量编码的是噪声方向。
②
Eigenvector Loadings Tell You Which Original Features Drive Each PCEigenvector Loadings बताती हैं कि कौन से Original Features हर PC को चलाते हैं特征向量载荷告诉你哪些原始特征驱动每个主成分
In a real dataset with 10 features, the first eigenvector might look like: [0.52, 0.48, 0.01, 0.02, −0.01, 0.49, 0.51, 0.00, 0.01, 0.02]. Features 1, 2, 6, 7 have large loadings. This PC represents "the combined level of features 1, 2, 6, 7" — perhaps they all relate to one underlying latent factor (e.g. socioeconomic status in survey data). The eigenvector has given you a data-driven grouping of related features — something domain analysis alone might miss.
10 features वाले किसी असली dataset में पहला eigenvector कुछ ऐसा दिख सकता है: [0.52, 0.48, 0.01, 0.02, −0.01, 0.49, 0.51, 0.00, 0.01, 0.02]. Features 1, 2, 6, 7 की loadings बड़ी हैं। यह PC "features 1, 2, 6, 7 का मिला-जुला स्तर" दिखाता है — शायद ये सब एक छिपे हुए factor से जुड़े हैं (जैसे survey data में सामाजिक-आर्थिक स्थिति)। Eigenvector ने आपको data के आधार पर जुड़े features का एक group दे दिया — जो सिर्फ़ domain analysis से छूट सकता था।
在一个有 10 个特征的真实数据集中,第一个特征向量可能是: [0.52, 0.48, 0.01, 0.02, −0.01, 0.49, 0.51, 0.00, 0.01, 0.02]。 特征 1、2、6、7 的载荷很大。这个主成分代表"特征 1、2、6、7 的综合水平"—— 它们可能都与同一个潜在因子有关(例如调查数据中的社会经济地位)。 特征向量为你提供了一个由数据驱动的相关特征分组 —— 这是只靠领域分析可能会漏掉的。
③
Eigenvalue Ratio Tells You How Redundant Your Features AreEigenvalue Ratio बताता है कि आपके Features में कितना दोहराव है特征值比例告诉你特征有多冗余
If the first eigenvalue captures 99% of the variance in a 50-feature dataset, it means 49 of your features are essentially redundant — they are all measuring the same underlying thing. The dataset's effective dimensionality is close to 1, not 50. Conversely, if eigenvalues are roughly equal, all features contribute unique information and PCA provides little compression benefit.
अगर 50-feature dataset में पहला eigenvalue 99% variance पकड़ता है, तो इसका मतलब आपके 49 features असल में दोहराव हैं — वे सब एक ही चीज़ माप रहे हैं। Dataset की effective dimensionality 50 नहीं, लगभग 1 है। इसके उलट, अगर eigenvalues लगभग बराबर हैं, तो हर feature अलग जानकारी देता है और PCA से compression का ज़्यादा फ़ायदा नहीं।
如果在一个 50 个特征的数据集中,第一个特征值捕获了 99% 的方差, 说明其中 49 个特征基本是冗余的 —— 它们都在测量同一个底层因素。 该数据集的有效维度接近 1,而不是 50。反过来,如果特征值大致相等, 说明每个特征都提供独特的信息,PCA 带来的压缩收益就很小。
④
Eigenvectors of the Largest Eigenvalues Are the Most Stableसबसे बड़े Eigenvalues के Eigenvectors सबसे Stable होते हैं最大特征值对应的特征向量最稳定
When you add more data, the eigenvectors corresponding to large eigenvalues stay nearly constant — they represent robust, real structure. Eigenvectors corresponding to small eigenvalues are unstable — small perturbations in data can rotate them significantly. This is why discarding small-eigenvalue PCs not only saves dimensions but also improves robustness: you are keeping only the stable, reproducible structure.
जब आप और data जोड़ते हैं, तो बड़े eigenvalues वाले eigenvectors लगभग वैसे ही रहते हैं — वे मज़बूत, असली ढाँचा दिखाते हैं। छोटे eigenvalues वाले eigenvectors अस्थिर होते हैं — data में छोटे बदलाव भी उन्हें काफ़ी घुमा सकते हैं। इसीलिए छोटे eigenvalue वाले PCs हटाने से सिर्फ़ dimensions नहीं बचते, बल्कि मज़बूती भी बढ़ती है: आप सिर्फ़ stable, दोहराया जा सकने वाला ढाँचा रखते हैं।
当你加入更多数据时,大特征值对应的特征向量几乎保持不变 —— 它们代表稳健、真实的结构。 小特征值对应的特征向量不稳定 —— 数据的微小扰动就可能让它们明显转向。 这就是为什么丢弃小特征值的主成分不仅节省维度,还能提高稳健性:你只保留了稳定、可复现的结构。
📈 How to Read Eigenvalues and Eigenvectors in a Real Projectअसली Project में Eigenvalues और Eigenvectors कैसे पढ़ें如何在真实项目中解读特征值和特征向量
Q1
"My first eigenvalue is 10× larger than the rest. What does that mean?"
Your data has one overwhelming dominant pattern. Almost all variation in your dataset can be described by a single axis. The data is effectively 1-dimensional. Check if this dominant PC correlates with a confounding variable (e.g. sample size, batch effect).
"मेरा पहला eigenvalue बाकियों से 10× बड़ा है। इसका क्या मतलब है?"
आपके data में एक बहुत हावी pattern है। आपके dataset का लगभग सारा बदलाव एक axis से बताया जा सकता है। Data असल में 1-dimensional है। जाँचें कि कहीं यह हावी PC किसी confounding variable (जैसे sample size, batch effect) से तो नहीं जुड़ा।
"我的第一个特征值比其他的大 10 倍,这说明什么?"
你的数据中有一个压倒性的主导模式,数据集中几乎所有变化都能用一条轴来描述,数据实际上是一维的。 要检查这个主导主成分是否与某个混杂变量(如样本量、批次效应)相关。
Q2
"Two of my eigenvectors have very similar eigenvalues. Which is PC1 and which is PC2?"
When eigenvalues are nearly equal, the corresponding eigenvectors are numerically unstable — small changes in data can swap them or rotate them into each other. They span the same 2D subspace, but their individual directions are unreliable. Do not over-interpret individual loadings from nearly degenerate eigenvalues.
"मेरे दो eigenvectors के eigenvalues लगभग बराबर हैं। कौन PC1 है और कौन PC2?"
जब eigenvalues लगभग बराबर हों, तो उनके eigenvectors numerically unstable होते हैं — data में छोटे बदलाव उन्हें आपस में बदल या घुमा सकते हैं। वे एक ही 2D subspace बनाते हैं, पर उनकी अलग-अलग दिशाओं पर भरोसा नहीं किया जा सकता। लगभग बराबर eigenvalues की loadings का ज़्यादा मतलब न निकालें।
"我有两个特征向量的特征值非常接近,哪个是 PC1,哪个是 PC2?"
当特征值几乎相等时,对应的特征向量在数值上不稳定 —— 数据的微小变化就可能让它们互换或互相旋转。 它们张成同一个二维子空间,但各自的方向并不可靠。不要过度解读近乎简并的特征值所对应的单个载荷。
Q3
"My eigenvector for PC1 has high loadings only on features 3 and 7. What does that mean?"
Features 3 and 7 together explain most of the variance in your data. They are the most informative features. They likely share an underlying cause — look for a domain explanation. This is also a signal that a simpler 2-feature model using only features 3 and 7 might perform nearly as well as the full model.
"मेरे PC1 के eigenvector में सिर्फ़ features 3 और 7 की loadings बड़ी हैं। इसका क्या मतलब है?"
Features 3 और 7 मिलकर आपके data का ज़्यादातर variance समझाते हैं। ये सबसे ज़्यादा जानकारी वाले features हैं। शायद इनकी कोई साझा वजह है — domain में उसकी व्याख्या खोजें। यह इस बात का भी संकेत है कि सिर्फ़ features 3 और 7 वाला एक सरल 2-feature model लगभग पूरे model जितना अच्छा चल सकता है।
"我的 PC1 特征向量只在特征 3 和 7 上有较大载荷,这说明什么?"
特征 3 和 7 一起解释了数据中大部分的方差,它们是信息量最大的特征,很可能有共同的成因 —— 去领域知识里找解释。 这也提示:只用特征 3 和 7 的简单双特征 model,表现可能和完整 model 差不多。
Q4
"My last 5 eigenvalues are all near zero. Should I always discard them?"
Yes in almost every case. Near-zero eigenvalues mean near-zero variance — those PCs are noise directions. However, if you are doing anomaly detection, outliers sometimes appear in these low-variance directions (they differ from the main data cloud in unusual ways), so check first before discarding.
"मेरे आख़िरी 5 eigenvalues सब zero के पास हैं। क्या उन्हें हमेशा हटा दूँ?"
लगभग हर मामले में हाँ। Zero के पास eigenvalues का मतलब लगभग zero variance — वे PCs noise की दिशाएँ हैं। पर अगर आप anomaly detection कर रहे हैं, तो outliers कभी-कभी इन्हीं कम variance वाली दिशाओं में दिखते हैं (वे मुख्य data बादल से असामान्य तरीके से अलग होते हैं), इसलिए हटाने से पहले जाँच लें।
"我最后 5 个特征值都接近零,是不是都应该丢掉?"
几乎所有情况下都应该。接近零的特征值意味着方差接近零 —— 这些主成分是噪声方向。 不过,如果你在做异常检测,异常点有时恰好出现在这些低方差方向上(它们以不寻常的方式偏离主数据云), 所以丢弃之前先检查一下。