Skip to contents

This function computes an ensemble score by aggregating values above the mean as detailed in Aggarwal and Sathe (2015) <doi:10.1145/2830544.2830549>.

Usage

threshold_ensemble(X)

Arguments

X

The input data containing the outlier scores in a dataframe, matrix or tibble format. Rows contain observations and columns contain outlier detection methods.

Value

The ensemble scores.

Examples

set.seed(123)
if (requireNamespace("dbscan", quietly = TRUE)) {
X <- data.frame(x1 = rnorm(200), x2 = rnorm(200))
X[199, ] <- c(4, 4)
X[200, ] <- c(-3, 5)
# Using different parameters of lof for anomaly detection
y1 <- dbscan::lof(X, minPts = 10)
y2 <- dbscan::lof(X, minPts = 20)
knnobj <- dbscan::kNN(X, k = 20)
# Using different KNN distances as anomaly scores
y3 <- knnobj$dist[ ,10]
y4 <- knnobj$dist[ ,20]
# Dense points are less anomalous. Hence 1 - pointdensity is used.
y5 <- 1 - dbscan::pointdensity(X, eps = 0.8, type = "gaussian")
y6 <- 1 - dbscan::pointdensity(X, eps = 0.5, type = "gaussian")
Y <- cbind.data.frame(y1, y2, y3, y4, y5, y6)
ens <- threshold_ensemble(Y)
ens
}
#>   [1] 2.12703920 0.99717054 1.60708251 0.00000000 0.00000000 1.87668970
#>   [7] 0.00000000 1.23879493 1.39456523 0.00000000 0.98216266 0.00000000
#>  [13] 1.08555204 0.00000000 0.00000000 2.58152989 0.00000000 2.30533410
#>  [19] 1.51659881 0.97635181 0.94886073 0.00000000 1.06874638 0.00000000
#>  [25] 0.06827432 1.60786749 0.00000000 0.00000000 1.15873018 1.77574987
#>  [31] 2.16797968 0.00000000 0.00000000 0.00000000 0.00000000 1.60239930
#>  [37] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
#>  [43] 1.63776048 2.74952902 0.92994621 1.95108731 0.00000000 1.04172264
#>  [49] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 1.22211979
#>  [55] 1.45898023 1.43405723 1.73790782 0.00000000 0.00000000 1.55005404
#>  [61] 0.00000000 0.04596960 0.00000000 1.16286036 2.35129675 1.67908244
#>  [67] 0.00000000 1.71721106 0.00000000 2.20745785 0.00000000 2.69995393
#>  [73] 1.14005524 1.28751290 0.00000000 0.00000000 0.00000000 0.95619886
#>  [79] 0.00000000 0.00000000 1.49322631 0.00000000 0.00000000 0.00000000
#>  [85] 0.00000000 0.00000000 0.50814584 1.83903985 0.00000000 0.91776240
#>  [91] 1.73785887 1.10247924 0.94019654 0.00000000 2.56408000 0.05378879
#>  [97] 2.90116692 2.31342969 0.00000000 1.13991372 0.00000000 0.00000000
#> [103] 0.00000000 0.00000000 0.00000000 0.00000000 2.19988348 1.59489585
#> [109] 0.92748455 2.45937512 1.00314043 0.00000000 2.67276221 0.00000000
#> [115] 0.00000000 0.00000000 0.00000000 1.03553481 1.54968406 0.97913245
#> [121] 0.00000000 1.07899485 1.03188706 0.00000000 2.05983343 0.00000000
#> [127] 0.00000000 0.00000000 1.15532203 0.00000000 2.01240415 1.17948125
#> [133] 0.00000000 1.36579527 2.20403829 2.59578740 2.20382962 0.00000000
#> [139] 2.33407750 1.27697079 0.00000000 0.00000000 2.14987619 1.33829235
#> [145] 1.53939000 1.68543719 1.28114736 0.00000000 2.58173305 1.13168335
#> [151] 1.21552859 2.33729727 0.00000000 0.05364579 0.00000000 0.00000000
#> [157] 0.00000000 0.00000000 2.91720553 2.56099831 0.00000000 0.52286600
#> [163] 1.00801547 3.40367621 0.00000000 0.00000000 0.00000000 0.00000000
#> [169] 0.00000000 0.00000000 2.39974724 1.54599532 0.00000000 2.49338085
#> [175] 0.00000000 0.98179446 0.00000000 0.00000000 0.00000000 1.60948324
#> [181] 0.48392377 1.14188197 0.00000000 1.03685005 0.00000000 1.15054167
#> [187] 1.00457950 0.06314952 0.00000000 0.00000000 0.00000000 2.19765179
#> [193] 0.00000000 0.91882705 1.28264965 2.61598634 0.00000000 1.13430593
#> [199] 5.24575372 5.97897131