milia.anomaly.explain#
SHAP explanations of an Isolation Forest flag.
SHAP on an Isolation Forest says which kind of feature drove a flag (shape, spread or spectrum), not reliably which hour; read it accordingly.
Functions
|
Largest SHAP contributions to a fitted Isolation Forest's score of one row. |
|
SHAP waterfall plot (matplotlib) of one row's explanation. |
- milia.anomaly.explain.explain(detector, query, names=None, top=5)#
Largest SHAP contributions to a fitted Isolation Forest’s score of one row.
- Parameters:
- Return type:
- Returns:
feature,valueandshapcolumns, largest absolute contribution first.
Examples
>>> import numpy as np >>> from milia import make >>> X = np.random.default_rng(0).normal(size=(200, 3)) >>> model = make("detector", "iforest").fit(X) >>> explain(model, [0.0, 0.0, 9.0], names=["a", "b", "c"], top=1)["feature"].item() 'c'
- milia.anomaly.explain.waterfall(detector, query, names=None, top=10)#
SHAP waterfall plot (matplotlib) of one row’s explanation.
- Parameters:
- Return type:
- Returns:
The matplotlib axes SHAP draws on.
Examples
>>> waterfall(model, [0.0, 0.0, 9.0])