主成分分析 m×n 矩阵实现
有谁知道如何在matlab中对m×n矩阵进行主成分分析(PCA)以进行归一化?
Does anyone know how to implement the Principal component analysis (PCA) on a m-by-n matrix in matlab for normalization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设每一列都是一个样本(即,每个维度
m
有n
个样本),并且它首先存储在矩阵A
中必须减去列意味着:那么您想要对
1/size(Amm,2)*Amm*Amm'
进行特征值分解(您可以使用1/(size(Amm ,2)-1)
作为比例因子(如果您希望将插值作为无偏协方差矩阵):并且
v
的列将成为您的 PCA 向量。d
的条目将是您相应的“方差”。但是,如果您的
m
很大,那么这不是最好的方法,因为存储Amm*Amm'
不切实际。您想要计算:这次
u
包含您的 PCA 向量。s
的条目通过sqrt
与d
的条目相关。注意:如果
m
很大,还有另一种方法,即计算eig(1/size(Amm,2)*Amm
(注意与上面相比的转置切换)并做了一些小技巧,但这是一个较长的解释,所以我不会详细介绍。'*Amm);
Assuming each column is a sample (that is, you have
n
samples each of dimensionm
), and it's stored in a matrixA
you first have to subtract off the column means:then you want to do an eigenvalue decomposition on
1/size(Amm,2)*Amm*Amm'
(you can use1/(size(Amm,2)-1)
as a scale factor if you want an interpetation as an unbiased covariance matrix) with:And the columns of
v
are going to be your PCA vectors. The entries ofd
are going to be your corresponding "variances".However, if your
m
is huge then this is not the best way to go because storingAmm*Amm'
is not practical. You want to instead compute:This time
u
contains your PCA vectors. The entries ofs
are related to the entries ofd
by asqrt
.Note: there's another way to go if
m
is huge, i.e. computingeig(1/size(Amm,2)*Amm
(notice the switch of transposes as compared to above) and doing a little trickery, but it's a longer explanation so I won't get into it.'*Amm);