KMeans Clusters and Plotting
pczjrh
I would like to create a plot of my data as clusters (different colours, or markers).
How would you go about creating tables of the clusters from the KMeans algorithm?
So, if we take the example in the documentation;
Make/O/N=(1,128) jack=4+gnoise(1)
jack[0][15,50]+=10
jack[0][60,]+=20
KMeans/init=1/out=1/ter=1/dead=1/tern=1000/ncls=5 jack
Print M_KMClasses
M_KMClasses[0][0]= {24.1439,68}
M_KMClasses[0][1]= {14.1026,36}
M_KMClasses[0][2]= {4.01537,24}
How would you go about plotting the 68 data points in class [0][0]?
I guess you need to identify the original data points in the wave and assign them a cluster number or split them into new waves... How do you do this?
Any help would be great,
Thanks in advance,
Jason.
Just use the /OUT=2 flag instead /OUT=1 as in the example.
This gives you W_KMMembers which specifies which class each data point falls in. Then you can use one of the various options you get when you open the Modify Trace Appearance dialog of the graph and click the "Set as f(z).." button. For example to use different markers and colors for the different classes, you could execute the following code:
ModifyGraph mode=3
ModifyGraph zmrkNum(jack)={W_KMMembers}
ModifyGraph zColor(jack)={W_KMMembers,*,*,Rainbow16,0}
October 27, 2009 at 08:42 am - Permalink