Restoring balance: principled under/oversampling of data for optimal classification

Emanuele Loffredo, Mauro Pastore, Simona Cocco, Rémi Monasson · DOI

Abstract

Class imbalance is a pervasive challenge in machine learning, often addressed through heuristic sampling methods. This paper introduces a rigorous theoretical framework using the "replica method" from statistical mechanics to analyze linear classifiers in high-dimensional regimes. We derive exact analytical expressions for generalization performance and demonstrate that "mixed" sampling strategies—combining under- and oversampling—are frequently optimal for maximizing balanced accuracy. Our findings are validated across synthetic and real-world datasets, including MNIST and CelebA, and extend qualitatively to deep learning architectures.

Introduction

Class imbalance occurs when one class significantly outnumbers another, a common scenario in fields like medical diagnosis and fraud detection. While practitioners have long used empirical techniques like Random Undersampling (RUS) and Random Oversampling (ROS), a "sharp" theoretical understanding of their efficacy has been lacking. This work provides a principled mathematical foundation for data balancing, moving beyond trial-and-error to predict optimal sampling strategies based on the underlying statistics of the data.

Methods

The authors employ the statistical mechanics of learning to analyze linear Support Vector Machines (SVMs) in the high-dimensional regime, where the number of features $L$ and samples $P, N$ scale proportionally toward infinity.

Key methodological components include:

  • Analytical Generalization Curves: Exact formulas for the confusion matrix, Balanced Accuracy (BA), and Area Under the ROC Curve (AUC) as functions of the imbalance ratio.
  • Likelihood-Informed Sampling (LIS): A strategy using Restricted Boltzmann Machines (RBMs) to learn the minority class distribution, generating "informed" synthetic samples while filtering out less informative majority samples.
  • Saddle-Point Analysis: Solving the optimization problem by finding stationary points of a free-energy-like quantity, allowing for performance prediction without extensive simulation.
Conceptual diagram illustrating how undersampling, oversampling, and mixed sampling strategies transform an initial imbalanced dataset into a balanced composite.

Key Insights and Results

The theoretical framework reveals several critical aspects of learning from imbalanced data:

The Accuracy Trap and Margin Trade-off

Standard accuracy (ACC) is quantitatively shown to be a misleading metric, as it rewards models for ignoring the minority class. Furthermore, the researchers identified a "balance-to-performance trade-off" controlled by the SVM margin ($\kappa$). While a higher margin improves stability in balanced settings, it makes the model "brittle," causing performance to collapse more rapidly as imbalance increases.

Optimality of Mixed Strategies

Geometrically, restoring balance allows the model to "un-bias" its decision boundary. In an imbalanced setting, the boundary is pushed toward the minority class; sampling techniques effectively "push back," centering the boundary. The study proves that neither pure undersampling nor pure oversampling is typically optimal. Instead, a "mixed" approach typically yields the highest Balanced Accuracy.

Balanced Accuracy (BA) as a function of mixing percentage for various initial imbalance ratios ($\rho^-$). The peaks in the curves demonstrate that mixed sampling strategies often outperform pure under- or oversampling.

Validation on Real-World Data and Deep Learning

Analytical curves derived from the replica method showed near-perfect agreement with numerical experiments on datasets like MNIST, FashionMNIST, and CelebA. Additionally, while the theory was derived for linear models, the qualitative benefit of mixed sampling was confirmed on a ResNet-50 architecture using CIFAR-10, suggesting these physics-based insights are applicable to modern deep learning.

Discussion

While the current derivation assumes homoscedasticity (shared covariance matrices) and focuses on binary classification, it offers a powerful tool for optimizing data balancing. Future work will aim to extend these insights to heteroscedastic data and multiclass "long-tail" distributions. By providing a theoretical anchor for sampling heuristics, this research enables more principled development of robust classifiers for imbalanced real-world applications.

Summary updated

BibTeX
@inproceedings{loffredo2024restoring,
  author = {Emanuele Loffredo and Mauro Pastore and Simona Cocco and Rémi Monasson},
  title = {{Restoring balance: principled under/oversampling of data for optimal classification}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=rHylzxK3HU},
}
Figure