Clustering algorithms from Weka can be accessed in Java-ML through the WekeClusterer bridge. This class makes it easy to use a clustering algorithm from Weka in Java-ML.
In the example below, we load the iris dataset, we create a clusterer from Weka (XMeans), we wrap it in the bridge and use the bridge to do the clustering.
/* Load data */ /* Create Weka classifier */ XMeans xm = new XMeans(); /* Wrap Weka clusterer in bridge */ Clusterer jmlxm = new WekaClusterer(xm); /* Perform clustering */ Dataset[] clusters = jmlxm.cluster(data); /* Output results */