The Story That Explains PCAवह कहानी जो PCA समझाती है一个解释 PCA 的故事
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.
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),以及聚类或分类之前的预处理。
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 维表示,而信息损失最小。
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 把它从二维降到一维,并尽可能多地保留方差。我们会手算每一步 —— 就像在数据科学考试的答题本上那样。
| SampleSample样本 | Feature x₁Feature x₁特征 x₁ | Feature x₂Feature x₂特征 x₂ |
|---|---|---|
| S1 | 1 | 2 |
| S2 | 3 | 4 |
| S3 | 5 | 4 |
| S4 | 3 | 6 |
① 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) → ⑦ 把数据投影到选中的主成分上
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),而不是它的绝对位置。 所以我们必须先平移数据,使它以原点为中心。 在此之前,我们需要每个特征的均值。
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]
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₄₁) / 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]
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)正好落在原点 —— 这是计算协方差的前提。
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
B₂ = (3 − 3, 4 − 4) = ( 0, 0)
B₃ = (5 − 3, 4 − 4) = ( 2, 0)
B₄ = (3 − 3, 6 − 4) = ( 0, 2)
| SampleSample样本 | x₁ | x₂ |
|---|---|---|
| S1 | 1 | 2 |
| S2 | 3 | 4 |
| S3 | 5 | 4 |
| S4 | 3 | 6 |
| SampleSample样本 | b₁ | b₂ |
|---|---|---|
| S1 | −2 | −2 |
| S2 | 0 | 0 |
| S3 | 2 | 0 |
| S4 | 0 | 2 |
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,说明均值或减法算错了。
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。
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。
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]]
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]]
第 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,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,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,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协方差矩阵 C | x₁ | x₂ |
|---|---|---|
| x₁ | 8/3 ≈ 2.667 | 4/3 ≈ 1.333 |
| x₂ | 4/3 ≈ 1.333 | 8/3 ≈ 2.667 |
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 得到的就是原来的坐标轴,不会改变。
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
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
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
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
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)
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)
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)
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 对应第二大的,依此类推。 不要不排序就直接按求解器返回的顺序来分配主成分。
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)为单位长度。
= [[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]
= [[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]
= [[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]
= [[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]
= [[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]
= [[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]
Principal components are always perpendicular to each other. Non-zero dot product means calculation error.
Principal components हमेशा एक-दूसरे से 90° पर होते हैं। Dot product zero न हो तो हिसाब में गलती है।
主成分之间总是互相垂直。点积不为零说明计算有错。
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 के फ़ैसले का यही दिल है।
特征值告诉我们每个主成分捕获了多少方差。我们把它写成占总方差的百分比, 以决定保留几个主成分。这是降维决策的核心。
Σλ = λ₁ + λ₂ = 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 का 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?रखें?保留? |
|---|---|---|---|---|
| PC1 | 4.000 | 75.0 % | 75.0 % | YESहाँ是 |
| PC2 | 1.333 | 25.0 % | 100.0 % | OPTIONALवैकल्पिक可选 |
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。
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):用每一行中心化数据乘以特征向量。
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]
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]
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]
| SampleSample样本 | x₁ | x₂ |
|---|---|---|
| S1 | 1 | 2 |
| S2 | 3 | 4 |
| S3 | 5 | 4 |
| S4 | 3 | 6 |
| SampleSample样本 | PC1 ScorePC1 ScorePC1 得分 |
|---|---|
| S1 | −2.828 |
| S2 | 0.000 |
| S3 | 1.414 |
| S4 | 1.414 |
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(被丢弃的主成分)上不同。这正是降维固有的取舍。
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 解答,就像你在期末考试答卷里写的那样:
Key Formulae at a Glanceमुख्य Formulas एक नज़र में关键公式一览
Three Concepts Every PCA Student Must Understandतीन बातें जो हर PCA Student को समझनी चाहिए每个学 PCA 的学生都必须理解的三个概念
When to Use PCA — and When Not ToPCA कब इस्तेमाल करें — और कब नहीं什么时候用 PCA — 什么时候不用
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()}")
λ₁ = 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_}")
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 使用确定的符号约定;比较不同实现时,一定要检查是否一致。
PCA vs Other Dimensionality Reduction MethodsPCA vs दूसरे Dimensionality Reduction तरीकेPCA 与其他降维方法对比
| Propertyगुण属性 | PCA | t-SNE | UMAP | LDA |
|---|---|---|---|---|
| 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分类前的预处理 |
Golden Rules — PCA Non-Negotiablesसुनहरे नियम — PCA में ज़रूरी बातें黄金法则 — PCA 必须遵守的原则
StandardScaler before PCA in every sklearn pipeline.PCA से पहले StandardScaler इस्तेमाल करें।PCA 之前使用 StandardScaler。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.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 只需很小一部分计算量,就能得到几乎相同的结果。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 के संदर्भ में।
大多数教科书把特征向量定义为"方差最大的方向"就一笔带过。这没错,但浅得危险。 下面讲讲特征向量真正的含义 —— 从几何、代数以及你的数据这三个角度。
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.
Eigenvector एक ख़ास vector है जिसे matrix घुमाता नहीं। वह सिर्फ़ खिंचता या सिकुड़ता है। Matrix उसे एक scalar — eigenvalue — से गुणा करता है, बस।
Cv = λv
इसे ऐसे पढ़ें: "जब covariance matrix C, eigenvector v पर काम करता है, तो नतीजा v का ही scaled रूप होता है — वही दिशा, अलग आकार।"
PCA में: covariance matrix बताता है कि आपका data कैसे बदलता है। इसके eigenvectors feature space की वे दिशाएँ हैं जहाँ यह बदलाव शुद्ध है — न मिलावट, न घुमाव। ये data के आकार के स्वाभाविक axes हैं।
特征向量是一种特殊的向量,矩阵不会旋转它, 只会把它拉长或压缩。矩阵只是把它乘以一个标量 —— 特征值 —— 仅此而已。
Cv = λv
这样读:"当协方差矩阵 C 作用在特征向量 v 上时,结果只是 v 本身的缩放版 —— 方向相同,大小不同。"
在 PCA 中:协方差矩阵描述了数据如何变化。它的特征向量就是特征空间中变化纯粹的方向 —— 没有混合,没有旋转。它们是数据形状的天然坐标轴。
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)。 它们永远互相垂直。永远。
① 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₁).
① 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₁) के बराबर है।
① 实数特征值(没有复数)
② 两两正交(互相垂直)的特征向量
③ 一组完整的特征向量,能张成整个特征空间
这就是 PCA 能成立的原因。如果协方差矩阵不对称,特征向量可能指向复数方向,或者不正交 —— 整个方法就会崩溃。 C 一定对称,因为协方差本身是对称的:Cov(x₁,x₂) 永远等于 Cov(x₂,x₁)。
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 的方法。
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 到底表示什么?我们从头推导答案。
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.
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 से साबित हुआ नतीजा है।
投影的方差:
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 上的方差,恰好等于特征值 λ。 这不是定义 —— 而是由特征向量方程证明出来的结论。
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 ✓
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 को पूरी तरह बताते हैं:
它们密不可分。没有特征向量的特征值只是一个数字;没有特征值的特征向量只是一个方向。 合在一起,它们回答了完整描述一个主成分的两个问题:
| 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(正交) |
| 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 |
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.
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λ₁ = 总方差,λ₂ = 0 | e₁ = [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该方向上 λ = 0 | Points 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 的方向不唯一 —— 没有优先方向。 |
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 个主成分时,你丢掉的恰好就是被舍弃主成分的方差。
Practical Significance — What These Numbers Mean for Your Dataव्यावहारिक महत्व — इन Numbers का आपके Data के लिए मतलब实际意义 — 这些数字对你的数据意味着什么
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).
आपके data में एक बहुत हावी pattern है। आपके dataset का लगभग सारा बदलाव एक axis से बताया जा सकता है। Data असल में 1-dimensional है। जाँचें कि कहीं यह हावी PC किसी confounding variable (जैसे sample size, batch effect) से तो नहीं जुड़ा।
你的数据中有一个压倒性的主导模式,数据集中几乎所有变化都能用一条轴来描述,数据实际上是一维的。 要检查这个主导主成分是否与某个混杂变量(如样本量、批次效应)相关。
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.
जब eigenvalues लगभग बराबर हों, तो उनके eigenvectors numerically unstable होते हैं — data में छोटे बदलाव उन्हें आपस में बदल या घुमा सकते हैं। वे एक ही 2D subspace बनाते हैं, पर उनकी अलग-अलग दिशाओं पर भरोसा नहीं किया जा सकता। लगभग बराबर eigenvalues की loadings का ज़्यादा मतलब न निकालें।
当特征值几乎相等时,对应的特征向量在数值上不稳定 —— 数据的微小变化就可能让它们互换或互相旋转。 它们张成同一个二维子空间,但各自的方向并不可靠。不要过度解读近乎简并的特征值所对应的单个载荷。
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.
Features 3 और 7 मिलकर आपके data का ज़्यादातर variance समझाते हैं। ये सबसे ज़्यादा जानकारी वाले features हैं। शायद इनकी कोई साझा वजह है — domain में उसकी व्याख्या खोजें। यह इस बात का भी संकेत है कि सिर्फ़ features 3 और 7 वाला एक सरल 2-feature model लगभग पूरे model जितना अच्छा चल सकता है।
特征 3 和 7 一起解释了数据中大部分的方差,它们是信息量最大的特征,很可能有共同的成因 —— 去领域知识里找解释。 这也提示:只用特征 3 和 7 的简单双特征 model,表现可能和完整 model 差不多。
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.
लगभग हर मामले में हाँ। Zero के पास eigenvalues का मतलब लगभग zero variance — वे PCs noise की दिशाएँ हैं। पर अगर आप anomaly detection कर रहे हैं, तो outliers कभी-कभी इन्हीं कम variance वाली दिशाओं में दिखते हैं (वे मुख्य data बादल से असामान्य तरीके से अलग होते हैं), इसलिए हटाने से पहले जाँच लें।
几乎所有情况下都应该。接近零的特征值意味着方差接近零 —— 这些主成分是噪声方向。 不过,如果你在做异常检测,异常点有时恰好出现在这些低方差方向上(它们以不寻常的方式偏离主数据云), 所以丢弃之前先检查一下。