This is an unofficial python implementation of the DIFFI (Depth-based Isolation Forest Feature Importance) Algorithm proposed by [1]. A model-based approach to assess global interpretation, in terms of feature importance, of an Isolation Forest.
This implementation assumes that the model used is an instance of scikit-learn's Isolation Forest.
from sklearn.ensemble import IsolationForest
from diffi.diffi import diffi_score
clf = IsolationForest()
clf.fit(X)
feature_importance = diffi_score(clf, X)
Carletti, Mattia, Chiara Masiero, Alessandro Beghi, and Gian Antonio Susto. "Explainable machine learning in industry 4.0: evaluating feature importance in anomaly detection to enable root cause analysis." In 2019 IEEE International Conference on Systems, Man and Cybernetics (SMC), pp. 21-26. IEEE, 2019.