How to use Principal Component Analysis to reduce feature vector size?
1 次查看(过去 30 天)
显示 更早的评论
I am working on emotion recognition.Feature vector size i got is 90x21952(90 is the number of images and 21952 is the coefficients).How can i use princomponent analysis to reduce the feature vector dimension.I am using princomp to find the principal component after that wheter i need to multiply this with meanadjusted original data.If i do so the dimension is no reducing. Please help me.
0 个评论
回答(3 个)
Shashank Prasanna
2013-5-1
Use PCARES function to do that:
[residuals,reconstructed] = pcares(X,ndim)
The 'reconstructed' will have the reduced dimensions data based on the ndims input. Note that 'reconstructed' will still be the original dimension. You can choose the first ndims if you'd like.
If you want the reduced dimensions in the new basis then just take the first ndims of the SCORE variable
SCORE(:,1:ndims)
[COEFF,SCORE] = princomp(X)
0 个评论
Adnan
2015-2-6
Hello Shashank Prasanna, I am using this code to reduce the dimension of my image patch (104*53) If i put img (with out transpose) then the reduced dimension is 104x4, and if i put img'(transpose) then the output in 4x53. So what one is correct?
noofdim=4
[r,c] = size(img);
%Calculate cov matrix and the PCA matrixes
m = mean(img')';
S = ((img - m*ones(1,c)) * (img - m*ones(1,c))');
[Coeff latent]= eig(S);
[latent, ind] = sort(diag(latent), 'descend');
M1 = Coeff(:,ind(1:noofdim));
latent1 = latent(1:noofdim);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!