Dimensions Reduction in Matlab using PCA

3 次查看(过去 30 天)
Hi;
I have a matrix of 35 columns, and I'm trying to reduce the dimension using PCA.
I run PCA on my data:
[coeff,score,latent,tsquared,explained,mu] = pca(data);
explained =
99.9955
0.0022
0.0007
0.0003
0.0002
0.0001
0.0001
0.0001
Then, by looking at explained vector I notice the value of the first is 99, so based on this I decided to take only the first compoenet. So I did the follwoing:
k=1;
X = bsxfun(@minus, data, mean(data)) * coeff(:, 1:k);
and Now, I used X for SVM training,
svmStruct = fitcsvm(X,Y,'Standardize',true, 'Prior','uniform','KernelFunction','linear','KernelScale','auto','Verbose',0,'IterationLimit', 1000000);
However, when I tried to do predict and calculate the miss-classification rate:
[label,score,cost]= predict(svmStruct, X) ;
The result was disappointing. I notice, when I select only one component (k=1), I got all classification wrong,however, as I increase number of included component (k), result is improving, as you can see from below diagram, but this doesn't make since according to explained, I should be fine with the first eginvector only.
Did I do any mistake?
Below diagram shows classification error for each number of included eginvector.

采纳的回答

Tom Lane
Tom Lane 2015-11-11
The first component explains most of the variation in the columns of DATA, but Y is not involved in that. Of course I don't understand your data. But it is certainly mathematically possible for Y to depend more strongly on a component that explains a lower amount of variance.
Also, for simplicity you may find it convenient to use the SCORE output from PCA instead of computing it yourself.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by