Most machine learning models are trained under the "static prior" assumption: the frequency of classes seen during training will match the frequency encountered in the real world. In practice, this assumption is frequently violated. Whether it is a self-driving car encountering a rare "unicycle" class or a fraud detection system facing a sudden shift in transaction patterns, models often struggle with label shift and class imbalance.
A growing body of research suggests that instead of treating class frequencies as fixed constants, models should dynamically estimate the underlying data distribution in real-time. By treating the class prior as a latent variable to be inferred, these methods allow models to adapt to new environments without expensive retraining.
The Problem of Static Priors
When a model trained on a balanced dataset is deployed in an environment where one class is dominant, it suffers from "recency bias" or "majority-class bias." Standard loss functions like Softmax implicitly assume a uniform distribution. If the test-time distribution is skewed, the model’s confidence scores become unreliable.
Milan Sulc and Jiri Matas demonstrated that simply adjusting a model's output based on estimated test-time priors can significantly boost accuracy. The challenge, however, is estimating these priors when ground-truth labels are unavailable.
Tracking the Stream with Moving Averages
The most direct way to estimate a shifting distribution is to track the model's own predictions over time. Researchers like Zhehao Huang have introduced techniques like Logit Adjusted Softmax (LAS), which uses a batch-wise sliding window to estimate class priors on the fly. This allows the training objective to adapt to changing frequencies in non-stationary data streams.
Similarly, in the context of online learning, Kleanthis Malialis proposed AREBA, which maintains dynamically sized memory queues for different classes. By using a time-decayed metric to estimate the current class distribution, the system can resize these buffers to maintain a balanced training signal even as the definition of the "minority" class evolves.
Statistical Prototypes and Latent Codes
Beyond simple counting, some methods estimate distributions by modeling the geometry of the feature space. Instead of storing raw samples, which is memory-intensive, Pascal Schlachter and colleagues use Gaussian Mixture Models (GMMs) to track class distributions as statistical parameters (means and covariances). This approach reduces memory overhead to just 2.2% of traditional methods while providing a stable reference for adaptation.
In Unsupervised Domain Adaptation (UDA), Boris Chidlovskii introduced LADA, which uses latent codes to disentangle the hidden structure of the target domain. By estimating the target class distribution during training, the model can dynamically re-weight its focus toward under-represented classes, maintaining resilience even when some classes are nearly missing.
Iterative Refinement via Expectation-Maximization
A powerful pattern for distribution estimation is the "Infer, Align, and Iterate" loop. When labels are unknown, the model uses its current state to guess the distribution, then uses that guess to refine its parameters.
- DOTA: Zongbo Han developed a framework for Vision-Language Models that uses an Expectation-Maximization (EM) approach to estimate the statistical distribution of class embeddings. This allows models like CLIP to adapt to new environments 20x faster than traditional prompt-tuning.
- ImbaGCD: For discovering new categories in imbalanced data, Ben Dai and Ziyun Li use iterative moving-average updates to refine class prior estimates. This prevents the model from ignoring rare "tail" classes during the discovery process.
Correcting Bias at Test-Time
Dynamic estimation is particularly crucial for Test-Time Adaptation (TTA), where a model must adjust to a single stream of unlabeled data. Hao Fu and the creators of CLIPScope use Bayesian scoring to identify "magnet" classes—categories that incorrectly attract out-of-distribution samples. By tracking the frequency of predicted classes and applying a marginal likelihood adjustment, they penalize these over-predicted classes to improve detection accuracy.
This shift from static to dynamic priors represents a fundamental move toward more autonomous AI. By building an internal model of the environment's distribution, these systems can maintain their performance in a messy, shifting world.