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 });
}
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 });
}
Aggregations