Java-ML provides a large number of cluster evaluation measures that are provided in the package net.sf.javaml.clustering.evaluation. All scores are measures for the quality of the clustering, i.e. how well it reflects the properties of the data. Mostly they try to quantify how well the data is separated in logical units by the clustering algorithm.
All scores implement the double score(Datasetclusters) method. This method returns a score for an array of datasets that is returned from a clustering algorithm. Typical usage is illustrated in the code snippet below.
- /* We load some data */
- Dataset data = FileHandler.loadDataset(new File("iris.data"), 4, ",");
- /* We create a clustering algorithm, in this case the k-means
- * algorithm with 4 clusters. */
- Clusterer km=new KMeans(4);
- /* We cluster the data */
- Dataset clusters = km.cluster(data);
- /* Create a measure for the cluster quality */
- ClusterEvaluation sse= new SumOfSquaredErrors();
- /* Measure the quality of the clustering */
- double score=sse.score(clusters);