milia.anomaly.models.iforest#
Isolation Forest: how few random splits it takes to isolate a point.
Classes
|
Tree-ensemble detector (Liu, Ting and Zhou, 2008). |
|
Validated hyperparameters of the Isolation Forest detector. |
- class milia.anomaly.models.iforest.IForest(n_estimators=100, max_samples='auto', max_features=1.0, random_state=0, contamination=0.1)#
Bases:
BaseDetectorTree-ensemble detector (Liu, Ting and Zhou, 2008).
The fitted
sklearn.ensemble.IsolationForestis kept asestimator_, so it can be explained with SHAP (milia.anomaly.explain).- Parameters:
Examples
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> train, cal = rng.normal(size=(200, 2)), rng.normal(size=(100, 2)) >>> model = IForest().fit(train).calibrate(cal, alpha=0.1) >>> model.flag(np.array([[0.0, 0.0], [8.0, 8.0]])).tolist() [False, True]
- class milia.anomaly.models.iforest.IForestConfig(*, name='iforest', kind='detector', space=SearchSpace(n_estimators=(50, 500), max_features=(0.3, 1.0)), n_estimators=100, max_samples='auto', max_features=1.0, random_state=0, contamination=0.1)#
Bases:
BaseModelConfigValidated hyperparameters of the Isolation Forest detector.
Fields mirror
IForest’s constructor;spaceis the default Optuna search space. Build the detector withmake("detector", "iforest", ...)orIForest(**config.params()).Examples
>>> IForestConfig().name 'iforest'