Interpretable Anomaly Detection with DIFFI: Depth-based Feature Importance for the Isolation Forest

Mattia Carletti, Matteo Terzi, Gian Antonio SustoarXiv 2020 · arXiv

Introduction

Anomaly Detection (AD) is a fundamental task in data science, essential for applications ranging from financial fraud detection to industrial system monitoring. Among the various algorithms available, the Isolation Forest (IF) has emerged as a practitioner favorite due to its computational efficiency, unsupervised nature, and strong performance with minimal tuning.

However, the Isolation Forest operates as a "black box." Its reliance on an ensemble of trees built with inherent randomness makes it difficult to explain why a specific data point was flagged as an anomaly. In high-stakes domains like healthcare or cybersecurity, a simple anomaly score is often insufficient; stakeholders require interpretable justifications to trust the model and identify root causes. While model-agnostic tools like SHAP can provide explanations, they are often computationally intensive and fail to leverage the specific internal logic of the Isolation Forest. To bridge this gap, this paper introduces DIFFI (Depth-based Isolation Forest Feature Importance), a model-specific framework designed for fast and accurate interpretability.

Methodology: The DIFFI Framework

DIFFI is built upon two core intuitions regarding the structural behavior of Isolation Forests:

  1. Depth (I1): Anomalies are easier to isolate than normal points. Consequently, they tend to reside in leaf nodes closer to the root (shallow depth).
  2. Imbalance (I2): A feature's importance is reflected in its ability to create highly imbalanced splits—for instance, separating a single outlier from a large cluster of normal data.

Components of DIFFI

The framework provides three primary functionalities:

  • Global DIFFI (GFI): This component offers a macro-view of feature importance across the entire training set. It utilizes an Induced Imbalance Coefficient (IIC) to weight the importance of specific splits based on how effectively they partition the data.
  • Local DIFFI (LFI): Designed for test-time explanations, LFI traces the specific path an outlier takes through the forest. By analyzing the features that contributed to early isolation, it provides a granular explanation for individual predictions.
  • Unsupervised Feature Selection: DIFFI rankings can be used to prune irrelevant or noisy features. By removing "junk" dimensions that do not contribute to isolation, the overall accuracy of the anomaly detector can be improved.

To ensure high performance, the authors employ an in-bag samples approach. Importance is calculated using only the subset of data used to train each specific tree, ensuring that computation time remains independent of the total training set size.

Experimental Validation

The authors evaluated DIFFI using a combination of synthetic and real-world datasets:

  • Synthetic Data: A 2D subspace of relevant features was augmented with four dimensions of white noise to test the model's ability to distinguish signal from noise.
  • Glass Identification (UCI): A real-world dataset where "headlamp glass" is categorized as the anomaly. Chemical properties (Aluminum and Barium content) served as the ground truth for feature importance.
  • ODDS Database: Six standard benchmarks (Satellite, Cardio, Ionosphere, Lympho, Musk, and Letter) were used to assess the effectiveness of DIFFI-based feature selection.

Key Results and Insights

Efficiency and Speed

One of the most significant advantages of DIFFI is its speed. In synthetic testing, Local-DIFFI achieved a processing time of 0.023 seconds per sample, compared to 0.221 seconds for SHAP. This nearly 10x speedup makes DIFFI a viable candidate for real-time applications where SHAP might be too slow.

Interpretability Accuracy

On the Glass Identification dataset, Local-DIFFI correctly identified Barium and Aluminum as the primary features driving the anomaly classification, aligning with known chemical profiles. In contrast, SHAP struggled by over-emphasizing Magnesium, suggesting that DIFFI’s model-specific approach can be more faithful to the IF's internal logic than model-agnostic alternatives.

Enhanced Feature Selection

When used for unsupervised feature selection on the ODDS datasets, DIFFI consistently outperformed traditional methods such as the Laplacian Score and SPEC. By focusing specifically on the features that facilitate isolation (task-specific selection), DIFFI-based pruning led to higher F1-scores with fewer features.

Conclusion and Future Work

DIFFI demonstrates that looking "under the hood" of the Isolation Forest provides significant benefits in both speed and explanatory power. By focusing on split imbalance and tree depth, the framework offers a macro and micro view of anomaly detection that is both computationally efficient and logically consistent with the underlying model.

While currently optimized for the standard Isolation Forest, the authors suggest that the principles of DIFFI could be extended to variants like the Extended Isolation Forest or SCiForest. Future research will also explore the application of these techniques to streaming data, enabling real-time, interpretable monitoring in dynamic environments.

Summary updated

Abstract

Anomaly Detection is an unsupervised learning task aimed at detecting anomalous behaviours with respect to historical data. In particular, multivariate Anomaly Detection has an important role in many applications thanks to the capability of summarizing the status of a complex system or observed phenomenon with a single indicator (typically called `Anomaly Score') and thanks to the unsupervised nature of the task that does not require human tagging. The Isolation Forest is one of the most commonly adopted algorithms in the field of Anomaly Detection, due to its proven effectiveness and low computational complexity. A major problem affecting Isolation Forest is represented by the lack of interpretability, an effect of the inherent randomness governing the splits performed by the Isolation Trees, the building blocks of the Isolation Forest. In this paper we propose effective, yet computationally inexpensive, methods to define feature importance scores at both global and local level for the Isolation Forest. Moreover, we define a procedure to perform unsupervised feature selection for Anomaly Detection problems based on our interpretability method; such procedure also serves the purpose of tackling the challenging task of feature importance evaluation in unsupervised anomaly detection. We assess the performance on several synthetic and real-world datasets, including comparisons against state-of-the-art interpretability techniques, and make the code publicly available to enhance reproducibility and foster research in the field.
BibTeX
@misc{carletti2020interpretable,
  author = {Mattia Carletti and Matteo Terzi and Gian Antonio Susto},
  title = {{Interpretable Anomaly Detection with DIFFI: Depth-based Feature Importance for the Isolation Forest}},
  year = {2020},
  eprint = {2007.11117},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.11117},
}
Figure