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

9 Ansichten (letzte 30 Tage)
WonJun Choi
WonJun Choi am 9 Jun. 2021
Kommentiert: WonJun Choi am 10 Jun. 2021
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

Akzeptierte Antwort

the cyclist
the cyclist am 9 Jun. 2021
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 Kommentare
the cyclist
the cyclist am 9 Jun. 2021
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 am 10 Jun. 2021
Thank you for your adivce! Hope you have great day.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by