public OutlierResult run ( Database database , Relation < O > rel ) { final DBIDs ids = rel . getDBIDs ( ) ; LOG . verbose ( "Running kNN preprocessor." ) ; KNNQuery < O > knnq = DatabaseUtil . precomputedKNNQuery ( database , rel , getDistanceFunction ( ) , kmax + 1 ) ; // Initialize store for densities WritableDataStore < double [ ] > densities = DataStoreUtil . makeStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP , double [ ] . class ) ; estimateDensities ( rel , knnq , ids , densities ) ; // Compute scores: WritableDoubleDataStore kofs = DataStoreUtil . makeDoubleStorage ( ids , DataStoreFactory . HINT_DB ) ; DoubleMinMax minmax = new DoubleMinMax ( ) ; computeOutlierScores ( knnq , ids , densities , kofs , minmax ) ; DoubleRelation scoreres = new MaterializedDoubleRelation ( "Kernel Density Estimation Outlier Scores" , "kdeos-outlier" , kofs , ids ) ; OutlierScoreMeta meta = new ProbabilisticOutlierScore ( minmax . getMin ( ) , minmax . getMax ( ) ) ; return new OutlierResult ( meta , scoreres ) ; }
Run the KDEOS outlier detection algorithm .