Search in sources :

Example 1 with Model

use of de.lmu.ifi.dbs.elki.data.model.Model in project elki by elki-project.

the class LSDBCTest method testLSDBCResults.

@Test
public void testLSDBCResults() {
    Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330);
    Clustering<Model> result = // 
    new ELKIBuilder<LSDBC<DoubleVector>>(LSDBC.class).with(LSDBC.Parameterizer.ALPHA_ID, // 
    0.4).with(LSDBC.Parameterizer.K_ID, // 
    20).build().run(db);
    testFMeasure(db, result, 0.44848979);
    testClusterSizes(result, new int[] { 38, 38, 41, 54, 159 });
}
Also used : ELKIBuilder(de.lmu.ifi.dbs.elki.utilities.ELKIBuilder) Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) DoubleVector(de.lmu.ifi.dbs.elki.data.DoubleVector) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 2 with Model

use of de.lmu.ifi.dbs.elki.data.model.Model 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 3 with Model

use of de.lmu.ifi.dbs.elki.data.model.Model in project elki by elki-project.

the class GriDBSCANTest method testGriDBSCANWide.

/**
 * Run DBSCAN with fixed parameters and compare the result to a golden
 * standard, with larger grid width (fewer cells, less redundancy).
 */
@Test
public void testGriDBSCANWide() {
    Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330);
    Clustering<Model> result = // 
    new ELKIBuilder<GriDBSCAN<DoubleVector>>(GriDBSCAN.class).with(DBSCAN.Parameterizer.EPSILON_ID, // 
    0.04).with(DBSCAN.Parameterizer.MINPTS_ID, // 
    20).with(GriDBSCAN.Parameterizer.GRID_ID, // 
    0.4).build().run(db);
    testFMeasure(db, result, 0.996413);
    testClusterSizes(result, new int[] { 29, 50, 101, 150 });
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) Test(org.junit.Test)

Example 4 with Model

use of de.lmu.ifi.dbs.elki.data.model.Model in project elki by elki-project.

the class GriDBSCANTest method testGriDBSCANResults.

/**
 * Run DBSCAN with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testGriDBSCANResults() {
    Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330);
    Clustering<Model> result = // 
    new ELKIBuilder<GriDBSCAN<DoubleVector>>(GriDBSCAN.class).with(DBSCAN.Parameterizer.EPSILON_ID, // 
    0.04).with(DBSCAN.Parameterizer.MINPTS_ID, // 
    20).with(GriDBSCAN.Parameterizer.GRID_ID, // 
    0.08).build().run(db);
    testFMeasure(db, result, 0.996413);
    testClusterSizes(result, new int[] { 29, 50, 101, 150 });
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) Test(org.junit.Test)

Example 5 with Model

use of de.lmu.ifi.dbs.elki.data.model.Model in project elki by elki-project.

the class SNNClusteringTest method testSNNClusteringResults.

/**
 * Run SNNClustering with fixed parameters and compare the result to a golden
 * standard.
 */
@Test
public void testSNNClusteringResults() {
    Database db = makeSimpleDatabase(UNITTEST + "different-densities-2d.ascii", 1200);
    Clustering<Model> result = // 
    new ELKIBuilder<SNNClustering<DoubleVector>>(SNNClustering.class).with(SNNClustering.Parameterizer.EPSILON_ID, // 
    77).with(SNNClustering.Parameterizer.MINPTS_ID, // 
    28).with(SharedNearestNeighborPreprocessor.Factory.NUMBER_OF_NEIGHBORS_ID, // 
    100).build().run(db);
    testFMeasure(db, result, 0.832371422);
    testClusterSizes(result, new int[] { 73, 228, 213, 219, 231, 236 });
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) Test(org.junit.Test)

Aggregations

Model (de.lmu.ifi.dbs.elki.data.model.Model)60 Database (de.lmu.ifi.dbs.elki.database.Database)29 Test (org.junit.Test)24 Clustering (de.lmu.ifi.dbs.elki.data.Clustering)21 Cluster (de.lmu.ifi.dbs.elki.data.Cluster)18 AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)17 ClusterModel (de.lmu.ifi.dbs.elki.data.model.ClusterModel)13 ModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)12 ELKIBuilder (de.lmu.ifi.dbs.elki.utilities.ELKIBuilder)11 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)10 ArrayList (java.util.ArrayList)9 DoubleVector (de.lmu.ifi.dbs.elki.data.DoubleVector)8 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)8 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)8 FiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress)7 HashMap (java.util.HashMap)5 ByLabelClustering (de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelClustering)3 SubspaceModel (de.lmu.ifi.dbs.elki.data.model.SubspaceModel)3 IndefiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.IndefiniteProgress)3 CorePredicate (de.lmu.ifi.dbs.elki.algorithm.clustering.gdbscan.CorePredicate)2