Need help on FCM clustering

Is any one knows how to create 5 clusters by using FCM please. I've number of samples across number of genes, I need to cluster them into 5 clusters but I couldn't figure this out in matlab.

回答 (5 件)

Walter Roberson
Walter Roberson 2011 年 11 月 26 日

0 投票

fcm(YourData, 5)
Each row of YourData should be a single sample.

17 件のコメント

Aiman Almazroey
Aiman Almazroey 2011 年 11 月 26 日
Hi Walter, thanks for your comments.
I had a look at FCM on matlab and I run the example problem for the 2-dimensional input data with 2 clusters. However, in my case I need to modify the code accordingly for multidimensional data with more than 2 clusters.
my data is 306 x 249, I need to cluster them into 5 groups?!!
So the question what I should do to let the code works on my data.
Walter Roberson
Walter Roberson 2011 年 11 月 26 日
Just pass your 306 x 249 array as the first argument to fcm, and pass 5 as the second argument. Have a look at that documentation link: the second argument is explicitly the number of clusters to return.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 26 日
I've done that,
load samples.txt;
[center,U,obj_fcn] = fcm(samples, 5);
%%But I've problem of plotting the 5 centres/clusters.
plot(samples(:,1),samples(:,2),'o');
%%here I'm looking for 5 groups but when I added samples(:,3), samples(:,4),....so on this didn't work
maxU = max(U);
index1 = find(U(1,:) == maxU);
index2 = find(U(2, :) == maxU);
%% here, how many index I should use is it 5 or less
line(samples(index1,1),samples(index1, 2),'linestyle','none',...
'marker','*','color','g');
line(samples(index2,1),samples(index2, 2),'linestyle','none',...
'marker', '*','color','r');
Walter Roberson
Walter Roberson 2011 年 11 月 27 日
Unfortunately the size and interpretation of the partition matrix is not documented in the reference, and I do not have that toolbox to experiment with. For your data, what does size(U) come out as?
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 27 日
I've played with this using many different ways, but couldn't figure out the problem. I can email you the matlab files if you like.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 27 日
I'm facing problem in, how I could get the 5 centres?..
Walter Roberson
Walter Roberson 2011 年 11 月 27 日
For your data, what does size(U) come out as?
Sending me the files will not help as I do not have that toolbox.
I have some suspicions about what would be needed, but I need that information to confirm or disprove it.
Also note that you will not be able to plot the centroid of data with more than 3 dimensions, as the centroids would be 4 or higher dimensional.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 27 日
U comes as 5x306.
I know that I need to modify the code accordingly for multidimensional data with more than 2 clusters.
Walter Roberson
Walter Roberson 2011 年 11 月 27 日
Okay, that shape of U is consistent with what I expected.
numclust = size(U,1);
centroids = zeros(size(U));
maxU = max(U);
for K = 1 : numclust
index = find(U(K,:) == maxU,1); %only take one in case multiple
centroids(K,:) = U(index,:);
end
From there you have the problem of plotting the point in 306 dimensions, at centroids(K,:) for cluster #K. Plotting in more than 3 dimensions is... ummm, not encouraged... by MATLAB.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 27 日
This is didn't work with me.
Here the matlab examble:
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');
In my case (how I should write the code to make its work) e.g.
load samples.txt
[center,U,obj_fcn] = fcm(samples, 5);
numclust = size(U,1);
centroids = zeros(size(U));
maxU = max(U);
for K = 1 : numclust
index = find(U(K,:) == maxU,1);
centroids(K,:) = U(index,:);
end
From the above I got this error "??? Improper assignment with rectangular empty matrix."
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 28 日
Hi Walter, any help please of how to solve this one please.
Walter Roberson
Walter Roberson 2011 年 11 月 28 日
It appears it is domestic duties day for me today.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 28 日
I didn't get your meaning here, but I'm trying to find a solution to my problem. If you have suggestion of where I should go to get an answer to my case I'd really appreciated.
Walter Roberson
Walter Roberson 2011 年 11 月 28 日
My meaning is that I have been doing housework and grocery shopping and laundry and the like all day, and have not time to work this through. Recall that I do not have this toolbox: I am having to recreate the algorithm and outputs by mental modelling of what calculations might be useful and working out what problems those calculations might run in to.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 28 日
Okay, take your time.
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 28 日
We know from FCM that it gives us the relation degree of each piece of data across all number of clusters.
therefore, we used the following command
[center,U,obj_fcn] = fcm(samples', 5,100);
now we need to plot them to see the 5 clusters but because we have more than 3 dimensions I don't know how to figure this out?
Aiman Almazroey
Aiman Almazroey 2011 年 11 月 29 日
Is there any one can help in this plz?

サインインしてコメントする。

Aiman Almazroey
Aiman Almazroey 2011 年 11 月 26 日

0 投票

Please someone help on this
YASSER
YASSER 2014 年 2 月 27 日

0 投票

hi I have the same your's problem, have you solved it please

2 件のコメント

Aiman Almazroey
Aiman Almazroey 2014 年 3 月 2 日
The issue was solved. Please specify your problem in which part, so I can help you.
YASSER
YASSER 2014 年 3 月 6 日
AFTER I apply FCM function, I don'knowt how to extract images clusters for example I use [center,U,obj_fcn] = fcm(data,3) what I have to do to get the 3 groups of Image

サインインしてコメントする。

soumi ghosh
soumi ghosh 2014 年 4 月 9 日

0 投票

Hello I have the same issue regarding fcm clusterinf of muti dimensional data set, need some help. Thank You

1 件のコメント

Tamilalagan Natarajan
Tamilalagan Natarajan 2014 年 9 月 5 日
Hi, I am trying to use FCM clustering. The only issue I still have is to identify the cluster center. If you have already found a solution, please can you share it.

サインインしてコメントする。

nur shidah ahmad
nur shidah ahmad 2016 年 12 月 8 日

0 投票

Do you have any idea to auto clustering the data? Since, i don't want set the cluster number and i want it to auto cluster.

1 件のコメント

Walter Roberson
Walter Roberson 2016 年 12 月 8 日
Yes, I know exactly how to get the best possible results in that situation: set the number of clusters to the number of unique points. Every cluster will then contain exactly one point (and any duplicates of it), which will always give you the best possible fitting, with no fitting error at all.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Clustering についてさらに検索

質問済み:

2011 年 11 月 26 日

コメント済み:

2016 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by