Classification Accuracy as a Proxy for Two Sample Testing.

Aaditya Ramdas, Aarti Singh, Larry A. Wasserman

TL;DR

This paper provides a rigorous theoretical foundation for a common data science "hack": using classification accuracy to determine if two datasets are statistically different. The authors prove that while this approach is slightly less powerful than specialized tests for simple mean shifts, it is a consistent and flexible tool for high-dimensional, complex data.

What Problem Does This Paper Address?

In classical statistics, the two-sample test asks a fundamental question: Do these two sets of data come from the same underlying distribution? For simple data, we have standard tools like the t-test or Hotelling’s $T^2$. However, modern data is often high-dimensional (many features relative to samples) and highly structured (like images or brain scans).

Practitioners often skip the classical tests and instead train a machine learning classifier to distinguish between the two groups. If the classifier's held-out accuracy is significantly better than a coin flip (50%), they conclude the distributions are different. While intuitive, the statistical properties of this "proxy" test—specifically its power and efficiency in high dimensions—were not well-understood until now.

Methods

The authors investigate the sample-splitting approach:

  1. Split the data into a training set and a test set.
  2. Train a classifier (e.g., Linear Discriminant Analysis or Naive Bayes) on the training set.
  3. Calculate the accuracy on the held-out test set.
  4. Use this accuracy as a test statistic, comparing it against a null distribution (either via Gaussian approximation or permutation testing).

The paper employs high-dimensional asymptotics, where both the number of samples ($n$) and the number of features ($d$) grow to infinity. They specifically analyze Fisher’s Linear Discriminant Analysis (LDA) and its variants to derive exact expressions for the test's power.

Datasets

The paper primarily uses synthetic datasets to validate its theoretical findings:

  • Multivariate Gaussians: Used to study mean-shift alternatives in high dimensions.
  • Elliptical Distributions (e.g., Multivariate $t$-distributions): Used to test the robustness of the theory against heavy-tailed data.
  • Simulation Parameters: Typically $n_0 = n_1 = d = 200$, varying the signal-to-noise ratio ($\delta$).

While no specific real-world benchmark datasets (like ImageNet) are used, the authors cite practical motivations from neuroscience (fMRI decoding) and genetics, where this classification-based testing is already common practice.

Key Insights and Ideas

  • Testing is "Easier" than Classification: A fascinating "aha moment" in the paper is that a classifier can be a great tester even if it's a terrible predictor. Even in regimes where the best possible classifier's accuracy approaches 50% (chance), the test based on that accuracy can still reliably reject the null hypothesis.
  • The $1/\sqrt{\pi}$ Efficiency Gap: For Gaussian data, the authors found that the classification-based test is only worse than the optimal Hotelling’s test by a constant factor. Specifically, it achieves an Asymptotic Relative Efficiency (ARE) of $1/\sqrt{\pi} \approx 0.564$. This means you need roughly 1.77x more samples to get the same power as the specialized test, but the "scaling" behavior remains optimal.
  • Heavy Tails are a Plus: For distributions with heavier tails (like the $t$-distribution), the classifier-based test actually becomes more efficient relative to the Gaussian case.
  • Hotelling’s $T^2$ is Still King (Sometimes): The authors prove that Hotelling’s test remains minimax optimal as long as the dimension $d$ grows slower than the sample size $n$ ($d = o(n)$), defending a classical tool that is often undervalued in high-dimensional settings.

Key Results

  • Consistency: The authors prove that for any classifier, the test is consistent (power approaches 1) as long as the classifier's true accuracy stays even slightly above chance as $n, d \to \infty$.
  • Power Matching: The power expressions for LDA-based testing and Hotelling-type tests match exactly in terms of their dependence on $n, d, \delta,$ and $\Sigma$.
  • Permutation Validity: They show that permutation-based versions of these tests are consistent as long as the number of permutations $P$ is greater than $(1-\alpha)/\alpha$.

Limitations and Future Work

  • Pointwise vs. Uniform Power: The current results are "pointwise," meaning they hold for specific sequences of distributions. Proving "uniform" power—guarantees that hold across an entire class of distributions—remains a difficult open problem.
  • Linear vs. Non-linear: The deep theoretical analysis is restricted to linear classifiers (LDA, Naive Bayes). While the authors suggest the logic should extend to non-linear kernels or neural networks, the math for those cases is significantly more complex and not yet solved.
  • Sample Splitting Inefficiency: Using only half the data for training is inherently wasteful. The authors suggest exploring "ensemble accuracy" (averaging over multiple splits) or "resubstitution" (testing on training data with proper correction) as promising future directions.

Summary updated

BibTeX
@misc{ramdas2016classification,
  author = {Aaditya Ramdas and Aarti Singh and Larry A. Wasserman},
  title = {{Classification Accuracy as a Proxy for Two Sample Testing.}},
  year = {2016},
  eprint = {1602.02210},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1602.02210},
}
Figure