Failing Loudly: An Empirical Study of Methods for Detecting Dataset Shift

Stephan Rabanser, Stephan Günnemann, Zachary C. Lipton

Abstract

We might hope that when faced with unexpected inputs, well-designed software systems would fire off warnings. Machine learning (ML) systems, however, which depend strongly on properties of their inputs (e.g. the i.i.d. assumption), tend to fail silently. This paper explores the problem of building ML systems that fail loudly, investigating methods for detecting dataset shift, identifying exemplars that most typify the shift, and quantifying shift malignancy. We focus on several datasets and various perturbations to both covariates and label distributions with varying magnitudes and fractions of data affected. Interestingly, we show that across the dataset shifts that we explore, a two-sample-testing-based approach, using pre-trained classifiers for dimensionality reduction, performs best. Moreover, we demonstrate that domain-discriminating approaches tend to be helpful for characterizing shifts qualitatively and determining if they are harmful.

Introduction

Standard software engineering practices rely on explicit error handling and exceptions. In contrast, machine learning models typically operate under the assumption that test-time data follows the same distribution as training data (the i.i.d. assumption). When this assumption is violated—due to sensor degradation, evolving user behavior, or adversarial intervention—models often continue to provide high-confidence predictions despite a significant drop in actual performance. This "silent failure" is a major hurdle for deploying ML in safety-critical environments. This study proposes a framework for "failing loudly" by detecting dataset shift before it leads to catastrophic errors.

The Shift Detection Pipeline

The authors propose a modular pipeline for detecting distribution changes between a reference "source" dataset and a newly observed "target" dataset. The process involves two primary stages: dimensionality reduction followed by statistical hypothesis testing.

The proposed shift detection pipeline: High-dimensional source and target data are compressed via dimensionality reduction before undergoing two-sample statistical testing to detect distribution shifts.

1. Dimensionality Reduction (DR)

Directly comparing high-dimensional distributions (like raw image pixels) is statistically inefficient. The study evaluates several DR techniques:

  • Traditional Methods: Principal Component Analysis (PCA) and Sparse Random Projections (SRP).
  • Autoencoders: Both trained (TAE) and untrained (UAE) variants.
  • Black Box Shift Detection (BBSD): This approach uses the internal state of the primary classifier itself, specifically the final class predictions or softmax probability distributions, as the compressed representation.
  • Domain Classifiers: Training a secondary model to distinguish between source and target data.

2. Statistical Testing

Once the data is projected into a lower-dimensional space, the pipeline applies two-sample tests. The authors compare multivariate methods like Maximum Mean Discrepancy (MMD) against multiple univariate tests (e.g., Kolmogorov-Smirnov) combined with a Bonferroni correction.

Empirical Evaluation and Results

The framework was tested across standard benchmarks including MNIST, CIFAR-10, and Fashion-MNIST. To simulate real-world conditions, the researchers introduced various perturbations, including Gaussian noise, image rotations, and adversarial attacks.

The most significant discovery was the effectiveness of Black Box Shift Detection (BBSD). By leveraging the softmax outputs of a pre-trained classifier, the system can detect shifts with remarkable sensitivity.

Detection sensitivity across different methods: The BBSD approach (orange line) consistently achieves a p-value near zero with significantly fewer samples than competing dimensionality reduction techniques.

As shown in the experimental results, BBSD often flags a shift with as few as 10-20 samples for severe perturbations, whereas methods like PCA or Autoencoders require much larger sample sizes to reach statistical significance. Interestingly, even Untrained Autoencoders (UAE)—which use random weights—performed surprisingly well as a baseline for multivariate testing when a pre-trained classifier was unavailable.

Characterizing Shift Malignancy

Not all shifts are detrimental. A "benign" shift might change the appearance of data without affecting the model's accuracy, while a "malignant" shift causes performance to plummet. The authors suggest using Domain Classifiers to identify "exemplars"—samples that the classifier is most confident belong to the target distribution. By inspecting these samples or evaluating the model's performance on them, practitioners can qualitatively determine if a detected shift requires intervention.

Conclusion

"Failing Loudly" provides a practical roadmap for monitoring ML models in production. The study demonstrates that the best tool for detecting when a model is out of its depth is often the model itself. By monitoring the distribution of confidence scores, systems can reliably alert human operators to dataset shifts before silent failures lead to real-world consequences.

Summary updated

Abstract

We might hope that when faced with unexpected inputs, well-designed software systems would fire off warnings. Machine learning (ML) systems, however, which depend strongly on properties of their inputs (e.g. the i.i.d. assumption), tend to fail silently. This paper explores the problem of building ML systems that fail loudly, investigating methods for detecting dataset shift, identifying exemplars that most typify the shift, and quantifying shift malignancy. We focus on several datasets and various perturbations to both covariates and label distributions with varying magnitudes and fractions of data affected. Interestingly, we show that across the dataset shifts that we explore, a two-sample-testing-based approach, using pre-trained classifiers for dimensionality reduction, performs best. Moreover, we demonstrate that domain-discriminating approaches tend to be helpful for characterizing shifts qualitatively and determining if they are harmful.
BibTeX
@inproceedings{rabanser2019failing,
  author = {Stephan Rabanser and Stephan Günnemann and Zachary C. Lipton},
  title = {{Failing Loudly: An Empirical Study of Methods for Detecting Dataset Shift}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=zOikCULPcc},
}
Figure