Improved Balanced Classification with Theoretically Grounded Loss Functions

Corinna Cortes, Mehryar Mohri, Yutao Zhong

Abstract

In many real-world classification tasks, data is heavily imbalanced, with majority classes often overwhelming minority classes of interest. While standard training objectives like Cross-Entropy (CE) maximize overall accuracy, they frequently fail to achieve high balanced accuracy. This paper introduces two new families of surrogate loss functions—Generalized Logit-Adjusted (GLA) and Generalized Class-Aware (GCA) losses—designed to optimize for balanced accuracy with rigorous theoretical guarantees. We demonstrate that these losses provide stronger consistency bounds and superior empirical performance across various imbalanced benchmarks compared to existing industry standards.

Introduction

Class imbalance is a pervasive challenge in machine learning, appearing in critical domains such as medical diagnosis, fraud detection, and rare event prediction. In these scenarios, a model can achieve high nominal accuracy by simply favoring the majority class, effectively ignoring the rare but important minority samples. To address this, researchers typically aim to maximize balanced accuracy, which assigns equal weight to every class regardless of its frequency.

However, the ideal balanced loss function is non-convex and intractable for gradient-based optimization in neural networks. Consequently, practitioners rely on "surrogate losses," such as weighted cross-entropy or logit adjustment. While effective in some cases, many existing surrogates lack strong theoretical guarantees—meaning they may not consistently converge to the optimal balanced model—or fail when data is "separable," a condition where models distinguish classes easily during training but generalize poorly to imbalanced test sets.

Methodology

Our approach builds upon the General Cross-Entropy (GCE) framework, which introduces a parameter $q$ to modulate the loss's behavior. We propose two distinct families of losses:

1. Generalized Logit-Adjusted (GLA) Losses

GLA generalizes the popular Logit-Adjustment technique by shifting the model's raw outputs (logits) based on class priors. By integrating this adjustment into the GCE family, the loss becomes more flexible and robust, allowing for better calibration in the presence of varying class distributions.

2. Generalized Class-Aware (GCA) Losses

GCA extends standard class-weighted losses by incorporating class-dependent confidence margins. This mechanism enforces a specific "margin of safety" for minority classes, requiring the model to not only classify rare samples correctly but to do so with higher confidence. We suggest a default heuristic for setting these margins based on the cube root of the number of samples ($m_k^{1/3}$), which has proven robust in empirical testing.

Theoretical Contributions: Consistency Analysis

A core contribution of this work is the analysis of $\mathcal{H}$-consistency—a measure of how effectively minimizing a surrogate loss minimizes the target balanced loss for a specific set of models (hypothesis classes).

Our analysis reveals a significant theoretical advantage for GCA in extreme scenarios. We found that the error bounds for GLA scale with $1/p_{min}$ (where $p_{min}$ is the probability of the rarest class), whereas GCA scales with $1/\sqrt{p_{min}}$. This indicates that GCA provides much stronger theoretical guarantees as imbalance becomes more severe. Furthermore, while GLA requires an "unbounded" or infinitely powerful model to reach perfect consistency, GCA remains consistent even for "bounded" hypothesis sets, making it more reliable for the constrained neural networks used in practice.

Experimental Results

We evaluated GLA and GCA using a ResNet-32 architecture on three computer vision benchmarks: CIFAR-10, CIFAR-100, and Tiny ImageNet. We simulated two types of imbalance:

  • Long-tailed: Class sizes decrease exponentially.
  • Step imbalance: A sharp divide between "head" classes and "tail" classes.

We tested these under moderate (100:1) and extreme (1000:1) imbalance ratios. Our findings include:

  • Performance Leadership: Both GLA and GCA consistently outperformed standard Cross-Entropy, Weighted Cross-Entropy, and original Logit-Adjustment (LA). On CIFAR-100 with extreme long-tailed imbalance, our methods reduced balanced error by several percentage points over the LA baseline.
  • GLA as the All-Rounder: GLA generally performs slightly better on standard benchmarks and under moderate imbalance conditions.
  • GCA for Extreme Imbalance: In line with our theoretical bounds, GCA exhibits a clear performance edge in highly imbalanced settings (1000:1 ratio).

Conclusion and Future Work

GLA and GCA offer a theoretically grounded and empirically superior alternative to standard imbalanced learning techniques. By leveraging the GCE framework and margin-based adjustments, these losses provide a more robust path toward balanced classification.

While these methods introduce new hyperparameters (such as $q$ and the margin $\rho$), our suggested defaults provide a strong starting point. Future research will explore extending these losses to structured prediction tasks, such as object detection and segmentation, as well as multi-label classification settings where class dependencies further complicate the imbalance problem.

Summary updated

BibTeX
@inproceedings{cortes2025improved,
  author = {Corinna Cortes and Mehryar Mohri and Yutao Zhong},
  title = {{Improved Balanced Classification with Theoretically Grounded Loss Functions}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=SkZUo6Xg61},
}
Figure