Multiple Testing Framework for Out-of-Distribution Detection

Akshayaa Magesh, Venugopal V. Veeravalli, Anirban Roy, Susmit JhaarXiv 2022 · DOI

Introduction

Machine Learning (ML) models are increasingly deployed in real-world environments where they inevitably encounter inputs that differ significantly from their training data. This challenge, known as Out-of-Distribution (OOD) detection, is critical for ensuring the safety and reliability of automated systems. While numerous detection statistics have been proposed, the field has historically lacked a formal, model-dependent framework and rigorous theoretical guarantees. This paper introduces a novel approach that treats OOD detection as a multiple hypothesis testing problem, utilizing conformal p-values to combine diverse model statistics into a robust and theoretically grounded detection system.

The Challenge of Out-of-Distribution Detection

Existing OOD research often conflates OOD detection with outlier detection—simply identifying rare inputs. However, the authors argue that effective OOD detection must be model-dependent. The primary concern is not just whether an input is rare, but whether the model's specific output for that input can be trusted.

Furthermore, current methods suffer from two major limitations:

  1. Inconsistent Performance: A statistic that excels at detecting one type of OOD data (e.g., blurred images) may fail entirely on another (e.g., images from a different dataset). There is no single "gold standard" statistic.
  2. Weak Theoretical Guarantees: Most methods offer only "marginal" guarantees, which describe average-case performance. Practitioners, however, require "conditional" guarantees—certainty regarding the error rate for the specific calibration data and model at hand.

Methodology: A Multiple Hypothesis Testing Approach

The proposed framework addresses these gaps by systematically combining multiple score functions derived from a pre-trained ML model.

Model-Aware OOD Definition

The authors formally define an OOD sample as one where the joint distribution of the input and the model's internal representations/predictions deviates from the patterns established during training. This ensures the detection is relevant to the model's actual performance.

Conformal p-values and Score Integration

Instead of relying on a single score (such as the Energy score or Mahalanobis distance), the framework treats each individual score—calculated at different layers of the neural network—as an individual hypothesis test. To standardize these diverse scores, the authors use a calibration set of held-out in-distribution data to calculate conformal p-values. This process transforms raw, incomparable scores into a standardized probability scale (0 to 1).

The Modified Benjamini-Hochberg (BH) Procedure

To aggregate these p-values, the framework employs a modified version of the Benjamini-Hochberg procedure, a staple in fields like genomics. Crucially, the authors incorporate a correction factor ($C(K)$) to account for the high degree of dependency between different model statistics, ensuring the combined test remains statistically valid.

Experimental Evaluation

The framework was evaluated using standard computer vision benchmarks to test its versatility and robustness:

  • In-Distribution (ID) Sets: CIFAR10, SVHN, and CIFAR100.
  • Out-of-Distribution (OOD) Sets: SVHN (when CIFAR is ID), LSUN, ImageNet, iSUN, and CIFAR10 (when SVHN is ID).
  • Architectures: The researchers utilized ResNet34 and DenseNet to verify that the framework's effectiveness is independent of specific neural network architectures.

Results and Analysis

Uniformity and Robustness

The experiments highlighted a "No Free Lunch" theorem for OOD detection: different layers of a network are sensitive to different types of OOD data. While a single statistic might occasionally outperform the proposed framework on a specific dataset, the multiple testing approach proved to be uniformly good. It achieved high detection power across all tested scenarios, reducing the variation in detection probability by nearly 5x compared to single-statistic baselines.

Theoretical vs. Empirical False Alarm Rates

A key contribution of this work is the proof (Theorem 1) that the false alarm rate is bounded for the specific calibration set used. Experimental results confirmed this, showing that the actual false alarm rate consistently stayed below the theoretical upper bound. This provides a much stronger safety guarantee for real-world applications than previous methods.

Performance on Complex Tasks

On more challenging datasets like CIFAR100, the combined method significantly improved AUROC scores. This demonstrates that the framework scales effectively to more complex classification tasks where single-score methods often struggle.

Discussion and Limitations

While the framework offers significant advantages, it does introduce certain requirements:

  • Calibration Data: The method requires a separate calibration set (approximately 5,000 samples in these tests), which may be a constraint in data-scarce environments.
  • Statistic Selection: The framework combines existing statistics but does not inherently determine which statistics are most effective to include. The final performance remains partially dependent on the quality of the base scores chosen (e.g., Mahalanobis, Gram matrix).
  • Computational Cost: Calculating multiple statistics and their corresponding p-values for every inference step increases computational overhead, which may impact deployment on real-time edge devices.

Conclusion

By reframing OOD detection as a multiple hypothesis testing problem, this work provides a rigorous and robust solution to a long-standing challenge in machine learning. The use of conformal p-values and the modified BH procedure allows for the integration of diverse model-aware statistics, resulting in a detection system that is both high-performing and theoretically sound. Future research will likely focus on automatically identifying the most complementary statistics to optimize both detection power and computational efficiency.

Summary updated

BibTeX
@misc{magesh2022multiple,
  author = {Akshayaa Magesh and Venugopal V. Veeravalli and Anirban Roy and Susmit Jha},
  title = {{Multiple Testing Framework for Out-of-Distribution Detection}},
  year = {2022},
  eprint = {2206.09522},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.09522},
}
Figure