use of de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.rstar.RStarTreeNode in project elki by elki-project.
the class KNNJoinTest method doKNNJoin.
/**
* Actual test routine.
*
* @param inputparams
*/
void doKNNJoin(ListParameterization inputparams) {
Database db = AbstractSimpleAlgorithmTest.makeSimpleDatabase(dataset, shoulds, inputparams);
Relation<NumberVector> relation = db.getRelation(TypeUtil.NUMBER_VECTOR_FIELD);
// Euclidean
{
KNNJoin<DoubleVector, ?, ?> knnjoin = new KNNJoin<DoubleVector, RStarTreeNode, SpatialEntry>(EuclideanDistanceFunction.STATIC, 2);
Relation<KNNList> result = knnjoin.run(db);
MeanVariance meansize = new MeanVariance();
for (DBIDIter id = relation.getDBIDs().iter(); id.valid(); id.advance()) {
meansize.put(result.get(id).size());
}
org.junit.Assert.assertEquals("Euclidean mean 2NN set size", mean2nnEuclid, meansize.getMean(), 0.00001);
org.junit.Assert.assertEquals("Euclidean variance 2NN", var2nnEuclid, meansize.getSampleVariance(), 0.00001);
}
// Manhattan
{
KNNJoin<DoubleVector, ?, ?> knnjoin = new KNNJoin<DoubleVector, RStarTreeNode, SpatialEntry>(ManhattanDistanceFunction.STATIC, 2);
Relation<KNNList> result = knnjoin.run(db);
MeanVariance meansize = new MeanVariance();
for (DBIDIter id = relation.getDBIDs().iter(); id.valid(); id.advance()) {
meansize.put(result.get(id).size());
}
org.junit.Assert.assertEquals("Manhattan mean 2NN", mean2nnManhattan, meansize.getMean(), 0.00001);
org.junit.Assert.assertEquals("Manhattan variance 2NN", var2nnManhattan, meansize.getSampleVariance(), 0.00001);
}
}
Aggregations