Search in sources :

Example 1 with KNNListener

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();
}
Also used : StepProgress(de.lmu.ifi.dbs.elki.logging.progress.StepProgress) AbstractMaterializeKNNPreprocessor(de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor) MaterializeKNNPreprocessor(de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor) KNNListener(de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener) Pair(de.lmu.ifi.dbs.elki.utilities.pairs.Pair)

Aggregations

AbstractMaterializeKNNPreprocessor (de.lmu.ifi.dbs.elki.index.preprocessed.knn.AbstractMaterializeKNNPreprocessor)1 KNNListener (de.lmu.ifi.dbs.elki.index.preprocessed.knn.KNNListener)1 MaterializeKNNPreprocessor (de.lmu.ifi.dbs.elki.index.preprocessed.knn.MaterializeKNNPreprocessor)1 StepProgress (de.lmu.ifi.dbs.elki.logging.progress.StepProgress)1 Pair (de.lmu.ifi.dbs.elki.utilities.pairs.Pair)1