How to find relevent principal component .

3 views (last 30 days)
Hi,
I am trying to do PCA analysis on featurevector size 30x17600, where 30 is the number of images and 17600 is the number of coffecients.
How can I find how many principal componts are requied for corect represtntaion of data.
[M N]=size(feature_vector'); m=mean(feature_vector',2); m_adj = feature_vector' - repmat(double(m),1,N); [evectors, score, evalues] = princomp(feature_vector','econ');
How to find the revelent pricomponent for multiplying with mean adujsted data
feature_vector_final=feature_vector'*evectors;
Please help me.
Thanks in advance

Accepted Answer

Conrad
Conrad on 27 Mar 2013
Calculate the quantity:
cumsum(evalues)./sum(evalues)
The will show you the cumulative variance explained by keeping the first n components. You can also look at the following plot (called a scree plot):
xOffset = -0.2;
yOffset = 2;
nComponentsToShow = 5;
figure; hold on;
p(1) = bar(1e2*evalues(1:nComponentsToShow)/sum(evalues));
ylabel('Variance explained (%)');
xlabel('Factor');
set(p(1),'FaceColor','Black');
set(gca,'XTick',1:size(evalues,1));
for i = 1 : nComponentsToShow
text(i+xOffset,1e2*evalues(i)/sum(evalues)+yOffset,sprintf...
('%0.2f%%',1e2*sum(evalues(1:i))/sum(evalues)));
end
Looking at the total variance explained you can decide on how many components to keep.
Conrad
  1 Comment
DS
DS on 27 Mar 2013
Thanks for the reply.I tried with this code.In the y-axis I am getting high amplitude and showing above the bar as 96.04% for the 1st factor for the remaining i am getting very low amplitude and showing above the bar in the range of (96 % to 100).Whether it maens only first principal componnet is required? Also I have a doubt why the xoffset = -.2 and yoffset=2; Thanks in advance

Sign in to comment.

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!