Skip to contents

This function computes an ensemble score using Item Response Theory (IRT). This was proposed as an ensemble method for anomaly/outlier detection in Kandanaarachchi (2021) <doi:10.13140/RG.2.2.18355.96801>.

Usage

irt_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

A list with the components:

scores

The ensemble scores.

model

The IRT model.

Details

For outlier detection, higher ensemble scores indicate higher levels of anomalousness. This ensemble uses IRT's latent trait to uncover the hidden ground truth, which is used as the ensemble score. It uses the R packages airt and EstCRM to fit the IRT models. It can also be used for other ensembling tasks.

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 <- irt_ensemble(Y)
ens$scores
}
#>   [1] 3.7952089 3.0035830 3.3666226 2.1300836 1.0683486 3.5957652 2.3031996
#>   [8] 3.1180325 3.1615298 1.9067552 3.0243225 2.1722921 3.1077875 1.5011276
#>  [15] 2.6003938 4.2590519 1.4404905 3.9323460 3.3699721 2.8282017 2.9012692
#>  [22] 2.1451581 2.8198343 2.7498736 2.6423326 3.3602876 2.7204966 1.9539427
#>  [29] 2.9302183 3.5147842 3.8489742 1.5620629 2.6918743 2.8499887 2.4984790
#>  [36] 3.4140906 1.9642133 1.4431093 1.4963490 2.3471782 2.5879914 2.0754792
#>  [43] 3.3477318 4.3888777 2.8595950 3.5958010 1.8990056 2.9156735 2.5200218
#>  [50] 1.7163441 1.3756780 1.8717282 1.3162910 3.1246859 3.2729750 3.3153552
#>  [57] 3.4506180 2.6236068 0.8813189 3.3701926 1.1631266 2.4524205 1.4922135
#>  [64] 2.8652878 4.0223205 3.4392156 1.7947946 3.4405224 2.5813665 3.8904897
#>  [71] 2.6704292 4.3233340 3.0144315 3.1537049 2.5471447 2.7467285 1.1496452
#>  [78] 2.9228507 2.0843506 1.0354834 3.3069119 2.5945917 1.8117976 2.0258041
#>  [85] 0.0000000 2.0592092 2.8664650 3.5765581 1.8700452 2.9664263 3.4882582
#>  [92] 3.0276952 2.9768730 2.5755047 4.2439395 2.3337523 4.5626511 4.0165581
#>  [99] 1.1805409 2.8521173 2.5277976 2.0682764 2.4310136 2.5785485 2.8090628
#> [106] 1.3421073 3.8688374 3.3429509 2.8432602 4.1207789 2.7676450 2.7032242
#> [113] 4.3018217 1.8983651 1.6398197 2.4776134 0.9857004 2.9816118 3.1941860
#> [120] 2.8204112 1.6382082 2.7777243 2.8663710 2.2210963 3.7696753 2.7146888
#> [127] 1.4043282 2.2722176 2.8895779 1.1006468 3.7176751 3.1516616 1.9114116
#> [134] 3.0918968 3.8621695 4.2762438 3.8505193 2.3205163 3.9985786 3.0969951
#> [141] 2.7590102 2.6846044 3.7862850 3.1342071 3.2396089 3.4364012 3.0637332
#> [148] 2.2053828 4.2516756 3.0109780 3.1271084 4.0459479 0.8615363 2.9604822
#> [155] 2.4580608 1.3209083 2.4839878 1.5245599 4.5654273 4.2121093 2.7021732
#> [162] 2.8352340 3.0218097 5.2082300 2.5330522 1.3448493 2.5618246 2.5394919
#> [169] 2.8203745 1.3033653 4.0585899 3.3344024 1.6436958 4.1591115 2.7067301
#> [176] 2.9377598 2.6644793 2.0416304 2.0025585 3.4347458 2.9126173 3.1117378
#> [183] 1.2938868 2.8117651 1.7968159 3.0994945 2.9543086 2.8473251 2.1410739
#> [190] 2.1077007 1.6869635 3.9030795 2.6164449 2.7121883 3.1551958 4.2886517
#> [197] 2.4985964 3.0449378 7.0710432 7.8237190