This is a rust port of the anomaly detection algorithm described in Extended Isolation Forest and implemented in https://github.com/sahandha/eif. For a detailed description see the paper or the github repository.
This crate requires rust >= 1.51 as it makes use of min_const_generics
.
Includes optional serde support with the serde
feature.
```rust use rand::distributions::Uniform; use rand::Rng; use extendedisolationforest::{Forest, ForestOptions};
fn makef64forest() -> Forest
let options = ForestOptions {
n_trees: 150,
sample_size: 200,
max_tree_depth: None,
extension_level: 1,
};
Forest::from_slice(values.as_slice(), &options).unwrap()
}
fn main() { let forest = makef64forest();
// no anomaly
assert!(forest.score(&[1.0, 3.0, 25.0]) < 0.5);
assert!(forest.score(&[-1.0, 3.0, 25.0]) < 0.5);
// anomalies
assert!(forest.score(&[-12.0, 6.0, 25.0]) > 0.5);
assert!(forest.score(&[-1.0, 2.0, 60.0]) > 0.5);
assert!(forest.score(&[-1.0, 2.0, 0.0]) > 0.5);
} ```