MATLAB Answers

How do I find cluster center of each cluster gained from Spectral Clustering?

2 views (last 30 days)
Riley
Riley on 29 Mar 2021
Commented: Riley on 29 Mar 2021
Hi, I am using Spectral Clustering for data analysis recently and I found that Spectral Clustering function built in MATLAB only returns the cluster indicator (that is, "idx"). However, I actually need the cluster center of each cluster (similar to the centroid locations gained by k-means). How can I get it? Any idea or code would be very helpful.
Regards, Ning
  2 Comments
Riley
Riley on 29 Mar 2021
clear
clc
load('xi.mat');
K=100;
[idx]=spectralcluster(xi, K);
Thank you for reminding. This is code and data xi. 'idx' contains cluster indices of each sampling in xi.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 29 Mar 2021
As you have indices in hand, you can get the centers....
clear
clc
load('xi.mat');
K=100;
[idx]=spectralcluster(xi, K);
C = zeros(k,2) ;
for i = 1:k
c = xi(idx==i) ; % this will give cluster
C(i,:) = mean(c) ; % calculate the mean
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by