public OutlierResult run(Relation<O> relation) {
    final DistanceQuery<O> distanceQuery = relation.getDistanceQuery(getDistanceFunction());
    final KNNQuery<O> knnQuery = relation.getKNNQuery(distanceQuery, k);

    FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("kNN distance for objects", relation.size(), LOG) : null;

    DoubleMinMax minmax = new DoubleMinMax();
    WritableDoubleDataStore knno_score = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC);
    // compute distance to the k nearest neighbor.
    for(DBIDIter it = relation.iterDBIDs(); it.valid(); it.advance()) {
      // distance to the kth nearest neighbor
      // (assuming the query point is always included, with distance 0)
      final double dkn = knnQuery.getKNNForDBID(it, k).getKNNDistance();

      knno_score.putDouble(it, dkn);
      minmax.put(dkn);

      LOG.incrementProcessed(prog);
    }
    LOG.ensureCompleted(prog);
    DoubleRelation scoreres = new MaterializedDoubleRelation("kNN Outlier Score", "knn-outlier", knno_score, relation.getDBIDs());
    OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0., Double.POSITIVE_INFINITY, 0.);
    return new OutlierResult(meta, scoreres);
  }
public OutlierResult run ( Relation < O > relation ) { final DistanceQuery < O > distanceQuery = relation . getDistanceQuery ( getDistanceFunction ( ) ) ; final KNNQuery < O > knnQuery = relation . getKNNQuery ( distanceQuery , k ) ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "kNN distance for objects" , relation . size ( ) , LOG ) : null ; DoubleMinMax minmax = new DoubleMinMax ( ) ; WritableDoubleDataStore knno_score = DataStoreUtil . makeDoubleStorage ( relation . getDBIDs ( ) , DataStoreFactory . HINT_STATIC ) ; for ( DBIDIter it = relation . iterDBIDs ( ) ; it . valid ( ) ; it . advance ( ) ) { final double dkn = knnQuery . getKNNForDBID ( it , k ) . getKNNDistance ( ) ; knno_score . putDouble ( it , dkn ) ; minmax . put ( dkn ) ; LOG . incrementProcessed ( prog ) ; } LOG . ensureCompleted ( prog ) ; DoubleRelation scoreres = new MaterializedDoubleRelation ( "kNN Outlier Score" , "knn-outlier" , knno_score , relation . getDBIDs ( ) ) ; OutlierScoreMeta meta = new BasicOutlierScoreMeta ( minmax . getMin ( ) , minmax . getMax ( ) , 0. , Double . POSITIVE_INFINITY , 0. ) ; return new OutlierResult ( meta , scoreres ) ; }
Runs the algorithm in the timed evaluation part.

@param relation Data relation