moutlier_iforest.Rd
Performs outlier detection using an Isolation Forest.
moutlier_iforest( xs, mask = !Reduce("|", lapply(xs, is.na)), threshold = c(0.8, 0.9), return.score = FALSE, ... )
xs | A dataframe or list of vectors (which will be coerced to a numeric matrix). |
---|---|
mask | A logical vector that defines which values in |
threshold | A length-two vector identifying thresholds for "mild" and "extreme" outliers. |
return.score | if |
... | Additional arguments to |
the values of threshold
identify mild and extreme\
outliers based on the Isolation Forest score in the range [0,1]
.
Default values are 0.8 for "mild" outliers and 0.9 for "extreme"
outliers.
x = seq(0, 34, by = 0.25)*pi noise = rlnorm(length(x), meanlog = 1, sdlog = 3) y = sin(x) + noise mask = noise < 1 if (requireNamespace("solitude", quietly = TRUE)) { moutlier_iforest(list(y)) moutlier_iforest(list(x, y)) moutlier_iforest(list(x, y), mask) moutlier_iforest(list(x, y), mask, threshold = c(1, 2)) moutlier_iforest(list(x, y), return.score = TRUE) }#> INFO [19:08:55.593] Building Isolation Forest ... #> INFO [19:08:56.801] done #> INFO [19:08:56.819] Computing depth of terminal nodes ... #> INFO [19:08:57.632] done #> INFO [19:08:57.643] Completed growing isolation forest #> INFO [19:08:57.663] Building Isolation Forest ... #> INFO [19:08:57.671] done #> INFO [19:08:57.673] Computing depth of terminal nodes ... #> INFO [19:08:57.983] done #> INFO [19:08:57.994] Completed growing isolation forest #> INFO [19:08:58.013] Building Isolation Forest ... #> INFO [19:08:58.020] done #> INFO [19:08:58.022] Computing depth of terminal nodes ... #> INFO [19:08:58.293] done #> INFO [19:08:58.300] Completed growing isolation forest #> INFO [19:08:58.316] Building Isolation Forest ... #> INFO [19:08:58.323] done #> INFO [19:08:58.325] Computing depth of terminal nodes ... #> INFO [19:08:58.556] done #> INFO [19:08:58.564] Completed growing isolation forest #> INFO [19:08:58.582] Building Isolation Forest ... #> INFO [19:08:58.590] done #> INFO [19:08:58.592] Computing depth of terminal nodes ... #> INFO [19:08:58.885] done #> INFO [19:08:58.895] Completed growing isolation forest#> [1] 0.5631930 0.6570447 0.5601630 0.5567201 0.5537250 0.5723817 0.5875774 #> [8] 0.5640617 0.5541519 0.5486279 0.5520207 0.5701804 0.5759214 0.5469393 #> [15] 0.5821687 0.5541519 0.5857690 0.5507459 0.5545791 0.5469393 0.5524463 #> [22] 0.5623256 0.5503217 0.5452559 0.5515955 0.5482052 0.5482052 0.5584389 #> [29] 0.5477829 0.5448358 0.5507459 0.5524463 0.5477829 0.5912112 0.5482052 #> [36] 0.5532984 0.5444161 0.5465179 0.5486279 0.5444161 0.5541519 0.8664589 #> [43] 0.5444161 0.5507459 0.5473609 0.5456762 0.5419046 0.5482052 0.5439967 #> [50] 0.5862206 0.5419046 0.5423224 0.5414872 0.5423224 0.5423224 0.5427405 #> [57] 0.5593003 0.6405458 0.6823303 0.5419046 0.5423224 0.5406532 0.5423224 #> [64] 0.5427405 0.5473609 0.5423224 0.5423224 0.5410700 0.5410700 0.5431589 #> [71] 0.5431589 0.5414872 0.5511705 0.5402367 0.5419046 0.5398205 0.5406532 #> [78] 0.5398205 0.5398205 0.5406532 0.5545791 0.5398205 0.7257210 0.5427405 #> [85] 0.5402367 0.5410700 0.5410700 0.5584389 0.5402367 0.5402367 0.5402367 #> [92] 0.5402367 0.5477829 0.5402367 0.5406532 0.5934936 0.5419046 0.5406532 #> [99] 0.5427405 0.5414872 0.5410700 0.5423224 0.5402367 0.5419046 0.5435777 #> [106] 0.5448358 0.6450040 0.5423224 0.5507459 0.5419046 0.5427405 0.5406532 #> [113] 0.5419046 0.5410700 0.5423224 0.6361185 0.5423224 0.5423224 0.5431589 #> [120] 0.5456762 0.5494741 0.5410700 0.5402367 0.5402367 0.5653673 0.5465179 #> [127] 0.5550066 0.5419046 0.5439967 0.5490508 0.5545791 0.5554345 0.5567201 #> [134] 0.6059721 0.5662394 0.5754777 0.5948673