Fit a pure-R isolation forest on rCLR log-ratio inputs
Source:R/singlesample-outlier-detection.R
fit_isolation_forest_logratio.RdBuilds a pure-R isolation forest (Liu et al., 2008) on rCLR-transformed
compositional inputs. Anomalies have shorter expected path lengths to
isolation-tree leaves. The decision threshold is calibrated on training
scores to control the empirical false-positive rate at fpr_target
(applied at scoring time in apply_isolation_forest_logratio).
This implementation uses no external dependencies and is intended for
robustness and auditability. For production use on large panels, a C++
backend (e.g., isotree) would be faster.
Usage
fit_isolation_forest_logratio(
x_train,
n_trees = 100L,
sample_size = 256L,
max_depth = NULL,
pseudocount = 0.5,
seed = 42L
)Arguments
- x_train
Numeric matrix (samples \(\times\) features).
- n_trees
Integer - number of isolation trees. Default 100.
- sample_size
Integer - subsample size per tree. Default 256.
- max_depth
Integer or
NULL. Maximum tree depth. Defaultceiling(log2(min(sample_size, n))).- pseudocount
Numeric. rCLR pseudocount. Default 0.5.
- seed
Integer - RNG seed. Default 42.