How to use Principal Component Analysis to reduce feature vector size?
1 view (last 30 days)
Show older comments
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 Comments
Answers (3)
Shashank Prasanna
on 1 May 2013
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 Comments
Adnan
on 6 Feb 2015
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 Comments
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!