why 主成分分析?
线性回归
y=Xβ+ϵ
假设 X={X1,…,Xp} 相互独立, ϵ∼N(0,σ2) 。
实际应用中, {X1,…,Xp} 未必相互独立,可能是线性相关的。违背线性模型基本假设。
What is 主成分分析?
简单的说就是通过对 X={X1,…,Xp} 进行线性组合,得到不相关的 Xc={Xc1,…,Xcq},q≤p
维基百科的定义:
- Principal component analysis (PCA) uses an orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of linearly uncorrelated variables called principal components.
- The number of principal components is less than or equal to the number of original variables.
- The first principal component has the largest possible variance
- each succeeding component in turn has the highest variance possible under the constraint that it is orthogonal to the preceding components.
- The resulting vectors are an uncorrelated orthogonal basis set.
看图说话:
假设
p=2
, 解释变量有2个,而且从图中可以看出,两个变量之间高度相关。
所以建立新的坐标系,使得在新的坐标系下,两变量线性无关。
How 主成分分析?
如何找到主成分?
假设对原数据进行线性变换:
Xc=WTX,s.t.∥W∥=1
第一主成分
X(1)c=argmax{var(Xc1),…,var(Xcq)}
计算
Var(Xc)=WTXXTW
从而
X(1)c=λmax
λmax 是 XXT 的最大特征值。
利用主成分分析方法进行机器学习分类,关注的不再是“主成分是谁?”
而是“如何找到变换W?”
假设有
k
类,
目标:寻找W极大化
L(W)=(WTμ1−WTμ2)T(WTμ1−WTμ2)
s.t.
WT(Σ1+Σ2)W=1
直接求解,可得
W→(Σ1+Σ2)−1(μ1−μ2)
更多参考文献:
https://onlinecourses.science.psu.edu/stat505/node/49
https://www.cs.princeton.edu/picasso/mats/PCA-Tutorial-Intuition_jp.pdf