Testing For Distribution Shifts with Conditional Conformal Test Martingales

Shalev Shaer, Yarin Bar, Drew Prinster, Yaniv Romano

TL;DR

This paper introduces a new method for detecting distribution shifts in data streams, called Conditional Conformal Test Martingales (CCTMs). Unlike existing methods that can be fooled by shifts in the data itself, CCTMs use a fixed reference dataset to maintain reliable detection and offer theoretical guarantees of faster and more powerful shift detection.

What Problem Does This Paper Address?

In many real-world applications, such as machine learning models deployed in the wild, it's crucial to detect when the incoming data starts to deviate from the data the model was trained on. This "distribution shift" can degrade performance. Existing methods, like Conformal Test Martingales (CTMs), use a "testing by betting" approach where they continuously update their reference data with new incoming samples. While this provides a guarantee of controlling false alarms (Type-I error) at any point in time, it has a critical flaw: "test-time contamination." When a shift occurs, the new, shifted data contaminates the reference set. This makes it harder for the test to recognize the shift, leading to slower detection and reduced power. The authors aim to solve this by developing a test that avoids this contamination while still maintaining strong theoretical guarantees.

Methods

The core of the proposed method, Conditional Conformal Test Martingales (CCTMs), is to avoid "test-time contamination" by using a fixed reference dataset ($D_0$) to evaluate incoming test samples. Instead of growing the reference set with test data, CCTMs compare each new test sample to this static $D_0$.

The key technical challenge is that using a fixed, finite reference set to estimate the true data distribution introduces estimation error. This error can break the statistical guarantees of the betting process. To address this, the authors:

  1. Robust Martingale Construction: They develop a novel betting function that explicitly accounts for the uncertainty introduced by estimating the null distribution from the finite $D_0$. This is achieved by constructing uniform confidence bounds for the true distribution based on $D_0$.
  2. Online Learning of Betting Strategy: They use an Online Newton Step (ONS) algorithm to adaptively learn the optimal betting strategy ($n_t$) in real-time, ensuring the bet is placed strategically to maximize wealth when a shift occurs.
  3. Theoretical Guarantees: They provide finite-sample, anytime-valid Type-I error control, and crucially, theoretical guarantees for asymptotic power one and bounded expected detection delay.

Datasets

The paper uses synthetic datasets for experiments, primarily drawing from a standard normal distribution ($N(0,1)$) for the null hypothesis and shifted distributions (e.g., $N(1,1)$) for testing.

For evaluation, they use the ImageNet-C benchmark. This dataset is derived from the ImageNet validation set and includes 15 types of common image corruptions (noise, blur, weather, digital) applied at various severity levels. The authors use this to simulate realistic distribution shifts and assess their method's performance against standard CTMs.

Key Insights and Ideas

  • Test-Time Contamination is a Real Problem: The paper clearly demonstrates how growing reference sets in standard CTMs can dilute the evidence of a distribution shift, leading to slower detection and reduced power. This is a crucial practical limitation of existing methods.
  • Fixed Reference Sets are Key to Robustness: By using a fixed, in-distribution reference set, CCTMs avoid the contamination issue entirely, allowing them to maintain high sensitivity to shifts.
  • Accounting for Estimation Error is Non-Negotiable: Simply using an empirical estimate of the distribution from a fixed set isn't enough. The authors show that explicitly modeling and bounding the estimation error is essential for maintaining valid Type-I error control.
  • Theoretical Guarantees for Power and Delay: Beyond just controlling false alarms, the paper provides theoretical backing for their method's ability to detect shifts quickly and reliably, which is a significant advancement.

Key Results

  • Improved Detection Speed and Power: Empirically, CCTMs consistently detect distribution shifts faster and with higher power than standard CTMs across various scenarios (immediate change-points, delayed change-points, gradual shifts).
  • Effective on Real-World Corruptions: On the ImageNet-C benchmark, CCTMs outperform standard CTMs, especially as the size of the fixed reference set increases. They show faster detection times across different corruption types.
  • Type-I Error Control: The proposed method rigorously controls the Type-I error rate at a user-specified level ($\alpha$), even with finite reference sets, as validated by experiments.
  • Theoretical Power Guarantees: The paper proves that CCTMs achieve asymptotic power one (meaning they will eventually detect a shift with probability 1) and provides bounds on the expected detection delay.

Limitations and Future Work

  • Reference Set Size: The performance of CCTMs is sensitive to the size of the fixed reference set ($D_0$). When $D_0$ is too small, the confidence bands widen, making the test overly conservative. The authors suggest that recent methods for generating synthetic data could help mitigate this.
  • Betting Function Choice: The current betting function targets deviations in the mean of conformal p-values. The authors suggest that extending the test to utilize other betting functions could further enhance statistical power by detecting deviations that don't alter the mean.
  • Mixture Martingales: While ONS is used for learning the betting parameter, the authors note that sequential mixture martingales could be an alternative for adaptively learning the betting parameter. However, proving formal power guarantees for mixture martingales under their specific betting function poses theoretical challenges that are left for future work.

Summary updated

BibTeX
@inproceedings{shaer2026testing,
  author = {Shalev Shaer and Yarin Bar and Drew Prinster and Yaniv Romano},
  title = {{Testing For Distribution Shifts with Conditional Conformal Test Martingales}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=B8sTBdGvqG},
}
Figure