4
$\begingroup$

I have a 1000 by 3 data matrix in which for each person we have 3 scores. I want to cluster those persons into 8 cluster using Agglomerative method. I did the clusetring by:

 class=FindClusters[data, 8, DistanceFunction -> ManhattanDistance, 
 Method -> {"Agglomerate", "Linkage" -> "Complete"}]

I want to find out how and which persons are classified into those 8 clusters.In other words, I want to have a vector of class membership for each person (similar to what we can get using ClusteringComponents[data,8,1]).

As an example, suppose we have this data set:

data={{3, 2, 4}, {1, 1, 0}, {5, 2, 4}, {2, 3, 2}, {4, 4, 4}, {3, 2, 4}, {3,
   2, 3}, {2, 1, 3}}

result of FindClusters is:

class = FindClusters[data, 3, DistanceFunction -> ManhattanDistance, 
  Method -> {"Agglomerate", "Linkage" -> "Complete"}]

{{{3, 2, 4}, {2, 3, 2}, {3, 2, 4}, {3, 2, 3}, {2, 1, 3}}, {{1, 1, 
   0}}, {{5, 2, 4}, {4, 4, 4}}}

through the output it can be seen that persons number 1,4,6,7&8 are classified in first cluster; person number 2 in second cluster and persons number 3&5 are in third cluster. I want to have a vector like:

{1,2,3,1,3,1,1,1}

then I can determine which person is located in which cluster and how many persons are in each cluster.

I decided to use FindClusters because I didn't get reasonable results from Agglomerate function for hierarchical clustering. My main aim is doing hierarchical clustering with different linkage functions.

Any help and additional ideas are appreciated.

Amin.

$\endgroup$
2
  • 1
    $\begingroup$ Could you include maybe a smaller sample of data, and the results you expect from a proper clustering? $\endgroup$ Commented Jun 11, 2013 at 3:38
  • $\begingroup$ @0x4A4D♦ I did. $\endgroup$
    – Amin
    Commented Jun 11, 2013 at 3:56

1 Answer 1

2
$\begingroup$

You can supply an optional label/argument to FindClusters. In this case, I've just labeled them with a list of integers

class = FindClusters[data -> Range[Length[data]], 3, 
  DistanceFunction -> ManhattanDistance, 
  Method -> {"Agglomerate", "Linkage" -> "Complete"}]

{{1, 4, 6, 7, 8}, {2}, {3, 5}}

which is the clustering labels you expected. Or just use

 ClusteringComponents[data, 8, 1, DistanceFunction -> ManhattanDistance, 
      Method -> "Agglomerate"]

to get the alternative form

{1, 2, 3, 4, 5, 1, 6, 7}

Note that FindCLusters and ClusteringComponents have pretty much the same options available.

$\endgroup$
9
  • $\begingroup$ this is close to what I want but I need to have that final vector which includes cluster membership. I can obtain that vector by using ClusteringComponents[d, 3, 1] but not from FindClusters. $\endgroup$
    – Amin
    Commented Jun 11, 2013 at 4:06
  • $\begingroup$ What advantage is there to using FindClusters over ClusteringComponents? $\endgroup$
    – bill s
    Commented Jun 11, 2013 at 4:26
  • $\begingroup$ I want to use hierarchical cluster analysis with different linkage functions so I thought that FindClusters is more appropriate.Do you have any idea? $\endgroup$
    – Amin
    Commented Jun 11, 2013 at 4:30
  • $\begingroup$ The Agglomerate function in HierarchicalClustering package didn't work for me (which uses different linkage functions) then I moved to FindClusters $\endgroup$
    – Amin
    Commented Jun 11, 2013 at 4:36
  • $\begingroup$ I used your ClusteringComponents[data, 8, 1, DistanceFunction -> ManhattanDistance, Method -> "Agglomerate"] but it didn't work for me.It gave me some error messages. $\endgroup$
    – Amin
    Commented Jun 11, 2013 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.