Search in sources :

Example 1 with TrivialAllInOne

use of de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne in project elki by elki-project.

the class ClusterContingencyTableTest method testCompareDatabases.

/**
 * Validate {@link ClusterContingencyTable} with respect to its ability to
 * compare data clusterings.
 */
@Test
public void testCompareDatabases() {
    Database db = AbstractSimpleAlgorithmTest.makeSimpleDatabase(dataset, shoulds);
    Clustering<Model> rai = new TrivialAllInOne().run(db);
    Clustering<Model> ran = new TrivialAllNoise().run(db);
    Clustering<?> rbl = new ByLabelClustering().run(db);
    assertEquals(1.0, computeFMeasure(rai, rai, false), Double.MIN_VALUE);
    assertEquals(1.0, computeFMeasure(ran, ran, false), Double.MIN_VALUE);
    assertEquals(1.0, computeFMeasure(rbl, rbl, false), Double.MIN_VALUE);
    assertEquals(0.009950248756218905, computeFMeasure(ran, rbl, true), Double.MIN_VALUE);
    assertEquals(0.0033277870216306157, computeFMeasure(rai, ran, true), Double.MIN_VALUE);
    assertEquals(0.5, /* 0.3834296724470135 */
    computeFMeasure(rai, rbl, false), Double.MIN_VALUE);
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) TrivialAllNoise(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllNoise) TrivialAllInOne(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne) ByLabelClustering(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering) Test(org.junit.Test) AbstractSimpleAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest)

Example 2 with TrivialAllInOne

use of de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne in project elki by elki-project.

the class VisualizerContext method generateDefaultClustering.

/**
 * Generate a default (fallback) clustering.
 *
 * @return generated clustering
 */
private Clustering<Model> generateDefaultClustering() {
    final Database db = ResultUtil.findDatabase(hier);
    Clustering<Model> c = null;
    try {
        // Try to cluster by labels
        ByLabelHierarchicalClustering split = new ByLabelHierarchicalClustering();
        c = split.run(db);
    } catch (NoSupportedDataTypeException e) {
        // Put everything into one
        c = new TrivialAllInOne().run(db);
    }
    return c;
}
Also used : NoSupportedDataTypeException(de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException) Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) TrivialAllInOne(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne) ByLabelHierarchicalClustering(de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelHierarchicalClustering)

Aggregations

TrivialAllInOne (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne)2 Model (de.lmu.ifi.dbs.elki.data.model.Model)2 Database (de.lmu.ifi.dbs.elki.database.Database)2 AbstractSimpleAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest)1 ByLabelClustering (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering)1 ByLabelHierarchicalClustering (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelHierarchicalClustering)1 TrivialAllNoise (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllNoise)1 NoSupportedDataTypeException (de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException)1 Test (org.junit.Test)1