When using Kmeans in Weka, you can call getAssignments () on the resulting model output to get the cluster assignment for each given instance. Here is an example of (truncated) Jython:
>>>import weka.clusterers.SimpleKMeans as kmeans
>>>kmeans.buildClusterer(data)
>>>assignments = kmeans.getAssignments()
>>>assignments
>>>array('i',[14, 16, 0, 0, 0, 0, 16,...])
The index of each cluster number corresponds to the instance. So, instance 0 is in cluster 14, instance 1 is in cluster 16, etc.
My question is: is there something similar for Xmeans? I looked through the entire API here and don't see anything like it.
source
share