How can I get un-descend index of latent in pca function

조회 수: 12 (최근 30일)
WonJun Choi
WonJun Choi 2021년 6월 9일
댓글: WonJun Choi 2021년 6월 10일
Hi, I'm trying to practice Neuron Spike Sorting using pca and kmeans clustering.
When I plot latent from pca function, I only get latent values which is desecended.
I want to use only 3 of them that has most powerful influence..
However, I can't find the dimension index of the big three.
My final result of spikes sorting is queit not good. I put k=2 in kmenas, but when I plot those two group, it looks same.
I guess I have a mistake finding big three powerful dimension in raw data.
Please,
spikes has 80000x48 double.
Here is my code :
%Spike Sorting
load('spikes.mat'); %detected spikes
[coeff,score,latent,tsquared,explained,mu] = pca(spikes); %PCA analysis
nscore1 = normalize(score(:,1));
nscore2 = normalize(score(:,2)); %score data normalize
nscore(:,1) = nscore1;
nscore(:,2) = nscore2;
[idx,C] = kmeans(nscore,2); %idx is clustering index
Sidx = [spikes, idx];
for k=1:size(idx)
if(Sidx(k,2)==1)
figure(1)
title('cluster1 spikes')
plot(spikes(k,:))
hold on
end
end
for k=1:size(idx)
if(Sidx(k,2)==2)
figure(2)
title('cluster2 spikes')
plot(spikes(k,:))
hold on
end
end
load('spikes.mat'); %detected spikes
[coeff,score,latent,tsquared,explained,mu] = pca(spikes); %PCA analysis
nscore1 = normalize(score(:,1));
nscore2 = normalize(score(:,2));
nscore3 = normalize(score(:,47));
figure(1)
scatter(nscore1, nscore2);
title('Normalize score1 vs Normalize score2')
xlabel('Normalize score1')
ylabel('Normalize score2')
figure(2)
scatter(nscore1, nscore3);
title('Normalize score1 vs Normalize score3')
xlabel('Normalize score1')
ylabel('Normalize score3')
figure(3)
scatter(nscore2, nscore3)
title('Normalize score2 vs Normalize score3')
xlabel('Normalize score2')
ylabel('Normalize score3')
figure(4)
scatter3(nscore1, nscore2, nscore3)
title('Normalize score1,2,3')
xlabel('Normalize score1')
ylabel('Normalize score2')
zlabel('Normalize score3')
figure(5)
plot(latent, 'o')
title('principal component') %eigen plotting

채택된 답변

the cyclist
the cyclist 2021년 6월 9일
My answer to this question gives a detailed explanation of how to use MATLAB's pca function, including how to reduce the number of dimensions. Please read the question, my answer, the other users' comments, and my responses to those. I think it will help you.
  댓글 수: 3
the cyclist
the cyclist 2021년 6월 9일
Correct.
Just to be clear, you want all rows of the first 3 columns of score (so that you are using all observations of the PC features that contribute the most variation).
The sum of the first 3 values of explained will tell you what fraction of the original variation you have retained.
WonJun Choi
WonJun Choi 2021년 6월 10일
Thank you for your adivce! Hope you have great day.

댓글을 달려면 로그인하십시오.

추가 답변 (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