本文介绍了PCA降维的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行 PCA 将900尺寸缩小到10.

I am trying to perform PCA reducing 900 dimensions to 10. So far I have:

covariancex = cov(labels);
[V, d] = eigs(covariancex, 40);

pcatrain = (trainingData - repmat(mean(traingData), 699, 1)) * V;
pcatest = (test - repmat(mean(trainingData), 225, 1)) * V;

其中labels是字符(1-26)的1x699标签. trainingData699x900,用于699个字符的图像的900维数据. test225x900,225 900个维字符.

Where labels are 1x699 labels for chars (1-26). trainingData is 699x900, 900-dimensional data for the images of 699 chars. test is 225x900, 225 900-dimensional chars.

基本上,我想将其减小到225x10,即10个尺寸,但此时有点卡住了.

Basically I want to reduce this down to 225x10 i.e. 10 dimensions but am kind of stuck at this point.

推荐答案

协方差应该在您的trainingData中实现:

The covariance is supposed to implemented in your trainingData:

X = bsxfun(@minus, trainingData, mean(trainingData,1));
covariancex = (X'*X)./(size(X,1)-1);

[V D] = eigs(covariancex, 10);   % reduce to 10 dimension

Xtest = bsxfun(@minus, test, mean(trainingData,1));
pcatest = Xtest*V;

这篇关于PCA降维的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 12:54