Reducing the dimension of training data using ATP in Matlab

This is the next question:

PCA Dimension Reduction

To classify the new 10-dimensional test data, do I have to reduce the training data to 10 dimensions?

I tried:

X = bsxfun(@minus, trainingData, mean(trainingData,1));           
covariancex = (X'*X)./(size(X,1)-1);                 
[V D] = eigs(covariancex, 10);   % reduce to 10 dimension
Xtrain = bsxfun(@minus, trainingData, mean(trainingData,1));  
pcatrain = Xtest*V;

But using a classifier with this and 10-dimensional test data gives very unreliable results? Is there something I am doing fundamentally wrong?

Edit:

X = bsxfun(@minus, trainingData, mean(trainingData,1));           
covariancex = (X'*X)./(size(X,1)-1);                 
[V D] = eigs(covariancex, 10);   % reduce to 10 dimension
Xtrain = bsxfun(@minus, trainingData, mean(trainingData,1));  
pcatrain = Xtest*V;

X = bsxfun(@minus, pcatrain, mean(pcatrain,1));           
covariancex = (X'*X)./(size(X,1)-1);                 
[V D] = eigs(covariancex, 10);   % reduce to 10 dimension
Xtest = bsxfun(@minus, test, mean(pcatrain,1));  
pcatest = Xtest*V;
+4
source share
1 answer

, , . , PCA , , . , , , .

% first, 0-mean data
Xtrain = bsxfun(@minus, Xtrain, mean(Xtrain,1));           
Xtest  = bsxfun(@minus, Xtest, mean(Xtrain,1));           

% Compute PCA
covariancex = (Xtrain'*Xtrain)./(size(Xtrain,1)-1);                 
[V D] = eigs(covariancex, 10);   % reduce to 10 dimension

pcatrain = Xtrain*V;
% here you should train your classifier on pcatrain and ytrain (correct labels)

pcatest = Xtest*V;
% here you can test your classifier on pcatest using ytest (compare with correct labels)
+7

All Articles