Isolation Forest: anomaly detection via random splits
Intermediate classical-mlunsupervisedanomaly-detection
Implement:
def build_isolation_tree(input, max_depth, rng) -> dict: ...
def path_length(tree, x, current_depth=0) -> float: ...
def isolation_forest_fit(input, n_trees, max_depth, seed=None) -> list[dict]: ...
def anomaly_scores(forest, input, sample_size) -> np.ndarray: ...
- No labels anywhere, this is unsupervised, "anomalous" is never told to the model, it falls out of how easy a point is to isolate.
- Splits are purely random: a random feature, a random threshold within that feature's observed range, no Gini impurity or information gain involved at all.