Featurized density ratio estimation

Kristy Choi, Madeline Liao, Stefano Ermon

Introduction

Estimating the ratio between two probability densities, $r(x) = p(x)/q(x)$, is a fundamental challenge in machine learning. It serves as a critical component for tasks such as out-of-distribution detection, mutual information estimation, and importance weighting. However, standard density ratio estimation (DRE) techniques often fail when the distributions have little overlap, a condition that leads to numerical instability and requires exponential amounts of data for accurate estimation.

The Problem: Pathological Failure in Disparate Distributions

When distributions $p$ and $q$ are significantly different—characterized by mismatched supports or low overlap—standard DRE algorithms encounter a "pathological" failure mode. In these cases, a simple classifier can easily find a separating hyperplane, causing ratio estimates to explode toward infinity or drop to zero prematurely. This makes it nearly impossible to obtain nuanced, accurate ratios in the low-density regions between the two distributions.

Methodology: The Featurized DRE Framework

To address this, we propose Featurized Density Ratio Estimation, a two-phase framework that leverages the properties of invertible normalizing flows.

Conceptual framework of Featurized Density Ratio Estimation (DRE).

The framework consists of three main steps:

  1. Normalizing Flows as Feature Maps: We use normalizing flows to learn a bijective (invertible) mapping $f_\theta$ between the complex input data $X$ and a simple latent space $Z$ (typically a unit Gaussian). By training the flow on a mixture of both datasets, the model "contracts" both distributions into the same high-density region of the latent space.
  2. Latent Ratio Estimation: Instead of estimating the ratio in the raw input space, we encode the data into the latent space and apply standard DRE algorithms (e.g., Kernel Mean Matching or KLIEP) there.
  3. Invertibility Guarantee: A key theoretical contribution is the proof that for any invertible mapping, the ratio of densities in the latent space is mathematically identical to the ratio in the input space. This allows us to solve the problem in a numerically friendlier coordinate system without losing the original meaning of the ratio.

Key Insights and Experimental Results

The core intuition behind this approach is the "Gaussian Ball" effect: normalizing flows naturally push data toward the center of a Gaussian distribution. This contraction forces disparate distributions to overlap more in the latent space than they do in the original pixel or feature space, creating a "bridge" for the DRE algorithm.

Comparison of different training strategies on synthetic 2D data.

Our evaluation across synthetic and real-world datasets (UCI, MNIST, Omniglot) yielded several key findings:

  • Maximum Likelihood Training: We found that simply having an invertible map is insufficient; the map must be trained via Maximum Likelihood to fit the data to a Gaussian. Purely discriminative invertible maps failed to improve ratio accuracy.
  • Domain Adaptation: On the UCI Breast Cancer dataset, the featurized method ("z-dre") achieved the lowest test error compared to standard input-space estimation.
  • Targeted Generation: When using estimated ratios to steer a generative model toward specific MNIST digits, the featurized approach generated 19.1% more samples with the correct target attribute than the baseline.
  • Data Augmentation: On the Omniglot task, using featurized ratios to re-weight synthetic samples improved downstream classification accuracy by 3.7% over a data-only baseline.

Conclusion

Featurized Density Ratio Estimation provides a robust solution for estimating ratios between disparate distributions by operating in a contracted latent space. While the computational overhead of training normalizing flows is a consideration, the gains in stability and accuracy—particularly for domain adaptation and generative modeling—are significant. Future work will explore relaxing the strict invertibility requirement to handle even more complex, high-dimensional data.

Summary updated

BibTeX
@inproceedings{choi2021featurized,
  author = {Kristy Choi and Madeline Liao and Stefano Ermon},
  title = {{Featurized density ratio estimation}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2021},
}
Figure