Search in sources :

Example 1 with ClusterContingencyTable

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);
}
Also used : Model(de.lmu.ifi.dbs.elki.data.model.Model) ByLabelClustering(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering) ClusterContingencyTable(de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)

Example 2 with ClusterContingencyTable

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();
}
Also used : ClusterContingencyTable(de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)

Example 3 with ClusterContingencyTable

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();
}
Also used : ClusterContingencyTable(de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)

Example 4 with ClusterContingencyTable

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();
}
Also used : ClusterContingencyTable(de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)

Example 5 with ClusterContingencyTable

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();
}
Also used : ClusterContingencyTable(de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)

Aggregations

ClusterContingencyTable (de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable)11 ByLabelClustering (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering)2 Model (de.lmu.ifi.dbs.elki.data.model.Model)2 AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)1 Database (de.lmu.ifi.dbs.elki.database.Database)1 StaticArrayDatabase (de.lmu.ifi.dbs.elki.database.StaticArrayDatabase)1 ListParameterization (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization)1 Test (org.junit.Test)1