Adaptive Resampling based Training for Imbalanced Classification
Python · PyTorch · Matplotlib
A modality-agnostic adaptive resampling method to handle class imbalance in supervised classification. Paper submitted to MLWA Journal.
Abstract
Traditional resampling methods for addressing class imbalance in supervised classification typically use fixed sampling distributions, either uniformly undersampling the majority class or oversampling the minority class. These static strategies fail to account for changes in class-wise learning difficulty during the training process. This paper proposes an Adaptive Resampling-based Training (ART) method that periodically updates the distribution of the training data based on the model’s class-wise performance. Specifically, ART uses class-wise macro F1 scores computed at fixed intervals to determine the degree of resampling to perform.
In contrast to instance-level difficulty modeling, which can be noisy and overly sensitive to outliers, ART adapts at the class level using the defined performance metric. This allows the model to incrementally shift its attention towards underperforming classes in a way that better aligns with the optimization objective.
Experimental results across diverse class-imbalanced benchmark datasets demonstrate that ART consistently outperforms both resampling-based and algorithm-level methods, including Synthetic Minority Oversampling Technique, nearmiss undersampling, and cost-sensitive learning on binary as well as multi-class classification tasks with varying degrees of imbalance.
In most settings, these improvements are statistically significant. On tabular datasets, gains are significant under both paired t-tests and Wilcoxon signed-rank tests (p < 0.05), while performance on text and image tasks remains consistently favorable. ART improves macro F1 by an average of 2.64 percentage points across all tested tabular datasets. Unlike existing methods, ART consistently delivers the highest macro F1 score, making it a reliable and broadly effective choice for imbalanced classification problems.
Method
ART can be viewed as a dynamic reweighting method that operates on the data distribution rather than the loss. In standard empirical risk minimization (ERM) with imbalanced data, optimization minimizes a weighted sum of class-wise risks, where the weights are fixed by empirical class priors. As a result, majority classes dominate gradient updates, while minority classes remain under-optimized.
Training on the original dataset minimizes:
Here, Πᵢ is the empirical prior of class i. This objective is static, so class contributions remain fixed even if class-wise performance differs during training.
ART replaces the fixed prior with a time-varying sampling distribution pᵢᵗ that adapts to model performance. At training step t, ART approximately optimizes:
This makes ART a form of dynamic ERM. Instead of scaling losses, ART changes how often each class is sampled. Classes that perform poorly are sampled more often.
ART updates pᵢᵗ using class-wise macro F1-scores from a validation set. Macro F1 balances precision and recall and is insensitive to class frequency. A low macro F1 indicates low recall, low precision, or both, making it a reliable signal of class difficulty.
ART defines a difficulty score sᵢ = 1 − fᵢ, where fᵢ is the class-wise F1-score. Lower performance directly leads to higher sampling priority. This creates a feedback loop where validation performance guides future data exposure.
Performance-based Sampling
Every bf epochs, ART evaluates class-wise F1-scores on a validation set. Difficulty is computed as:
These scores are normalized to form a probability distribution:
Classes with lower performance receive higher sampling probability. As performance improves, the distribution adapts and shifts focus to other underperforming classes.
Blending with Class Priors
To stabilize training, ART blends adaptive weights with empirical class priors:
The parameter c ∈ [0,1] controls the trade-off. Higher c favors the original data distribution, while lower c emphasizes hard classes. This prevents classes with near-zero adaptive weight from being temporarily excluded, especially early in training.
Computational Overhead
ART differs from the baseline only during periodic refresh steps. If training runs for E epochs with boost frequency bf, the number of refreshes is:
Total runtime is:
Each refresh consists of:
Where:
T_val_fwdis a forward pass over the validation setT_metriccomputes per-class F1-scores and weightsT_resamplerebuilds the training sampler
Space overhead
ART does not change dataset size. It allocates temporary arrays during refresh, causing a small peak memory increase, but stores no state that grows with training length.
Experiments
Compared Methods
We benchmark ART against a broad set of commonly used methods for handling class imbalance. These methods fall into four categories.
No Imbalance Handling
- Baseline: Standard training with no explicit mechanism to address class imbalance.
Resampling-based Methods
- Random Oversampling (ROS): Duplicates minority class samples.
- Random Undersampling (RUS): Removes samples from majority classes.
- SMOTE: Generates synthetic samples for minority classes.
- MSMOTE: A variant of SMOTE that focuses on difficult minority samples.
- NearMiss Undersampling: Selects majority samples close to minority samples.
Loss-based Methods
- Cost-Sensitive Learning: Assigns higher loss weights to minority classes.
- Focal Loss: Downweights easy examples and focuses on hard ones.
- Online Hard Example Mining (OHEM): Prioritizes samples with high loss.
- LDAM + DRW: Combines margin adjustment with deferred reweighting.
Hybrid Methods
- Balanced Meta-Softmax (BALMS): Integrates class-balanced priors directly into the softmax formulation.
This setup allows us to compare ART against data-level, loss-level, and hybrid imbalance handling strategies under a unified evaluation protocol.
Experimental Setup
Each method is evaluated using 20 random seeds to ensure robustness. We report the following:
- Mean and standard deviation of macro F1 scores on the held-out test set.
- Paired t-test and Wilcoxon signed-rank test to assess the statistical significance of ART compared to each baseline.
- Average rank of each method across the 20 runs
Results
Ablation Studies
The preprint is on arXiv, with the full method, proofs, and per-dataset tables.