greedy_ensemble.Rd
This function computes an ensemble score using the greedy algorithm in the paper titled Evaluation of Outlier Rankings and Outlier Scores by Schubert et al (2012) <doi:10.1137/1.9781611972825.90>. The greedy ensemble is detailed in Section 4.3.
greedy_ensemble(X, kk = 5)
The input data containing the outlier scores in a dataframe, matrix or tibble format. Rows contain observations and columns contain outlier detection methods.
The number of estimated outliers.
A list with the components:
scores
The ensemble scores.
methods
The methods that are chosen for the ensemble.
chosen
The chosen subset of original anomaly scores.
set.seed(123)
X <- data.frame(x1 = rnorm(200), x2 = rnorm(200))
X[199, ] <- c(4, 4)
X[200, ] <- c(-3, 5)
y1 <- DDoutlier::KNN_AGG(X)
y2 <- DDoutlier::LOF(X)
y3 <- DDoutlier::COF(X)
y4 <- DDoutlier::INFLO(X)
y5 <- DDoutlier::KDEOS(X)
y6 <- DDoutlier::LDF(X)
y7 <- DDoutlier::LDOF(X)
Y <- cbind.data.frame(y1, y2, y3, y4, y5, y6, y7)
ens <- greedy_ensemble(Y, kk=5)
ens$scores
#> [1] 0.15856189 0.08408787 0.14740462 0.14549353 0.20489762 0.15881729
#> [7] 0.22734604 0.12480345 0.16766943 0.16269742 0.08340384 0.15451244
#> [13] 0.12310651 0.24331070 0.12561906 0.10687695 0.19696268 0.34893921
#> [19] 0.23586493 0.09419329 0.08232116 0.16027197 0.17041569 0.09060252
#> [25] 0.24036495 0.13385489 0.09969514 0.14255530 0.13076604 0.29507452
#> [31] 0.24042198 0.26020940 0.22114615 0.13624938 0.16693662 0.23180377
#> [37] 0.15480771 0.14586334 0.14106320 0.23498217 0.09809964 0.20764001
#> [43] 0.20602223 0.24361671 0.18470218 0.16227582 0.16135621 0.09575059
#> [49] 0.11501803 0.15748904 0.19600415 0.11619852 0.22623607 0.15215758
#> [55] 0.18958532 0.18181472 0.26569241 0.11450460 0.11465683 0.14956265
#> [61] 0.14332761 0.17326698 0.29994929 0.07679322 0.22424706 0.15317831
#> [67] 0.13028272 0.11081977 0.13755118 0.29593500 0.11949264 0.36762192
#> [73] 0.23970981 0.18077744 0.15761709 0.18593405 0.21497297 0.14901404
#> [79] 0.23719987 0.18136431 0.10387998 0.10402992 0.19794267 0.13540231
#> [85] 0.24464063 0.10284801 0.11085692 0.16655615 0.24538310 0.08206543
#> [91] 0.23323572 0.14369854 0.17427458 0.12262323 0.20948884 0.29045935
#> [97] 0.22757697 0.19866317 0.28243700 0.07873216 0.08674553 0.16293868
#> [103] 0.11701237 0.17512583 0.19469674 0.18632447 0.27195422 0.18327378
#> [109] 0.12279595 0.24149669 0.17915703 0.09214501 0.34825825 0.13028079
#> [115] 0.20535411 0.13579111 0.13056848 0.16591488 0.17650108 0.14050331
#> [121] 0.22922391 0.09906502 0.07775717 0.14465261 0.14956986 0.10007742
#> [127] 0.20520877 0.13885353 0.10020061 0.18587629 0.23715801 0.19787554
#> [133] 0.22523703 0.14608977 0.30267571 0.23483263 0.32267736 0.15191501
#> [139] 0.15202598 0.13340002 0.12405766 0.23889276 0.26483356 0.08204389
#> [145] 0.12435203 0.16948009 0.10720964 0.18721029 0.20197274 0.21792744
#> [151] 0.15244142 0.20402446 0.13281066 0.16048661 0.14477648 0.14504425
#> [157] 0.15157325 0.19598628 0.34084278 0.28649249 0.20010772 0.22105932
#> [163] 0.21179370 0.33434950 0.12931127 0.22544437 0.14950032 0.11249231
#> [169] 0.12613020 0.11037935 0.23301792 0.09996585 0.17385895 0.18440470
#> [175] 0.21611005 0.07672948 0.18519622 0.09713127 0.19601970 0.16543499
#> [181] 0.13692143 0.09788002 0.22923733 0.22701248 0.25708085 0.08932955
#> [187] 0.20023342 0.21862762 0.20108476 0.27043161 0.17961237 0.22256101
#> [193] 0.24036286 0.18576624 0.16891082 0.11550586 0.22223915 0.14815598
#> [199] 0.66254952 0.85714286