cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
nikles
Level VI

Using the Hier Clust Function

Hi.  How can I sort a vector of data into clusters using the "Hier Clust()" function?  I'm aware this can be done for a data column in a table, using the tools in the Clustering menu. However, I'm interested in doing this without a table or involving a GUI.

 

Hier Clust() takes a data vector and returns a list of 5 vectors: {OldToNew, NewToOld, Leader, Joiner, Distance}.  So, perhaps a more specific question is: how can I use this information to assign a cluster to each item in my original vector?

 

Using JMP Pro 15.2.1

 

As always, thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
nikles
Level VI

Re: Using the Hier Clust Function

Answering my own question in case anyone finds it helpful.  I was able to find a way to determine the cluster for a vector of data x_vec (assuming nclusters) using this script:

hc_lis = Hier Clust(x_vec);
ldr_vec = Eval(hc_lis[3]);
jnr_vec = Eval(hc_lis[4]);
c_vec = (1::NItems(ldr_vec))`;     //initialize a vector that will become the cluster ids
For(i=1, i<=NItems(ldr_vec) - nclusters, i++,
	loc_vec = Loc(c_vec, jnr_vec[i]);
	c_vec[loc_vec] = ldr_vec[i];
);
c_aa = AssociativeArray(c_vec);
c_lis = c_aa << Get Keys;    //list of just the cluster ids

This returns c_vec, which is a matrix the same size as x_vec, where c_vec[I] = the cluster id number of x_vec[I].  Also returned is c_lis, which is just a list of the cluster ids.  

 

If there's a faster or more elegant way to do this, please let me know. 

 

 

View solution in original post

1 REPLY 1
nikles
Level VI

Re: Using the Hier Clust Function

Answering my own question in case anyone finds it helpful.  I was able to find a way to determine the cluster for a vector of data x_vec (assuming nclusters) using this script:

hc_lis = Hier Clust(x_vec);
ldr_vec = Eval(hc_lis[3]);
jnr_vec = Eval(hc_lis[4]);
c_vec = (1::NItems(ldr_vec))`;     //initialize a vector that will become the cluster ids
For(i=1, i<=NItems(ldr_vec) - nclusters, i++,
	loc_vec = Loc(c_vec, jnr_vec[i]);
	c_vec[loc_vec] = ldr_vec[i];
);
c_aa = AssociativeArray(c_vec);
c_lis = c_aa << Get Keys;    //list of just the cluster ids

This returns c_vec, which is a matrix the same size as x_vec, where c_vec[I] = the cluster id number of x_vec[I].  Also returned is c_lis, which is just a list of the cluster ids.  

 

If there's a faster or more elegant way to do this, please let me know.