Kernel Selection is Model Selection: A Unified Complexity-Penalized Approach for MMD Two-Sample Tests

Yijin Ni, Xiaoming Huo

TL;DR

This paper reframes data-driven kernel selection for Maximum Mean Discrepancy (MMD) two-sample testing as a model selection problem. By introducing Complexity-Penalized MMD (CP-MMD), the authors enable grid-free, continuous optimization over complex kernel spaces—including deep neural networks—while maintaining strict Type-I error control and avoiding the catastrophic overfitting typical of prior methods.

What Problem Does This Paper Address?

Two-sample testing is a foundational problem in statistics and machine learning: given two datasets, $X$ and $Y$, do they come from the same underlying distribution? The Maximum Mean Discrepancy (MMD) is a popular non-parametric tool for answering this question. However, MMD's success hinges entirely on choosing the right kernel. A poorly chosen kernel will fail to detect subtle differences between distributions.

To maximize test power, researchers try to optimize the kernel using the observed data. But this introduces a major catch: data-driven optimization violates the independent and identically distributed (i.i.d.) assumptions required by classical MMD theory.

Existing solutions fall into two flawed camps:

  1. Ratio Criteria: These methods maximize the empirical MMD divided by its variance. When applied to rich kernel classes (like deep networks), they suffer from variance collapse—the optimizer drives both the MMD and its variance to zero, creating a deceptively massive ratio on training data that fails completely at test time.
  2. Aggregation Methods: These methods bypass the dependency by evaluating a finite, pre-specified grid of candidate kernels. While statistically sound, they cannot scale to continuous search spaces or deep learning architectures.

Methods

The authors bridge this gap by establishing kernel selection as a formal model selection problem.

1. Composite Kernel Unification

They unify various kernel selection regimes (linear, polynomial, and deep) under a single composite framework: $$k_h(x, x') = k(h(x), h(x'))$$ where $k$ is a simple base kernel and $h$ is a learnable feature map (such as a scaling factor, polynomial feature lift, or a deep neural network).

2. The CP-MMD Criterion

Instead of maximizing a fragile ratio, the authors propose a subtractive, complexity-penalized objective: $$J_{CP}(h) = \hat{\gamma}^2_{k,u}(h) - \hat{C}_1 \cdot \tilde{G}(h)$$

  • $\hat{\gamma}^2_{k,u}(h)$ is the standard unbiased empirical MMD.
  • $\tilde{G}(h)$ is a computable spectral-norm bound that measures the complexity of the feature map $h$.
  • $\hat{C}_1$ is a penalty coefficient calibrated via null permutations on a training split.

By incorporating a Uniform Concentration Inequality (UCI), this penalty mathematically absorbs the statistical "cost" of optimization, acting as a spectral brake that prevents the model from overfitting or collapsing into degenerate solutions.

3. Deployment Protocol

To guarantee exact Type-I error control, the data is split into training ($D_{tr}$) and testing ($D_{te}$) halves. The kernel is optimized on $D_{tr}$ using continuous gradient ascent, and the final permutation test is executed on the held-out $D_{te}$.

Datasets

The approach was validated across both synthetic and real-world benchmarks:

  • Synthetic Data: Multi-scale 2D Gaussian mixtures, a high-dimensional Gaussian mean-shift family (HDGM), and a multivariate Student-$t$ kurtosis-shift dataset.
  • Real-World Data:
    • UCI Higgs Boson Dataset: 28 kinematic features used to distinguish background noise from signal events.
  • CIFAR-10 vs. CIFAR-10.1: Image datasets used to test performance on natural distribution shifts.
  • Tennessee Eastman Process: An industrial chemical process monitoring dataset used for fault detection.

Key Insights and Ideas

  • Kernel Selection is Model Selection: Viewing the choice of a kernel through the lens of statistical learning theory allows the use of uniform concentration bounds to safely optimize kernels continuously.
  • The Danger of Ratios: Optimizing ratios in deep learning often leads to numerical exploits where the denominator (variance) vanishes faster than the numerator. Subtractive penalties are inherently more stable.
  • "B-Free" Scaling: Aggregation methods scale poorly because their computational cost grows linearly with the number of candidate configurations ($B$). CP-MMD tracks only the single optimized kernel, making test-time deployment independent of the search space size.

Key Results

Robustness to Model Capacity

As the hidden width ($w$) of a neural network discriminator increases, traditional ratio-based methods completely collapse due to overfitting and variance collapse. CP-MMD successfully maintains a perfect test power of 1.00 regardless of network size.

Figure 1: Class-richness sweep on a fixed signal (±1 SE): as w grows, Liu collapses through variance collapse, Plain overfits, while CP-MMD holds power 1.00.

Superior Power Across Regimes

CP-MMD matches or outperforms specialized state-of-the-art methods across all tested regimes:

  • On high-dimensional Gaussian mean-shift tasks, CP-MMD achieved a test power of 1.00 in scenarios where previous deep kernel methods dropped as low as 0.30.
  • On the real-world Higgs dataset, the polynomial variant of CP-MMD matched the baseline median heuristic (1.00) and outperformed grid-based aggregation methods.

Computational Efficiency

Because CP-MMD does not rely on a discrete grid, its deployment cost remains flat as the complexity of the search space grows. At a modest grid size of $B=10$, CP-MMD was 1.6$\times$ faster than aggregation alternatives like MMDAgg.

Higgs power and deployment wall-clock time comparison

Limitations and Future Work

The authors note two primary limitations:

  1. Calibration Scope: For extremely wide, overparameterized networks, the permutation calibration can degenerate ($\hat{C}_1 \to 0$). Currently, the penalty must be calibrated at a moderate, representative width and reused.
  2. Conservative Bounds: The Lipschitz-based complexity proxy $\tilde{G}$ is a worst-case bound, meaning it is theoretically conservative. The empirical calibration step absorbs this looseness, but tighter theoretical bounds remain an open challenge.

Future Directions: The authors suggest extending this complexity-penalized framework to other kernel-based statistics, such as the Hilbert-Schmidt Independence Criterion (HSIC) and Kernel Stein Discrepancies.

Summary updated

BibTeX
@inproceedings{ni2026kernel,
  author = {Yijin Ni and Xiaoming Huo},
  title = {{Kernel Selection is Model Selection: A Unified Complexity-Penalized Approach for MMD Two-Sample Tests}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=JhQRP9MfR8},
}
Figure