How to know which features causes anomalies while training isolation forest model

528 views Asked by At

I'm training an unsupersived isolation forest model with a dataframe that contains 10 features , the model performs well and detect anomalies. My question is if an anomaly is catched i want to know which feature(s) has caused that anomaly. Is there any way to do it ? If not , is there an other model that allows me to do it

1

There are 1 answers

0
Jon Nordby On BEST ANSWER

SHAP values and the shap library can be used for this. See this answer for an example.

After getting the shap values out of the explainer for your datapoints, you can use the waterfall plots to see how different features contributed to the decision.

shap.plots.waterfall(shap_values[0])

It will give a plot similar to this:

enter image description here