Abstract
In anomaly detection, the degree of irregularity is often summarized as a real-valued anomaly score. We address the problem of attributing such anomaly scores to input features for interpreting the results of anomaly detection. We particularly investigate the use of the Shapley value for attributing anomaly scores of semi-supervised detection methods. We propose a characteristic function specifically designed for attributing anomaly scores. The idea is to approximate the absence of some features by locally minimizing the anomaly score with regard to the to-be-absent features. We examine the applicability of the proposed characteristic function and other general approaches for interpreting anomaly scores on multiple datasets and multiple anomaly detection methods. The results indicate the potential utility of the attribution methods including the proposed one.
Introduction
Anomaly detection is a cornerstone of modern data science, yet identifying an outlier is often only the first step. For practitioners in security, medicine, or finance, the critical question is "why" a specific instance was flagged. Attributing a high anomaly score to specific input features provides the necessary interpretability to turn a detection into an actionable insight.
A common approach for feature attribution is the use of Shapley values from coalitional game theory. Shapley values distribute a "payout"—in this case, the anomaly score—among "players" (features) based on their marginal contributions. However, applying Shapley values requires a characteristic function to determine the score when a subset of features is "absent." In standard machine learning, absence is often modeled by replacing features with a fixed reference value, such as zero or the mean. In anomaly detection, this is problematic: a fixed reference might inadvertently create a new anomaly or fail to neutralize the existing one, as there is no universal "normal" value for every feature in every context.
The Anomaly Shapley (ASH) Method
To address these limitations, we propose Anomaly Shapley (ASH). The core innovation is a characteristic function designed specifically for anomaly scores that avoids the pitfalls of fixed reference values.
Local Minimization for Feature Absence
Instead of using a fixed reference, we define the "absence" of a feature by its local contribution to making a data point look "normal." Specifically, we find a value that minimizes the anomaly score in the local neighborhood of the data point, keeping the "present" features fixed. This approach adaptively identifies what "normal" looks like for a specific context.
Practical Implementation
Calculating this for every possible subset of features is computationally prohibitive ($O(2^d)$). ASH introduces two key relaxations to ensure practical utility:
- Regularization: A regularizer ($\gamma$) is used to penalize the distance of "absent" features from their original values, replacing hard neighborhood constraints.
- Heuristic Relaxation: The minimization process is simplified to require only $d+1$ runs, reducing complexity to $O(d)$.
Experimental Evaluation
We evaluated ASH across six diverse public datasets, ranging from low-dimensional clinical data to high-dimensional sensor data, to test its robustness across different scales.
The method was tested against four anomaly detection models, including Gaussian Mixture Models (GMMs) and Variational Autoencoders (VAEs), and compared with baselines such as Kernel SHAP and Integrated Gradients.
Key Results
- Synthetic Anomalies: In scenarios where features were manually corrupted, ASH effectively identified the source of the anomaly, often achieving a Mean Reciprocal Rank (MRR) between 0.8 and 0.9, meaning the true cause was almost always the top-ranked feature.
- Real-World Performance: On real-world anomalies, ASH's attributions aligned more closely with supervised "ground truth" labels than other unsupervised methods.
- Stability and Sparsity: ASH provided stable performance across datasets and produced sparse attributions, making the results easier for human users to digest by pointing to a few key culprits.
Conclusion
ASH offers a principled, structure-agnostic framework for attributing anomaly scores. By defining feature absence through local minimization, it avoids the pitfalls of fixed reference values. While challenges remain for highly non-linear models like Deep Autoencoding Gaussian Mixture Models (DAGMM), ASH represents a significant step toward robust "root cause" analysis in unsupervised anomaly detection.
Reference: Takeishi, N., & Kawahara, Y. (2023). A Characteristic Function for Shapley-Value-Based Attribution of Anomaly Scores. Transactions on Machine Learning Research.
Summary updated