AutoML Two-Sample Test

Jonas M. Kübler, Vincent Stimper, Simon Buchholz, Krikamol Muandet, Bernhard Schölkopf

Abstract

Two-sample testing is a fundamental task in statistics, aimed at determining whether two datasets originate from the same underlying distribution. While classical methods struggle with high-dimensional data and modern non-parametric tests require expert manual tuning, this paper introduces a novel framework that automates the process. By demonstrating that minimizing Mean Squared Error (MSE) is equivalent to maximizing the power of a statistical test, the authors leverage Automated Machine Learning (AutoML) to create a robust, "off-the-shelf" testing procedure. This approach achieves state-of-the-art performance across diverse benchmarks, from particle physics to computer vision, without requiring manual intervention.

Introduction

Two-sample testing is a cornerstone of statistical inference and machine learning. Whether a researcher is validating the efficacy of a new medical treatment against a placebo or an engineer is monitoring a production model for distribution shift, the core question remains: Are these two sets of data coming from the same underlying distribution?

Despite the simplicity of the question, providing a powerful answer for modern, high-dimensional data is complex. In their NeurIPS 2022 paper, Jonas M. Kübler and colleagues from the Max Planck Institute and CISPA propose a paradigm shift: treating the construction of a statistical test as an AutoML problem. Their framework, autotst, simplifies the process while maintaining high statistical power.

The Problem: The Expert Tuning Bottleneck

Classical statistical tests, such as the Student’s t-test, rely on rigid parametric assumptions—often assuming data follows a normal distribution. These assumptions frequently fail in modern contexts involving images, text, or complex tabular data. While non-parametric alternatives like the Maximum Mean Discrepancy (MMD) offer more flexibility, they introduce a new challenge: the "expert tuning" problem. To achieve high test power, researchers must manually select kernels or witness functions, a process that requires significant domain expertise and trial-and-error.

In supervised learning, the burden of manual tuning has been largely mitigated by AutoML frameworks like AutoGluon, which automate feature engineering and model selection. This paper explores whether these same tools can be repurposed to solve the two-sample testing problem.

Methodology: The AutoML Pipeline

The authors propose a streamlined two-stage pipeline to automate the test:

  1. Stage I (Optimization): The available data is split into a training set and a test set. Data from the first distribution is labeled "1," and data from the second is labeled "0." An AutoML framework (specifically AutoGluon) is then tasked with training a "witness function" $h$ to minimize the Mean Squared Error (MSE) on the training set.
  2. Stage II (Testing): The learned witness function is applied to the held-out test set. The test statistic is calculated as the difference between the mean values assigned to each group. To determine statistical significance, a standard permutation test is used to derive a p-value.

The Theoretical "Secret Sauce"

The primary theoretical contribution of this work is the proof that minimizing the (weighted) squared loss is mathematically equivalent to maximizing the Signal-to-Noise Ratio (SNR) of the resulting test. This bridge between regression objectives and hypothesis testing power means that by simply optimizing for MSE, the AutoML system is implicitly searching for the most powerful statistical test possible for that specific dataset.

Key Insights

Continuous vs. Binary Witness Functions

Previous "classifier-based" tests often relied on binary classification accuracy. However, this research demonstrates that using a continuous witness function—such as raw regression outputs or class probabilities—provides significantly higher test power. This allows the test to detect subtle distributional differences that a hard binary classifier might ignore.

Interpretability and Resource Trading

The AutoML approach offers two unique practical advantages:

  • Interpretability: Because the witness function assigns a score to every data point, researchers can inspect samples with the highest and lowest scores. This reveals why the test rejected the null hypothesis (e.g., identifying specific features or classes that have shifted).
  • Resource Trading: Users can explicitly trade computation time for statistical sensitivity. By increasing the time limit (t_max) for the AutoML training phase, the system can find more sophisticated witness functions, potentially uncovering shifts that were previously undetectable.

Experimental Results

The researchers evaluated the autotst package against several benchmarks:

  • Low-Dimensional Data: On the "Blob" dataset (a grid of Gaussians) and the "Higgs" dataset (particle physics), the AutoML test matched or exceeded the performance of specialized statistical tests.
  • High-Dimensional Distribution Shift: Using MNIST and CIFAR-10, the authors simulated 33 types of shifts, including adversarial attacks, rotations, and class removals. The AutoML approach proved remarkably robust, consistently detecting shifts where other methods failed, all without manual hyperparameter adjustment.
  • Efficiency: Even with a restricted training budget of one minute, the AutoML test remained highly effective on complex image data.

Limitations and Future Directions

While powerful, the method has trade-offs. The requirement to split data for the witness function training reduces the sample size available for the final test statistic. Future research may look into k-fold cross-validation techniques to improve data efficiency. Additionally, for very simple, low-dimensional Gaussian data, classical tests remain more computationally efficient. The AutoML approach is most valuable in high-stakes, high-dimensional scenarios where the nature of the data shift is unknown.

Conclusion

By framing two-sample testing as a supervised learning task, Kübler et al. have successfully bridged the gap between AutoML and frequentist statistics. Their approach removes the need for manual kernel selection, providing a powerful, interpretable, and automated tool for detecting distribution shifts in the modern data landscape.

Summary updated

BibTeX
@inproceedings{kubler2022automl,
  author = {Jonas M. Kübler and Vincent Stimper and Simon Buchholz and Krikamol Muandet and Bernhard Schölkopf},
  title = {{AutoML Two-Sample Test}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
}
Figure