use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.
the class AbstractClusterAlgorithmTest method testFMeasure.
/**
* Test the clustering result by comparing the score with an expected value.
*
* @param database Database to test
* @param clustering Clustering result
* @param expected Expected score
*/
protected <O> void testFMeasure(Database database, Clustering<?> clustering, double expected) {
// Run by-label as reference
ByLabelClustering bylabel = new ByLabelClustering();
Clustering<Model> rbl = bylabel.run(database);
ClusterContingencyTable ct = new ClusterContingencyTable(true, false);
ct.process(clustering, rbl);
double score = ct.getPaircount().f1Measure();
Logging.getLogger(this.getClass()).verbose(this.getClass().getSimpleName() + " score: " + score + " expect: " + expected);
assertEquals(this.getClass().getSimpleName() + ": Score does not match.", expected, score, 0.0001);
}
use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.
the class ClusterContingencyTableTest method computeFMeasure.
private double computeFMeasure(Clustering<?> c1, Clustering<?> c2, boolean noise) {
ClusterContingencyTable ct = new ClusterContingencyTable(true, noise);
ct.process(c1, c2);
return ct.getPaircount().f1Measure();
}
use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.
the class ClusteringBCubedF1SimilarityFunction method distance.
@Override
public double distance(Clustering<?> o1, Clustering<?> o2) {
ClusterContingencyTable ct = new ClusterContingencyTable(false, true);
ct.process(o1, o2);
return 1. - ct.getBCubed().f1Measure();
}
use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.
the class ClusteringFowlkesMallowsSimilarityFunction method similarity.
@Override
public double similarity(Clustering<?> o1, Clustering<?> o2) {
ClusterContingencyTable ct = new ClusterContingencyTable(false, true);
ct.process(o1, o2);
return ct.getPaircount().fowlkesMallows();
}
use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.
the class ClusteringRandIndexSimilarityFunction method distance.
@Override
public double distance(Clustering<?> o1, Clustering<?> o2) {
ClusterContingencyTable ct = new ClusterContingencyTable(false, true);
ct.process(o1, o2);
return 1. - ct.getPaircount().randIndex();
}
Aggregations