> Thank you Peter for your reply, I have actually tried this Groovy code but unfortunately it did not work with clusterer = new weka.clusterers.EM().
> I believe it is related to the fact that EM does not use distances in clustering so I always get NullPointerException.
> Do you have any idea how to fix this?
The distance function needs to be initialized with the data it is
supposed to calculate the distances for, which happens implicitly
within SimpleKMeans.
For EM, you have to do this explicitly:
weka.core.EuclideanDistance distance = new weka.core.EuclideanDistance();
distance.setDontNormalize(true); // Turn normalisation off because
we have standardised the data
distance.setInstances(data); // initialize the distance function
Cheers, Peter