Search in sources :

Example 11 with ClusterContingencyTable

use of de.lmu.ifi.dbs.elki.evaluation.clustering.ClusterContingencyTable in project elki by elki-project.

the class DeLiCluTest method testDeLiCluResults.

/**
 * Run DeLiClu with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testDeLiCluResults() {
    ListParameterization indexparams = new ListParameterization();
    // We need a special index for this algorithm:
    indexparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class);
    indexparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 1000);
    Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710, indexparams);
    Clustering<?> clustering = // 
    new ELKIBuilder<>(OPTICSXi.class).with(DeLiClu.Parameterizer.MINPTS_ID, // 
    18).with(OPTICSXi.Parameterizer.XI_ID, // 
    0.038).with(OPTICSXi.Parameterizer.XIALG_ID, // 
    DeLiClu.class).build().run(db);
    // Test F-Measure
    Clustering<Model> rbl = new ByLabelClustering().run(db);
    ClusterContingencyTable ct = new ClusterContingencyTable(true, false);
    ct.process(clustering, rbl);
    double score = ct.getPaircount().f1Measure();
    // identical each time, the results will vary.
    if (Math.abs(score - 0.8771174) < 1e-5) {
        assertEquals("Score does not match.", 0.8771174, score, 1e-5);
    } else {
        assertEquals("Score does not match.", 0.8819664, score, 1e-5);
    }
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) StaticArrayDatabase(de.lmu.ifi.dbs.elki.database.StaticArrayDatabase) 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) ListParameterization(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization) Test(org.junit.Test) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)

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