use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization in project elki by elki-project.
the class SpacefillingKNNPreprocessorTest method testCauchy.
@Test
public void testCauchy() {
Database db = AbstractSimpleAlgorithmTest.makeSimpleDatabase(dataset, shoulds);
Relation<DoubleVector> rel = db.getRelation(TypeUtil.DOUBLE_VECTOR_FIELD);
DistanceQuery<DoubleVector> distanceQuery = db.getDistanceQuery(rel, EuclideanDistanceFunction.STATIC);
// get linear queries
LinearScanDistanceKNNQuery<DoubleVector> lin_knn_query = new LinearScanDistanceKNNQuery<>(distanceQuery);
// get preprocessed queries
ListParameterization config = new ListParameterization();
//
config.addParameter(//
SpacefillingKNNPreprocessor.Factory.Parameterizer.CURVES_ID, //
HilbertSpatialSorter.class.getName() + "," + PeanoSpatialSorter.class.getName() + "," + ZCurveSpatialSorter.class.getName() + "," + BinarySplitSpatialSorter.class.getName());
config.addParameter(SpacefillingKNNPreprocessor.Factory.Parameterizer.DIM_ID, 7);
config.addParameter(SpacefillingKNNPreprocessor.Factory.Parameterizer.PROJECTION_ID, CauchyRandomProjectionFamily.class);
config.addParameter(SpacefillingKNNPreprocessor.Factory.Parameterizer.VARIANTS_ID, 10);
config.addParameter(SpacefillingKNNPreprocessor.Factory.Parameterizer.WINDOW_ID, 5.);
config.addParameter(SpacefillingKNNPreprocessor.Factory.Parameterizer.RANDOM_ID, 0L);
config.addParameter(CauchyRandomProjectionFamily.Parameterizer.RANDOM_ID, 0L);
SpacefillingKNNPreprocessor.Factory<DoubleVector> preprocf = ClassGenericsUtil.parameterizeOrAbort(SpacefillingKNNPreprocessor.Factory.class, config);
SpacefillingKNNPreprocessor<DoubleVector> preproc = preprocf.instantiate(rel);
preproc.initialize();
// add as index
db.getHierarchy().add(rel, preproc);
KNNQuery<DoubleVector> preproc_knn_query = preproc.getKNNQuery(distanceQuery, k);
assertFalse("Preprocessor knn query class incorrect.", preproc_knn_query instanceof LinearScanDistanceKNNQuery);
// test queries
testKNNQueries(rel, lin_knn_query, preproc_knn_query, k);
// also test partial queries, forward only
testKNNQueries(rel, lin_knn_query, preproc_knn_query, k / 2);
}
use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization in project elki by elki-project.
the class MTreeTest method testMetrical.
/**
* Test {@link MTree} using a file based database connection.
*/
@Test
public void testMetrical() {
ListParameterization metparams = new ListParameterization();
metparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, MTreeFactory.class);
metparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
testExactEuclidean(metparams, MetricalIndexKNNQuery.class, MetricalIndexRangeQuery.class);
}
use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization in project elki by elki-project.
the class KNNJoinTest method testKNNJoinRtreeMini.
/**
* Test {@link RStarTree} using a file based database connection.
*/
@Test
public void testKNNJoinRtreeMini() {
ListParameterization spatparams = new ListParameterization();
spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 200);
doKNNJoin(spatparams);
}
use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization in project elki by elki-project.
the class KNNJoinTest method testKNNJoinRtreeMaxi.
/**
* Test {@link RStarTree} using a file based database connection.
*/
@Test
public void testKNNJoinRtreeMaxi() {
ListParameterization spatparams = new ListParameterization();
spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 2000);
doKNNJoin(spatparams);
}
use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization in project elki by elki-project.
the class DeLiCluTest method testDeLiCluResults.
/**
* Run DeLiClu with fixed parameters and compare the result to a golden
* standard.
*/
@Test
public void testDeLiCluResults() {
ListParameterization indexparams = new ListParameterization();
// We need a special index for this algorithm:
indexparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class);
indexparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 1000);
Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710, indexparams);
Clustering<?> clustering = //
new ELKIBuilder<>(OPTICSXi.class).with(DeLiClu.Parameterizer.MINPTS_ID, //
18).with(OPTICSXi.Parameterizer.XI_ID, //
0.038).with(OPTICSXi.Parameterizer.XIALG_ID, //
DeLiClu.class).build().run(db);
// Test F-Measure
Clustering<Model> rbl = new ByLabelClustering().run(db);
ClusterContingencyTable ct = new ClusterContingencyTable(true, false);
ct.process(clustering, rbl);
double score = ct.getPaircount().f1Measure();
// identical each time, the results will vary.
if (Math.abs(score - 0.8771174) < 1e-5) {
assertEquals("Score does not match.", 0.8771174, score, 1e-5);
} else {
assertEquals("Score does not match.", 0.8819664, score, 1e-5);
}
}
Aggregations