Search in sources :

Example 1 with SLINK

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK in project elki by elki-project.

the class HDBSCANHierarchyExtractionTest method testSLINKResults.

@Test
public void testSLINKResults() {
    Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330);
    HDBSCANHierarchyExtraction slink = // 
    new ELKIBuilder<>(HDBSCANHierarchyExtraction.class).with(HDBSCANHierarchyExtraction.Parameterizer.MINCLUSTERSIZE_ID, // 
    50).with(AbstractAlgorithm.ALGORITHM_ID, // 
    SLINK.class).build();
    testFMeasure(db, slink.run(db), 0.9407684);
    testClusterSizes(slink.run(db), new int[] { 8, 62, 104, 156 });
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) SLINK(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 2 with SLINK

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK in project elki by elki-project.

the class FileBasedSparseDoubleDistanceFunctionTest method testExternalDistance.

@Test
public void testExternalDistance() throws IOException {
    Database db = // 
    new ELKIBuilder<>(StaticArrayDatabase.class).with(AbstractDatabase.Parameterizer.DATABASE_CONNECTION_ID, // 
    DBIDRangeDatabaseConnection.class).with(DBIDRangeDatabaseConnection.Parameterizer.COUNT_ID, // 
    4).build();
    db.initialize();
    FileBasedSparseDoubleDistanceFunction df = new // 
    FileBasedSparseDoubleDistanceFunction(new AsciiDistanceParser(CSVReaderFormat.DEFAULT_FORMAT), null, Double.POSITIVE_INFINITY);
    // We need to read from a resource, instead of a file.
    df.loadCache(4, FileUtil.openSystemFile(FILENAME));
    SLINK<DBID> slink = new SLINK<>(df);
    CutDendrogramByHeight clus = new CutDendrogramByHeight(slink, 0.5, false);
    Clustering<DendrogramModel> c = clus.run(db);
    testClusterSizes(c, new int[] { 2, 2 });
}
Also used : DBID(de.lmu.ifi.dbs.elki.database.ids.DBID) Database(de.lmu.ifi.dbs.elki.database.Database) AbstractDatabase(de.lmu.ifi.dbs.elki.database.AbstractDatabase) StaticArrayDatabase(de.lmu.ifi.dbs.elki.database.StaticArrayDatabase) SLINK(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK) CutDendrogramByHeight(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.CutDendrogramByHeight) DendrogramModel(de.lmu.ifi.dbs.elki.data.model.DendrogramModel) StaticArrayDatabase(de.lmu.ifi.dbs.elki.database.StaticArrayDatabase) Test(org.junit.Test) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)

Example 3 with SLINK

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK in project elki by elki-project.

the class HDBSCANHierarchyExtractionTest method testSLINKDegenerate.

@Test
public void testSLINKDegenerate() {
    Database db = makeSimpleDatabase(UNITTEST + "3clusters-and-noise-2d.csv", 330);
    HDBSCANHierarchyExtraction slink = // 
    new ELKIBuilder<>(HDBSCANHierarchyExtraction.class).with(HDBSCANHierarchyExtraction.Parameterizer.MINCLUSTERSIZE_ID, // 
    1).with(AbstractAlgorithm.ALGORITHM_ID, // 
    SLINK.class).build();
    testFMeasure(db, slink.run(db), 0.497315);
    testClusterSizes(slink.run(db), new int[] { 0, 1, 329 });
}
Also used : Database(de.lmu.ifi.dbs.elki.database.Database) SLINK(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest) Test(org.junit.Test)

Example 4 with SLINK

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK in project elki by elki-project.

the class FileBasedSparseFloatDistanceFunctionTest method testExternalDistance.

@Test
public void testExternalDistance() throws IOException {
    Database db = // 
    new ELKIBuilder<>(StaticArrayDatabase.class).with(AbstractDatabase.Parameterizer.DATABASE_CONNECTION_ID, // 
    DBIDRangeDatabaseConnection.class).with(DBIDRangeDatabaseConnection.Parameterizer.COUNT_ID, // 
    4).build();
    db.initialize();
    FileBasedSparseFloatDistanceFunction df = new // 
    FileBasedSparseFloatDistanceFunction(new AsciiDistanceParser(CSVReaderFormat.DEFAULT_FORMAT), null, Float.POSITIVE_INFINITY);
    // We need to read from a resource, instead of a file.
    df.loadCache(4, FileUtil.openSystemFile(FILENAME));
    SLINK<DBID> slink = new SLINK<>(df);
    CutDendrogramByHeight clus = new CutDendrogramByHeight(slink, 0.5, false);
    Clustering<DendrogramModel> c = clus.run(db);
    testClusterSizes(c, new int[] { 2, 2 });
}
Also used : DBID(de.lmu.ifi.dbs.elki.database.ids.DBID) Database(de.lmu.ifi.dbs.elki.database.Database) AbstractDatabase(de.lmu.ifi.dbs.elki.database.AbstractDatabase) StaticArrayDatabase(de.lmu.ifi.dbs.elki.database.StaticArrayDatabase) SLINK(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK) CutDendrogramByHeight(de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.CutDendrogramByHeight) DendrogramModel(de.lmu.ifi.dbs.elki.data.model.DendrogramModel) StaticArrayDatabase(de.lmu.ifi.dbs.elki.database.StaticArrayDatabase) Test(org.junit.Test) AbstractClusterAlgorithmTest(de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)

Aggregations

AbstractClusterAlgorithmTest (de.lmu.ifi.dbs.elki.algorithm.clustering.AbstractClusterAlgorithmTest)4 SLINK (de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK)4 Database (de.lmu.ifi.dbs.elki.database.Database)4 Test (org.junit.Test)4 CutDendrogramByHeight (de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.CutDendrogramByHeight)2 DendrogramModel (de.lmu.ifi.dbs.elki.data.model.DendrogramModel)2 AbstractDatabase (de.lmu.ifi.dbs.elki.database.AbstractDatabase)2 StaticArrayDatabase (de.lmu.ifi.dbs.elki.database.StaticArrayDatabase)2 DBID (de.lmu.ifi.dbs.elki.database.ids.DBID)2