Statistical Model Criticism using Kernel Two Sample Tests

James Robert Lloyd, Zoubin GhahramaniNeurIPS 2015

Introduction

Statistical model criticism is the process of evaluating whether a trained model accurately captures the underlying data distribution. Traditionally, this requires human experts to manually select test statistics (like the mean or variance) to see if the model's output matches the observed data. However, as models grow in complexity—such as deep neural networks or automated machine learning pipelines—manually identifying the right statistic becomes increasingly difficult. A model might perfectly capture the mean but fail entirely on local density or higher-order correlations.

This paper introduces an automated, exploratory approach to statistical model criticism using Maximum Mean Discrepancy (MMD) two-sample tests. By leveraging the "witness function," the authors provide a tool that automatically identifies exactly where and how a complex model fails to represent the underlying data.

The Maximum Mean Discrepancy (MMD) Approach

The core innovation lies in applying Maximum Mean Discrepancy (MMD), a framework for comparing two probability distributions (the real data versus the model's generated data). In a Reproducing Kernel Hilbert Space (RKHS), the MMD is defined as a supremum over a class of functions. The specific function that achieves this maximum is known as the witness function.

Instead of just calculating a single p-value to determine if a model is "bad," this approach uses the witness function to visualize where the model is failing. The witness function essentially represents the difference between two kernel density estimates. A positive value indicates the model has placed too much mass in a specific region, while a negative value indicates it has placed too little.

Witness function on Newcomb's speed of light data

For high-dimensional data, such as images, the authors utilize Principal Component Analysis (PCA) to project the data into a lower-dimensional space before applying the MMD test. This ensures the witness function remains interpretable and the statistical test retains its power.

Key Insights and Results

The authors evaluate their method across diverse datasets, including Newcomb’s 1D Speed of Light measurements, synthetic high-dimensional clusters, MNIST handwritten digits, and various time-series datasets.

Automatic Feature Selection

Unlike traditional tests, MMD automatically selects the statistic that most highlights any discrepancy, effectively finding the "weakest link" in the model's representation. On the toy speed-of-light data, the MMD test successfully identified that a Normal distribution fit was poor because it lacked mass in the center, even when outliers were ignored.

The Interpretability of "Dreams"

When applied to generative models like Restricted Boltzmann Machines (RBMs) and Deep Belief Networks (DBNs), the witness function reveals systematic errors.

MNIST digits showing model discrepancies

For example, it showed that RBMs consistently confuse the identity of digits (e.g., generating a '0' when it should be a '7'), while DBNs suffer from "ghosting"—generating faded, spurious features in visible neurons. For RBMs trained on MNIST, the p-values were consistently less than 0.001, indicating a clear failure to capture the true distribution, with witness function peaks showing exactly which digit shapes were over-represented.

Identifying Heteroscedasticity

In Gaussian Process (GP) regression, the witness function identified regions of low variability in the data that the model failed to capture. It effectively spotted local heteroscedasticity (changing variance) that standard performance metrics might ignore. In a comparison of regression algorithms across 13 datasets, the MMD test revealed that even advanced methods like "Automatic Bayesian Covariance Discovery" (ABCD) failed to capture the structure of 4 out of the 13 datasets.

Falsification over Prediction

The authors argue for a paradigm shift: we should spend more effort trying to falsify models rather than just measuring predictive accuracy. A model can have high accuracy but still fail to capture the true data-generating process, leading to overconfidence or biased conclusions.

Limitations and Future Work

While powerful, the approach has limitations. The power of the MMD test depends heavily on the choice of kernel and its lengthscale. Although cross-validation helps, a poor choice could lead to missing certain types of discrepancies, such as outliers. Furthermore, the "curse of dimensionality" remains a challenge; in very high dimensions, kernel density estimation becomes difficult, degrading the interpretability of the witness function. Finally, adapting MMD tests to non-i.i.d. data structures like graphs or longitudinal data requires further research.

Summary updated

BibTeX
@inproceedings{lloyd2015statistical,
  author = {James Robert Lloyd and Zoubin Ghahramani},
  title = {{Statistical Model Criticism using Kernel Two Sample Tests}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2015},
  url = {https://openreview.net/forum?id=r1b7ytZObr},
}
Figure