use of de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener in project elki by elki-project.
the class OnlineLOF method run.
/**
* Performs the Generalized LOF_SCORE algorithm on the given database by
* calling {@code #doRunInTime(Database)} and adds a {@link LOFKNNListener} to
* the preprocessors.
*/
@Override
public OutlierResult run(Database database, Relation<O> relation) {
StepProgress stepprog = LOG.isVerbose() ? new StepProgress("OnlineLOF", 3) : null;
Pair<Pair<KNNQuery<O>, KNNQuery<O>>, Pair<RKNNQuery<O>, RKNNQuery<O>>> queries = getKNNAndRkNNQueries(database, relation, stepprog);
KNNQuery<O> kNNRefer = queries.getFirst().getFirst();
KNNQuery<O> kNNReach = queries.getFirst().getSecond();
RKNNQuery<O> rkNNRefer = queries.getSecond().getFirst();
RKNNQuery<O> rkNNReach = queries.getSecond().getSecond();
LOFResult<O> lofResult = super.doRunInTime(relation.getDBIDs(), kNNRefer, kNNReach, stepprog);
lofResult.setRkNNRefer(rkNNRefer);
lofResult.setRkNNReach(rkNNReach);
// add listener
KNNListener l = new LOFKNNListener(lofResult);
((MaterializeKNNPreprocessor<O>) ((PreprocessorKNNQuery<O>) lofResult.getKNNRefer()).getPreprocessor()).addKNNListener(l);
((MaterializeKNNPreprocessor<O>) ((PreprocessorKNNQuery<O>) lofResult.getKNNReach()).getPreprocessor()).addKNNListener(l);
return lofResult.getResult();
}
Aggregations