Search in sources :

Example 1 with CutDendrogramByHeight

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.CutDendrogramByHeight 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 2 with CutDendrogramByHeight

use of de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.extraction.CutDendrogramByHeight 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)2 SLINK (de.lmu.ifi.dbs.elki.algorithm.clustering.hierarchical.SLINK)2 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 Database (de.lmu.ifi.dbs.elki.database.Database)2 StaticArrayDatabase (de.lmu.ifi.dbs.elki.database.StaticArrayDatabase)2 DBID (de.lmu.ifi.dbs.elki.database.ids.DBID)2 Test (org.junit.Test)2