Abstract
Understanding how different classes are distributed in an unlabeled data set is an important challenge for the calibration of probabilistic classifiers and uncertainty quantification. Approaches like adjusted classify and count, black-box shift estimators, and invariant ratio estimators use an auxiliary (and potentially biased) black-box classifier trained on a different (shifted) data set to estimate the class distribution and yield asymptotic guarantees under weak assumptions. We demonstrate that all these algorithms are closely related to the inference in a particular Bayesian model, approximating the assumed ground-truth generative process. Then, we discuss an efficient Markov Chain Monte Carlo sampling scheme for the introduced model and show an asymptotic consistency guarantee in the large-data limit. We compare the introduced model against the established point estimators in a variety of scenarios, and show it is competitive, and in some cases superior, with the state of the art.
Introduction
In many real-world machine learning deployments, the distribution of classes changes between training and inference—a phenomenon known as prior probability shift. For example, a medical diagnostic model trained during a period of low disease prevalence will likely underestimate the proportion of cases during an outbreak. While standard classification focuses on individual predictions, quantification aims to estimate the aggregate class proportions in a new population.
Existing frequentist methods, such as "Adjusted Classify and Count" (ACC) and "Black-Box Shift Estimators" (BBSE), provide point estimates but suffer from several limitations. They lack inherent uncertainty quantification, can produce "pathological" outputs (like negative probabilities) in low-data regimes, and are often rigid regarding the dimensionality of the classifier's output space.
The Bayesian Framework: $M_{approx}$
To address these issues, we propose a generative Bayesian model, $M_{approx}$, which reinterprets existing black-box estimators through a unified probabilistic lens. Directly modeling high-dimensional features ($X$) is often computationally prohibitive. Instead, we utilize an auxiliary black-box classifier ($f$) to map these features into a discrete, low-dimensional space ($C$).
Our framework provides several technical advantages:
- Bayesian Unification: We demonstrate that established frequentist estimators are closely related to specific inference procedures within this model.
- Scalability: By deriving a "sufficient statistic" for the model, we enable Markov Chain Monte Carlo (MCMC) sampling that scales with the number of classes rather than the number of data points, making it suitable for massive datasets.
- Theoretical Consistency: We provide a proof of asymptotic consistency, showing that the Maximum A Posteriori (MAP) estimate converges to the true prevalence as data volume increases.
Experimental Results and Stability
We evaluated the model across diverse scenarios, including simulated categorical models, Gaussian mixtures, and real-world datasets such as the Wisconsin Breast Cancer Database and the Kidney Cell Atlas.
A key finding is the model's stability in low-data regimes. While frequentist point estimators like BBSE and Invariant Ratio (IR) can produce impossible negative estimates when data is scarce, the Bayesian approach remains naturally constrained within valid probability bounds.
In larger datasets, our method matched the accuracy of state-of-the-art point estimators while providing the critical benefit of credible intervals—rigorous bounds on the uncertainty of the prevalence estimates.
Discussion and Key Insights
A primary advantage of the Bayesian approach is its ability to "know what it doesn't know." In scenarios where classes are nearly indistinguishable to the classifier, the posterior distribution remains wide, correctly signaling high uncertainty rather than providing a potentially misleading point estimate.
Furthermore, the model is flexible regarding the number of classifier outputs ($K$) relative to the true number of labels ($L$). Unlike many existing methods that require $K \geq L$, our approach can extract meaningful prevalence information even from "simpler" classifiers. Finally, the Bayesian formulation allows for the integration of expert prior knowledge, such as the known rarity of a condition, which is not possible with standard frequentist estimators.
Limitations
The model relies on the "weak prior probability shift" assumption, meaning the relationship between classes and classifier outputs must remain constant across datasets. If the classifier's fundamental accuracy changes (e.g., due to covariate shift), the estimates may become biased. Future work will explore optimal discretization strategies for continuous classifier outputs and the implications of quantification for algorithmic fairness.
Summary updated