NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

E-Valuating Classifier Two-Sample Tests

Teodora Pandeva, Tim Bakker, Christian A. Naesseth, Patrick Forré

Introduction

Two-sample testing is a fundamental task in machine learning and statistics, centered on a single question: are two given datasets drawn from the same underlying distribution? This task is critical for detecting data drift in production models, evaluating the quality of generative models, and performing scientific hypothesis testing.

For high-dimensional data like images, the Classifier Two-Sample Test (C2ST) has become the gold standard. In a standard C2ST, a neural network is trained to distinguish between two samples; if the network's accuracy is significantly better than random guessing, the null hypothesis—that the distributions are identical—is rejected. However, traditional C2ST relies on fixed sample sizes and p-values, making it ill-suited for modern workflows where data arrives sequentially.

The Problem: The "Peeking" Penalty

In many real-world scenarios, practitioners want to collect data until they have sufficient evidence to reach a conclusion. However, traditional frequentist methods are not designed for this "anytime" analysis. If a researcher uses standard p-values and repeatedly checks the results to decide whether to stop or continue (a practice known as "peeking"), they inadvertently engage in p-hacking. This leads to a dramatic inflation of the Type I error rate—the probability of claiming a difference exists when it does not. In sequential settings, a standard t-test or C2ST can see its false positive rate skyrocket to 60% or higher, far exceeding the typical 5% significance threshold.

Methodology: E-Values and Sequential Testing

Researchers from the University of Amsterdam have addressed this limitation by introducing E-C2ST, a framework that replaces p-values with e-values.

E-Values as Bets

An e-value can be conceptualized as a bet against the null hypothesis. If the null hypothesis is true, the expected value of the e-value is at most 1. If the e-value grows large, it provides mounting evidence that the null hypothesis is false. Unlike p-values, e-values possess a multiplicative property: independent e-values can be multiplied together to form a new, valid e-value. This makes them inherently suited for sequential data; as new batches of data arrive, the evidence is simply multiplied into a running total.

The M-Split Approach

To implement this, E-C2ST utilizes an "M-split" strategy. Rather than a single train/test split, the data is partitioned into multiple sequential batches. For each new batch, a classifier is trained on all preceding data and then evaluated on the current batch to generate a new e-value. This process ensures that the test remains "anytime-valid," allowing researchers to stop the experiment the moment the cumulative e-value crosses a predefined threshold (e.g., $1/\alpha$).

The Mixing Parameter

To maintain robustness while the classifier is still learning, the authors introduce a mixing parameter, $\lambda$. This hyperparameter balances the null model (random guessing) with the alternative model (the neural network), ensuring the test remains stable even in the early stages of data collection when the classifier may be weak.

Experimental Evaluation

The authors evaluated E-C2ST across three distinct benchmarks:

  1. Blob Dataset: A synthetic 2D Gaussian mixture model where samples differ only in variance, testing the model's sensitivity to subtle distributional shifts.
  2. MNIST & Corrupted MNIST: Comparing the classic handwritten digit dataset against versions corrupted by a DCGAN to simulate realistic data discrepancies.
  3. KDEF (Karolinska Directed Emotional Faces): A high-dimensional dataset of human facial expressions, testing the ability to distinguish between complex emotional categories like "happy" versus "afraid."

Key Results and Insights

1. Anytime Validity and Early Stopping

The primary advantage of E-C2ST is optional continuation. Because the test is anytime-valid, researchers can stop as soon as they reach a conclusion. In experiments with the Blob and MNIST datasets, E-C2ST reached maximum statistical power (a 100% rejection rate when the null was false) significantly faster than sequential baselines like S-C2ST or M-C2ST.

2. Strict Error Control

Across all benchmarks, E-C2ST maintained a Type I error rate well below the significance level ($\alpha = 0.05$). In contrast, sequential p-value methods failed to control for false positives, highlighting the danger of using fixed-sample statistics in a sequential context.

3. Data and Computational Efficiency

Traditional C2ST is often data-inefficient, as it requires a large portion of the data to be set aside for training, leaving only a fraction for the actual test. E-C2ST utilizes the entire dataset more effectively by treating every batch (after the initial training phase) as a test set. Furthermore, by allowing for early rejection, E-C2ST can reduce "wall clock" time, as it does not always need to process the full dataset or perform the hundreds of permutations required for p-value calculations.

Limitations and Future Directions

While E-C2ST offers a robust new standard, it is not without challenges. In small data regimes, the computational overhead of retraining or updating models for each batch can be significant. Additionally, the test is sensitive to batch size; very small batches (e.g., 8 samples) can lead to training instability, resulting in weaker e-values.

Future research directions include the integration of online learning to update models incrementally rather than retraining, and active learning to identify the most informative samples for testing, potentially further increasing the power and efficiency of the framework.

Summary updated

BibTeX
@article{pandeva2024e,
  author = {Teodora Pandeva and Tim Bakker and Christian A. Naesseth and Patrick Forré},
  title = {{E-Valuating Classifier Two-Sample Tests}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2024},
}
Figure