Skip to contents

Random axis-parallel splits; the depth at which a point becomes isolated is the statistic. Anomalies are isolated in few splits, so short average path length means high score. The normalisation c(psi) is the average path length of an unsuccessful search in a binary search tree, which is what makes scores comparable across subsample sizes.

Usage

morie_isolation_forest(X, n_trees = 100, sample_size = 256, seed = 0)

Arguments

X

numeric matrix, one row per observation.

n_trees

number of trees.

sample_size

subsample size per tree (capped at nrow(X)). Subsampling is not only for speed – it reduces swamping.

seed

integer seed. R's generator is not numpy's, so scores will not match the Python module value-for-value; the rankings do.

Value

list with score (in (0, 1], 0.5 is the neutral point), rank, path_length.

Details

The splits are axis-parallel, so structure at an angle is invisible: points inside a tight diagonal band score as anomalous even though they sit exactly on the data's own manifold.

References

Liu, F. T., Ting, K. M. and Zhou, Z.-H. (2008). Isolation forest. ICDM, 413-422.

Examples

# \donttest{
set.seed(1)
X <- rbind(matrix(rnorm(200), ncol = 2), c(8, 8))
which.max(morie_isolation_forest(X, n_trees = 50, seed = 1)$score)
#> [1] 101
# }