[Paper Review] Why is the Mahalanobis Distance Effective for Anomaly Detection?
This paper analyzes why the Mahalanobis distance-based confidence score performs well for OoD and adversarial detection, shows the effect comes from high-dimensional feature directions not used for classification, and proposes marginal/partial Mahalanobis variants plus a combined detector with ODIN.
The Mahalanobis distance-based confidence score, a recently proposed anomaly detection method for pre-trained neural classifiers, achieves state-of-the-art performance on both out-of-distribution (OoD) and adversarial examples detection. This work analyzes why this method exhibits such strong performance in practical settings while imposing an implausible assumption; namely, that class conditional distributions of pre-trained features have tied covariance. Although the Mahalanobis distance-based method is claimed to be motivated by classification prediction confidence, we find that its superior performance stems from information not useful for classification. This suggests that the reason the Mahalanobis confidence score works so well is mistaken, and makes use of different information from ODIN, another popular OoD detection method based on prediction confidence. This perspective motivates us to combine these two methods, and the combined detector exhibits improved performance and robustness. These findings provide insight into the behavior of neural classifiers in response to anomalous inputs.
Motivation & Objective
- Evaluate why the Mahalanobis distance-based confidence score works for OoD and adversarial detection despite tied-covariance assumptions.
- Investigate the role of high-dimensional feature directions that are not central to classification.
- Propose marginal and partial Mahalanobis variants to test the information content of different feature subspaces.
- Propose combining Mahalanobis-based detection with ODIN to improve OoD detection robustness.
- Provide guidance on the behavior of neural classifiers under anomalous inputs.
Proposed method
- Review and analyze the Mahalanobis distance-based confidence score under the tied-covariance assumption.
- Introduce partial and marginal Mahalanobis distances to isolate information useful for anomaly detection versus classification.
- Empirically compare original, partial, and marginal variants on OoD and adversarial detection tasks across multiple datasets.
- Propose a simple detector combination by adding ODIN as an extra feature to the Mahalanobis-based detector.
- Evaluate using AUROC as the primary metric across datasets like CIFAR-10/100, SVHN, Tiny ImageNet, and LSUN.
Experimental results
Research questions
- RQ1Why does the Mahalanobis confidence score perform well for OoD and adversarial detection despite the assumption of tied covariances?
- RQ2Which subspaces of the neural feature representations contribute to anomaly detection versus classification performance?
- RQ3Can simpler, information-only variants (marginal/partial Mahalanobis) match or exceed the original approach?
- RQ4Does combining Mahalanobis-based detection with ODIN improve OoD detection robustness and performance?
- RQ5How do these findings inform understanding of neural classifier behavior under anomalous inputs?
Key findings
- The Mahalanobis score is powerful due to information in feature directions with small explained variance, not primarily due to classification confidence.
- Partial Mahalanobis using high-variance components (P1-9) aligns with classification performance, while low-variance components (P10-512) drive OoD detection.
- The marginal Mahalanobis distance, which ignores class information and uses a single Gaussian over penultimate features, achieves comparable OoD detection performance to the original score.
- Combining marginal Mahalanobis with ODIN improves OoD detection, including for unseen data, indicating they rely on complementary information.
- Empirical results across multiple datasets show marginal and partial variants can match or closely approach the original Mahalanobis performance in OoD tasks, and similar competitiveness is observed for adversarial detection.
- The study provides insight into why neural classifiers respond to anomalous inputs and suggests practical detector enhancements.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.