Re: Re: Question - Cluster Analysis
- To: mathgroup at smc.vnet.net
- Subject: [mg89857] Re: [mg89842] Re: Question - Cluster Analysis
- From: DrMajorBob <drmajorbob at att.net>
- Date: Mon, 23 Jun 2008 02:45:55 -0400 (EDT)
- References: <g3ihn2$fb6$1@smc.vnet.net>
- Reply-to: drmajorbob at longhorns.com
That's a much nicer way to parse the Clusters. Thanks! Bobby On Sun, 22 Jun 2008 02:24:29 -0500, magma <maderri2 at gmail.com> wrote: > On Jun 21, 11:30 am, Steve Mahoney <patrick.bernh... at gmx.net> wrote: >> Hello, >> >> I have a question regarding hierarchical cluster analysis. One measure >> to determine the number of clusters is the so called elbow criteria, >> which is just a list of the single distances between the clusters. >> >> These values are inside the results from the Agglomerate function, but >> I am not able to extract them to a list. >> >> data = {{1, 2, 2}, {1, 3, 3}, {2, 4, 2}, {5, 4, 3}, {5, 4, 4}, {7, 6, >> 7}}; >> >> Agglomerate[data] >> >> Cluster[Cluster[ >> Cluster[Cluster[{1, 2, 2}, {1, 3, 3}, 2, 1, 1], {2, 4, 2}, 3, 2, 1], >> Cluster[{5, 4, 3}, {5, 4, 4}, 1, 1, 1], 10, 3, 2], {7, 6, 7}, 17, 5, 1] >> >> --> now I have to extract the values manually >> >> elbowcriterium = ListLinePlot[{17, 10, 3, 2, 1}] >> >> --> suggesting three clusters >> >> Thanks a lot for a suggestion, how to handle this, which would be >> really helpful for me! > > Hello, > this was a good excuse for me to learn some cluster analysis in the > past 2 hours ! > Ok, now I know what you are talking about, so this is your function > > ElbowCriterium[ > cl_Cluster] := {cl[[3]], ElbowCriterium[cl[[1]]], > ElbowCriterium[cl[[2]]]} // Flatten > > ElbowCriterium[x_] := {} > > On your data: > > data = {{1, 2, 2}, {1, 3, 3}, {2, 4, 2}, {5, 4, 3}, {5, 4, 4}, {7, 6, > 7}}; > > Agglomerate[data] // ElbowCriterium > > the answer is.... > > {17, 10, 3, 2, 1} > > > -- DrMajorBob at longhorns.com