I am clustering some data in matlab using the builtin fuzzy c means algorithm which returns C the cluster centers, U fuzzy partition matrix. So I know what the cluster centers are from C but how can I figure out which cluster center eac开发者_开发知识库h data point belongs to? using the fuzzy partition matrix or some other way?
I know it is a very old question but someone else might find helpful if I give the answer.
The following example is from the Matlab help. There are 2 clusters in the example.
index1 is the indices of the data point that belong to the cluster 1, and index2 is similar. So, using this info what you need is easily obtained.
data = rand(100, 2);
[center,U,obj_fcn] = fcm(data, 2);
plot(data(:,1), data(:,2),'o');
maxU = max(U);
index1 = find(U(1,:) == maxU);
index2 = find(U(2, :) == maxU);
line(data(index1,1),data(index1, 2),'linestyle','none',...
'marker','*','color','g');
line(data(index2,1),data(index2, 2),'linestyle','none',...
'marker', '*','color','r');
精彩评论