---
title: "A systematic study of the class imbalance problem in"
description: "How class imbalance affects image classification with convolutional networks, when oversampling helps, and why score adjustment can…"
canonical: "https://research.elamur.ai/free/en/papers/buda-2018-systematic-study-class-imbalance-problem/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/buda-2018-systematic-study-class-imbalance-problem/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2018](https://md.research.elamur.ai/free/en/papers/2018/) / A systematic study of the class imbalance problem in convolutional neural networks

# A systematic study of the class imbalance problem in convolutional neural networks

Paper · 2018 · Mateusz Buda, Atsuto Maki and Maciej A. Mazurowski

**Authors:** Mateusz Buda, Atsuto Maki and Maciej A. Mazurowski · **Year:** 2018 · **Venue:** Neural Networks · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[Cited by **70** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/buda-2018-systematic-study-class-imbalance-problem/cited-by/) · Neural Networks · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1710.05381)
- [DOI 10.1016/j.neunet.2018.07.011](https://doi.org/10.1016/j.neunet.2018.07.011)
- [arXiv 1710.05381](https://arxiv.org/abs/1710.05381)

## Summary

A classifier can see thousands of examples of a common category during training and have very little opportunity to learn a rare one. Buda and colleagues ask how much this uneven exposure hurts convolutional neural networks and which common remedies work. They create unequal class sizes in MNIST, CIFAR-10 and ImageNet, then evaluate the resulting classifiers on test sets with equal representation across classes. Their main measure is multiclass ROC AUC. It asks how well the scores for each class rank its own examples ahead of examples from other classes, then gives each class equal weight in the average.

The experiments distinguish how scarce the rarest class is from how widely that scarcity extends across the label set. In a step distribution, some classes have many examples and the rest share a much smaller count. In a linear distribution, class sizes decrease gradually. Classification generally deteriorated as the imbalance grew, with a stronger effect on CIFAR-10 than on MNIST. The distribution of examples mattered even at the same total training size. At a shared imbalance ratio, the linear distribution and the step distribution with half the classes in the smaller group supplied the same number of examples, yet the step distribution caused a larger loss in discrimination.

Random oversampling, which repeats existing images from underrepresented classes, usually produced the highest ROC AUC. Fully closing the class-size gap worked best in the MNIST experiment that varied how much to oversample. Random undersampling discards examples from common classes and frequently performed poorly, although it could approach oversampling when a large share of classes was severely underrepresented. Intermediate amounts of undersampling worked better in some conditions. The authors found no widening training–test accuracy gap attributable to oversampling in the runs they examined. On ImageNet, oversampling consistently beat undersampling, while its small shortfall against ordinary training at extreme imbalance was difficult to interpret given the variability between runs.

Accuracy asks a different question. It counts how many final labels are correct after the network must choose a class. Dividing each class score by its estimated prior frequency can change that choice, and the paper found that such threshold adjustment often improved accuracy, particularly after oversampling. This adjustment preserves the order of examples within each class’s score ranking. The study therefore distinguishes a training intervention that can improve discrimination from an inference intervention that can make better use of the scores for a particular decision.

## Deep dive: A systematic study of the class imbalance problem in convolutional neural networks

How class imbalance affects image classification with convolutional networks, when oversampling helps, and why score adjustment can improve accuracy. · about 35 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### What becomes scarce in an imbalanced training set

In supervised classification, the learner receives examples with known labels and uses them to assign labels to new cases. A training set is class-imbalanced when some labels occur much more frequently than others. The paper points to medical diagnosis, fraud detection and computer vision as settings where uneven frequencies arise. In the medical example it uses to illustrate the magnitude, cancer can be 1,000 times less frequent than the healthy category. A large collection can therefore provide very little evidence about a category that is important to recognize.

The authors approach this as a problem in [machine learning](https://md.research.elamur.ai/free/en/concepts/machine-learning/) with two practical consequences. One concerns learning. Common classes can contribute much more of the experience from which a classifier forms its decision rules. The other concerns measurement. A score that counts successes over all cases can place most of its weight on frequent classes. These consequences can occur together, but the training distribution and the evaluation rule are distinct parts of the experiment. A test can be designed to make weaknesses on rare classes visible even when the learner received sparse evidence for those classes.

A convolutional neural network, or CNN, learns features and a classification rule within the same network. Convolutions apply learned filters across an image, activation functions transform their responses, and pooling can summarize local responses. Successive layers can build more involved representations from earlier features. The paper cites work on visualizing CNNs for this account of hierarchical features and uses well-known image classifiers to situate the architectural family. Class frequency can matter at the point where a network learns the image representation as well as at the point where it maps that representation to labels. [Visualizing and Understanding Convolutional Networks](https://md.research.elamur.ai/free/en/papers/zeiler-2013-visualizing-understanding-convolutional-networks/) · [ImageNet Classification with Deep Convolutional Neural Networks](https://md.research.elamur.ai/free/en/papers/krizhevsky-2012-imagenet-classification-deep-convolutional/) · [Very Deep Convolutional Networks for Large-Scale Image Recognition](https://md.research.elamur.ai/free/en/papers/simonyan-2014-very-deep-convolutional-networks-large/)

The multiclass setting also complicates the word *rare*. One label may be scarce among otherwise well-represented labels. A large group of labels may each have very little support, leaving a handful of classes to account for much of the training set. Or the available data may fall gradually from common to scarce across the label set. A ratio between the largest and smallest class describes the endpoints of all these arrangements. The authors wanted an experimental design in which the placement of the classes between those endpoints could vary too.

This distinction matters when judging a remedy. Removing images from common classes changes their share of training and also reduces the stock of distinct examples. Repeating rare examples increases their share while drawing on the same underlying stock. Adjusting the output scores leaves the learning procedure as it was and changes how a class is chosen at the end. A study that tests these interventions together can ask which part of the pipeline benefits from a change and which measure records the benefit.

#### What earlier work had tried

Earlier studies reviewed in the paper had already documented harmful effects of class imbalance in conventional classifiers, including multilayer perceptrons. The authors describe consequences for both convergence, the course of learning as the weights are updated, and generalization, how well the learned rule works on held-out examples. They also describe an extensive literature on remedies in classical classification. For deep learning, they found examples of methods being used and new methods being proposed, with comparatively little systematic evidence about their behavior across controlled degrees of imbalance.

The most direct family of remedies changes the training data. Random minority oversampling selects rare-class examples and copies them. More elaborate sampling can change which examples are chosen or create new examples. The paper discusses SMOTE, which creates synthetic points by interpolating between neighboring examples. It also describes an extension that emphasizes examples near class boundaries, a method that samples within clusters to address uneven coverage inside individual classes, and a boosting-based approach that identifies hard examples before generating data. For stochastic training of neural networks, it mentions class-aware sampling, which controls label composition within each minibatch. Dataset-wide balance and balance inside every update are separate choices. [SMOTE: Synthetic Minority Over-Sampling Technique](https://md.research.elamur.ai/free/en/papers/chawla-2002-smote-synthetic-minority-over-sampling/)

Random majority undersampling works by deletion. In its basic form, it picks a random subset from each larger class and discards the rest. Earlier work reviewed by the authors had found circumstances in which undersampling was preferable. Its cost is the loss of examples that could help distinguish categories. The paper also describes more selective removal, including one-sided selection, and discusses data decontamination as a broader intervention that can involve relabeling. Those approaches pose a different question from random deletion because their outcome depends on how they identify examples to remove or revise.

Another family changes the classifier’s treatment of errors or the way it makes a prediction. Cost-sensitive training gives different consequences to errors from different classes. The paper surveys implementations that alter the outputs used in back-propagation, increase the contribution of costly examples to weight updates, or minimize a cost-sensitive objective. An inference-only option moves the decision thresholds after learning. The authors treat sampling and threshold adjustment as ways to express cost sensitivity and cite earlier arguments connecting some cost-sensitive training procedures to oversampling. Their comparison focuses on direct sampling and score adjustment.

Hybrid methods combine interventions. The review discusses ensembles trained from undersampled subsets and a method that combines boosting with SMOTE. It also describes earlier work on brain tumor segmentation that treated pixels as classification examples. That work trained a network on balanced data, then adapted its output layer using the natural skew. This two-phase approach gave Buda and colleagues a way to test whether balanced training and a later return to the imbalanced distribution could work together.

The review also covers one-class learning, framed for neural networks as novelty detection. An autoencoder can learn to reconstruct examples of a target kind, then use reconstruction error as evidence about unfamiliar inputs. The paper associates that approach with problems in which very severe imbalance turns the task into detecting anomalies. Its own experiments concern ordinary multiclass classification, where a network must distinguish among all the labels. The authors prioritize methods that can be implemented with a single network and that researchers were already using or considering for such tasks.

### The method, step by step

#### Constructing different kinds of scarcity

The study starts from labeled image collections with separate training and test splits. From the available training images, the authors construct subsets with prescribed class counts. They then train on those subsets directly or apply one of the balancing procedures. The original test split remains the common destination for the comparison. This makes the experimental question concrete. When different runs change the selection or frequency of training images, their scores are measured on the same held-out cases within that comparison.

How the study compares remedies for class imbalance The steps in order.

In step imbalance, all classes in the larger group have one common count, and all classes in the smaller group have another. Sorting the classes by size would give two flat groups with a drop between them. The authors use the following quantity to say how much of the label set is on the smaller side.

```
μ = |{i ∈ {1, …, N} : Cᵢ is a minority class}| / N
```

Here μ is the fraction of classes in the smaller group. There are N classes in all, with i serving as the index for a particular class. Cᵢ is the set of training examples for class i, so the condition inside the braces refers to whether that class belongs to the minority group. The symbol ∈ means membership in the set of indices, with 1 and N marking the endpoints and the ellipsis standing for the intervening indices. The colon introduces the condition an index must meet. The bars count the indices that satisfy it, and division by N expresses that count as a share of all classes.

The second quantity measures the distance between the largest and smallest class sizes.

```
ρ = maxᵢ |Cᵢ| / minᵢ |Cᵢ|
```

Here ρ is the imbalance ratio. The bars count the examples in Cᵢ, the training set for class i. The maximum and minimum range over the class indices. Their quotient compares the number of training examples in the largest class with the number in the smallest class. In a step distribution, every class in either group has the corresponding extreme count.

The paper illustrates step imbalance with 10 classes. It gives 500 training examples to 5 classes and 5,000 to the other 5, yielding the reported ρ of 10 and μ of 0.5. It also shows a distribution with the same total training count, a ρ of 2 and a μ of 0.9. These are different kinds of scarcity at the same dataset size. In the first distribution, the gap in class sizes is larger. In the second, the group with fewer examples contains more of the labels. Treating μ and ρ separately makes it possible to study both circumstances.

In linear imbalance, the authors set the largest and smallest class counts with the same definition of ρ. The counts of the remaining classes are placed along a linear progression between those endpoints, so that neighboring classes in size order differ by a constant amount. The paper illustrates this arrangement at a ρ of 10. The parameter μ belongs to the step design because the linear design has a progression of class sizes in place of a designated group sharing the minimum. A common value of ρ can thus describe datasets in which many labels have some intermediate amount of evidence or in which all minority labels share the sparsest allocation.

#### Changing the examples that reach the network

For the do-nothing baseline, the authors train on the imbalanced subset as drawn. This is the reference for judging whether an intervention helps when the available labeled images are already unevenly distributed. A separate comparison with the original training data describes the cost of the artificial imbalance and of the images removed to construct it. Those references answer different questions. The untreated imbalanced run establishes the starting point for a remedy, and the original-data run gives context for how far that remedy can recover.

Random oversampling raises smaller classes to the size of the largest. Images selected at random within those classes are reused. The resulting training set contains more entries, while the distinct images available to train the network are the same as for the imbalanced baseline. The intervention increases the influence of rare labels by bringing their examples into training more often. It can help a network use the available evidence under a different exposure pattern. The content of the repeated examples still comes from the original subset.

With random undersampling, the authors retain fewer images from each class above the minimum until every class has the size of the smallest. This changes relative exposure by reducing the amount of common-class evidence. The balanced set can be much smaller than the input subset when the minimum class count is low. A condition with many underrepresented classes leaves fewer large classes to cut down. The identity and diversity of the discarded images depend on the random selection.

The default forms of both methods produce equal class counts. To test whether equality is necessary, the authors also run a series of partial corrections on MNIST. A partial oversample raises some class counts while leaving a residual disparity. A partial undersample removes some examples from larger classes while retaining more of them than full undersampling would. These variants let the authors compare full balance with intermediate points, starting from a specified original skew.

#### Changing the training sequence

The two-phase variants use an oversampled or undersampled set at the start. This phase trains the whole network on data with equal class counts. The next phase uses the original imbalanced subset and updates the output portion. In effect, the network first learns its features under balanced exposure, then adapts the part that turns those features into class scores. Its earlier layers retain what they learned in the first phase. When the paper refers to training from random initialization, the initialization is at the start of the run. The first phase of this particular treatment supplies the weights for its second phase.

The paper keeps the learning-rate policy and other hyper-parameters from the first phase, with the base learning rate multiplied by the following factor for phase two.

```
10⁻¹
```

The base of 10 and exponent −1 express the multiplier applied to the first phase’s base learning rate. The learning rate governs the size of the weight updates, so the multiplier makes the output adaptation use a smaller starting step.

What counts as an output layer depends on the architecture. CIFAR-10 uses All-CNN, which has no fully connected layers. For that network, the fine-tuning phase updates the final two convolutions, whose kernels have size 1. The underlying experimental question remains the same as for a network with a conventional final classifier layer. The comparison asks what happens when the score-producing layers are exposed to the old class proportions after the network has already learned from balanced data.

#### Changing the final decision

A network produces a score for each possible label. The paper’s thresholding procedure rescales these scores using class frequencies. It can be applied to a network trained on the original imbalanced subset, to a network trained after oversampling, or to a network trained after undersampling. In each case it is applied at test time. The calculations use the estimated priors from the imbalanced data before either sampling treatment is applied.

The rationale starts with a Bayesian interpretation of the network’s output.

```
yᵢ(x) = p(i | x) = p(i) · p(x | i) / p(x)
```

The symbol x denotes the input example, and i denotes a possible class. The output for that class is yᵢ(x). The paper interprets it as p(i | x), the posterior probability of class i given the example. The vertical bar means “given.” The prior probability p(i) describes the frequency of class i before the input is taken into account. The class-conditional term p(x | i) expresses how likely the input is under that class, and p(x) is the marginal probability or density of the input. The dot means multiplication. The denominator adjusts for the overall occurrence of the input across the classes.

The estimate of the prior is based on the number of distinct training examples that belong to each class in the original imbalanced subset.

```
p(i) = |i| / ∑ₖ |k|
```

The term p(i) is the estimated prior for class i. The bars in |i| denote the number of unique examples with that label. The index k ranges over all the classes, so |k| is the distinct-example count for class k. The summation sign adds those counts, and division by the sum gives the frequency of class i in the subset. A duplicate introduced by oversampling does not add to this estimate.

Dividing a class output by its estimated prior gives scores on which to base a class decision. Under the stated probability interpretation, the division removes the prior factor and leaves a class-conditional term divided by the same input-dependent quantity for every candidate label. For a given image, that common term has no effect on which rescaled score is largest. This explains the intended direction of the correction. Given comparable starting scores, a class with a smaller estimated prior receives a larger increase relative to a class with a larger prior.

The ranking used in the main metric behaves differently from the decision between labels. For a given class, the prior is constant across test images. Multiplying that class’s scores by the same positive factor preserves their order. But every label can receive a different factor, and the label with the largest score for an individual image can change. This property is central to interpreting the accuracy results. Thresholding can change the chosen answers while leaving the class-by-class ranking measure unchanged.

#### Keeping the learning budget comparable

The training runs use stochastic gradient descent with momentum. Each update uses a batch of examples to estimate how the weights should move, and momentum carries information from earlier updates into the current one. The comparisons for a given dataset use a fixed iteration budget. An iteration is a weight update based on a batch, while an epoch corresponds to going through the training set. Different sampling methods change the number of entries in that set, so runs can make the same number of updates while passing through their respective datasets a different number of times.

For MNIST, the paper specifies an inverse decay schedule for the learning rate.

```
ηₜ = η₀ · (1 + γ · t)⁻ᵅ
```

Here ηₜ is the learning rate at iteration t, and η₀ is the base learning rate. The paper sets η₀ to 0.01. The decay parameters are γ, set to 0.0001, and α, set to 0.75. The dot denotes multiplication. The expression in parentheses grows from 1 as the iteration counter advances, and raising it to the negative power −α makes the learning rate shrink. The momentum value for this training run is also written with the symbol μ in the paper. In the optimizer it denotes momentum, while in the imbalance design μ denotes the fraction of minority classes.

The architectures and schedules differ by dataset. On MNIST, the authors use a version of LeNet-5 and train for 10,000 iterations with batches of 64. The momentum setting is 0.9 and the weight decay is 0.0005. Weight decay regulates the weights during training. The initial weights come from a uniform distribution using Xavier variance, and the biases begin at zero. The authors use no data augmentation on MNIST. An image repeated by sampling is therefore presented without an augmentation procedure that would vary its appearance.

All-CNN on CIFAR-10 runs for 70,000 iterations with batches of 256, momentum of 0.9 and weight decay of 0.001. The rate is multiplied by 0.1 after 40,000, 50,000 and 60,000 iterations. Weights use Xavier initialization and the biases start at zero. The authors found that some runs trained poorly and that more skewed training sets could require a smaller starting rate for learning to proceed. They tried base rates of 0.05, 0.005, 0.0005 and 0.00005. Each training choice was repeated twice on the same dataset, and for each method and imbalanced subset the authors chose the run with the best test score over all eight runs.

The ImageNet experiments use ResNet-10, a residual network with batch normalization. Residual blocks learn transformations in the presence of a shortcut carrying the input onward, and batch normalization is used here to aid training. The architecture has four residual blocks and an output layer with 1,000 values passed to a softmax, which turns the outputs into a distribution over the labels. Its first residual block outputs features with depth 64, and each successive block increases that depth by a factor of two. Training uses 320,000 iterations, batches of 256, momentum of 0.9 and weight decay of 0.0001. The starting rate is 0.1 and declines linearly to 0 at the last iteration. Weights are initialized with the Kaiming procedure. The experiments across all datasets use Caffe. [Deep Residual Learning for Image Recognition](https://md.research.elamur.ai/free/en/papers/he-2015-deep-residual-learning-image-recognition/) · [Caffe](https://md.research.elamur.ai/free/en/papers/jia-2014-caffe-convolutional-architecture-fast-feature/)

### Experiments and results

#### What the experiments put under pressure

MNIST contains grayscale digit images of size 28 × 28, with labels from 0 to 9. In the original training split, the class counts run from 5421 for digit 5 to 6742 for digit 1. To construct the artificial conditions, the authors randomly sub-sampled classes with a ceiling of 5,000 examples per class. Training LeNet-5 on the original MNIST data with the stated settings gave a test error below 1%. This result gives context for the later imbalance experiments on a relatively simple recognition task.

The MNIST grid covers imbalance ratios of 10, 25, 50, 100, 250, 500, 1,000, 2,500 and 5,000 for both step and linear distributions. In the step distribution, the number of minority classes spans 1 to 9. Each parameter combination was repeated 50 times, with randomized assignments of minority labels across repetitions. The authors report creating 4,050 step-imbalanced training sets and 450 linear-imbalanced training sets. They count 22,500 trained networks, including the imbalanced baseline. Thresholding variants can reuse a trained network because they operate on its outputs.

CIFAR-10 contains 32 × 32 color images of objects. Its original data are balanced, with 5,000 training images and 1,000 test images in each class. The images are preprocessed with global contrast normalization and ZCA whitening. These procedures adjust image contrast and correlations in the input representation. The experiments use no augmentation. All-CNN trained on the original CIFAR-10 set had a test error of 9.75% under the reported procedure.

The CIFAR-10 grid tests ratios of 2, 10, 20 and 50 for both imbalance shapes. In the step conditions, minority fractions of 0.2, 0.5 and 0.8 correspond to two, five and eight minority classes, respectively. The authors assign the smallest numerical labels to the minority group, so the same labels recur whenever the group has the same size. A larger minority group includes the labels used in a smaller one. This yields an orderly progression within the experiment. The authors report training 640 networks on CIFAR-10 and also describe supplementary checks with reshuffled stratified splits, which preserve the class proportions in the splits.

ImageNet uses the ILSVRC-2012 subset. For the constructed conditions, the authors reduce the count in majority classes from 1,200 to 1,000. Classes already below 1,000 images are always assigned to the minority group. They resize images so that the shorter side is 256 pixels, preserving the aspect ratio. During training the network sees a randomly located 224 × 224 crop and images can be mirrored. At test time it receives a single centered crop. On the original ILSVRC-2012 dataset, that setup yielded a top-1 test error of 62.56% and a multiclass ROC AUC of 99.50. Top-1 error counts an example as an error when the label with the highest score is wrong. [ImageNet Large Scale Visual Recognition Challenge](https://md.research.elamur.ai/free/en/papers/russakovsky-2014-imagenet-large-scale-visual-recognition/)

The ImageNet comparison is limited to untreated imbalanced training, oversampling and undersampling. Its step settings are μ of 0.1 with ρ of 10, μ of 0.8 with ρ of 50, and μ of 0.9 with ρ of 100. The corresponding minority groups have 100, 800 and 900 classes. In the most extreme setting, the authors randomized minority assignment and image selection across three runs for each method to gauge variation. In total, they trained 15 ResNet-10 networks across five artificially imbalanced training subsets.

#### What the scores measure

To obtain a receiver operating characteristic curve, the authors first consider one label at a time. Images with that label count as positives, and images from the rest of the label set count as negatives. A threshold on that label’s score determines which images are called positive. Moving the threshold traces the relationship between the true positive rate, the share of positives recovered, and the false positive rate, the share of negatives incorrectly accepted. The area under this curve, ROC AUC, summarizes how well the scores distinguish positives from negatives across the thresholds.

The implementation in scikit-learn uses thresholds derived from the responses on the test set and calculates area using the trapezoid rule. The authors repeat the calculation for each class and take the mean of the resulting areas. Every class makes the same contribution to that final mean. A large class cannot dominate the average by contributing more correct final labels. The score reflects ordering across thresholds, so it is possible to obtain a high area while making substantial errors under the rule that selects a single label.

Overall accuracy is the share of test cases assigned the correct label. The paper motivates the distinction with a test set on which the majority class accounts for 99% of the cases. A system that always predicts that class attains an accuracy of 99% in that example. That score follows from prevalence and leaves performance on the rare class invisible. In the actual experiments, balanced test sets avoid that particular dominance, while accuracy remains sensitive to how the classifier weighs competing class outputs. The same held-out images also make comparisons across the artificially imbalanced training subsets easier to interpret. [Evaluation & benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/)

#### How discrimination changed with the training distribution

In the step experiments on MNIST and CIFAR-10, untreated training deteriorated as the count disparity widened and as more labels belonged to the smaller group. The comparison looks at the same experiment from both directions. At a fixed number of minority classes, increasing the ratio makes those classes sparser relative to the majority. At a fixed ratio, putting more classes in the minority group changes how much of the label set experiences that scarcity. Both dimensions had consequences for multiclass ROC AUC.

CIFAR-10 was more sensitive to the imposed skew. The authors describe comparable drops on the two benchmarks as occurring at roughly 100 times stronger imbalance on MNIST. Their interpretation is that the more complex image task is more vulnerable to losing training examples unevenly. The observed comparison is between the complete dataset-and-network setups. CIFAR-10 also uses a different architecture and training procedure and contains more varied visual content, so the experiment ties the difference to the tested task configurations.

Oversampling typically ranked first on MNIST and CIFAR-10 by multiclass ROC AUC. It frequently increased the score over the untreated baseline, and the authors report no substantial decreases for the step conditions on those datasets. Undersampling was more variable relative to ordinary training. It frequently reduced the score, while helping in some conditions with a large minority group. The gap between the two sampling procedures was largest when few classes were in the minority and narrowed as more classes entered that group.

The two-phase procedures generally produced results between the untreated baseline and the corresponding stand-alone sampling method. Fine-tuning after undersampling could recover some performance when undersampling had harmed the classifier. In those cases the untreated run was still at least as good a reference. Fine-tuning after oversampling tended to give up some of the discrimination gained by balanced training. An output stage adapted to the original class distribution did not preserve the full benefit seen in the one-phase oversampling comparison.

The linear distributions show how much the intermediate class counts can matter. At the most extreme MNIST linear ratio, 5,000, the smallest class contains one training image. Even at that endpoint the authors describe the aggregate drop for untreated training as modest. That statement concerns the mean of class AUCs. The performance for the rarest individual digit is a different quantity. Oversampling improved the aggregate score at every tested linear ratio on both datasets, while the results for undersampling declined approximately linearly with the imbalance ratio. With full undersampling, the minimum class size determines how many images remain in every class, even where the original linear progression supplied substantially more images to the intermediate labels.

#### ImageNet and the extreme case

On ImageNet, the authors report a decline from 99 to 90 in multiclass ROC AUC at the largest tested imbalance. The chart shows the levels used to describe that decline. The original-data reference with a centered crop is separately reported with greater precision, and the discussion of the decline uses the figures shown here.

ImageNet multiclass ROC AUC at the reference level and largest tested imbalance The largest training imbalance was associated with a marked loss of discrimination.

**The numbers**

| System or setting | multiclass ROC AUC |
| --- | --- |
| Reported higher reference level (this paper) | 99 |
| Largest tested training imbalance | 90 |

Across the ImageNet conditions, oversampling performed more favorably than undersampling. At extreme imbalance, it did slightly worse than the untreated baseline. The authors caution that the separation is small compared with the observed variation. They report differences higher than 4 in multiclass ROC AUC across repeated undersampling runs and note that gaps of 1 - 2 could arise from variation between runs. The small baseline advantage under extreme skew provides limited evidence for a general preference between untreated training and oversampling in that regime.

ImageNet also illustrates why the paper keeps discrimination and final decisions separate. The AUC obtained on the original training data is high, while the reported top-1 error is substantial. The AUC asks whether a class receives higher scores on its own images than on images grouped together from all the other classes. The top-1 decision asks whether the true label beats every competing label on that image. A class can rank its positives well in aggregate and still lose the competition on many individual images. Those scores describe different aspects of the same classifier’s behavior.

#### When thresholding helped accuracy

The accuracy plots cover step imbalance on MNIST and CIFAR-10. Applying the prior adjustment generally improved the proportion of correct labels, with a particularly favorable pattern when combined with oversampling. The authors also identify thresholding the untreated network as a preferable combination and advise against pairing the adjustment with undersampling on the basis of their results. The reported conclusion concerns the incidence of correct final predictions on the balanced test sets.

This result has a different interpretation from oversampling’s increase in ROC AUC. Oversampling changes what the network learns and can change which images rank higher for any given label. Thresholding rescales the scores of an already trained network. For each label, the ranking of test examples is preserved. Between labels on a single image, the relative sizes of the scores can shift. The accuracy gain is evidence that the rescaled scores can produce a better decision rule under the evaluated class distribution.

### What the ablations show

#### Training-set size and training-set composition

Creating artificial imbalance by removal changes two things at once. It produces unequal class counts and reduces the number of distinct images available to learn from. If a network trained on that subset performs worse than a network trained on the original dataset, both changes are plausible contributors. The authors use several comparisons to test whether total training size accounts for the whole effect.

The first comparison uses the untreated imbalanced baseline and oversampling. Both start with the same collection of distinct images, and the oversampling condition sees some images more often. The frequent gains in AUC establish that a change in exposure can be beneficial even without new visual evidence. The gap that remains relative to training on the original collection is consistent with a cost from the images removed during construction. Repetition can change how the network uses the remaining information, while the original training data can contain visual variation absent from the subset.

The undersampling comparison points in the same direction from the other side. Undersampling removes additional examples from a subset that was already smaller than the original. There were cases, particularly with many minority classes, where the resulting classifier improved over the baseline. A reduction in distinct images can therefore coincide with a better ranking score when it also changes the share of learning devoted to each class. In some of those conditions, undersampling could also match oversampling closely. Once the available data are already concentrated in a few labels, the number of common-class images retained and the opportunity they receive during training are both relevant.

The most direct comparison matches the total size of two different distributions. At a shared ρ, a linear subset and a step subset with μ of 0.5 contain the same total number of training examples in the paper’s design. The step distribution produces a much larger drop. Several of its classes cluster at the minimum, whereas the linear distribution places the intermediate classes between the extremes. With the overall count and the ratio held constant, the difference in results shows that these two descriptors alone leave out an important property of the training set. The location of the individual classes along the size distribution affects how well the network learns.

The three comparisons have different controls. Oversampling preserves the distinct-image pool, undersampling changes both balance and the pool, and the matched-size comparison preserves the count while redistributing it across classes. Taken together, they support the authors’ interpretation that the class distribution makes a contribution beyond the total number of examples. They also explain why a ratio can be informative about the endpoints while giving an incomplete prediction of the loss in discrimination.

#### Where to stop resampling

Full balance is an endpoint of the sampling procedures. The authors test whether stopping before that endpoint retains useful exposure without paying all of the associated costs. For MNIST they start from a ratio of 1,000 and apply progressively stronger oversampling and undersampling. This comparison changes the amount of correction within each method, so differences between partial and full treatment can be attributed to how far the given procedure is taken under those conditions.

For oversampling, reducing the disparity improved the score across the minority-group sizes in this comparison. Equal class counts produced the best results. With more complete oversampling, rare images take up more of the training sequence, while the set of unique images stays fixed. Within this experiment, the benefit of that altered exposure persisted all the way to full balance. This is the empirical basis for the recommendation to match class counts when using basic random oversampling.

For undersampling, stronger correction also removes more unique images. The result was an interior optimum in some conditions with a moderate number of minority classes. Partial undersampling could perform better than both the untreated baseline and full undersampling. The authors found a level of undersampling that could approximately match each oversampling treatment in the comparison, but the appropriate setting varied. Their conclusion is that greater reductions in the ratio tend to be appropriate as minority classes account for a larger share of the labels.

The change in the number of minority classes helps account for the convergence of the sampling methods. At a fixed ratio in the step comparisons, full undersampling uses a dataset of the same size whichever classes were originally in the larger group. The small-class count fixes the final count for every label. In contrast, the oversampled training set retains the underlying distinctions in how many unique images each class contributed. As a larger fraction of classes starts at the small count, there are fewer classes for which oversampling preserves a much larger pool of examples. The methods then become closer in the evidence they can offer.

The reported time argument for undersampling applies to its smaller training set. In the main experiments, the authors held the number of weight updates fixed within a dataset, so fewer retained images did not automatically imply a shorter scheduled run. A smaller set changes the cost of going through the data and can make undersampling attractive where a training budget is based on passes through the set. The measured comparison itself establishes performance under the chosen update schedule.

#### What the second phase contributes

The comparison between ordinary sampling and two-phase training isolates the practical effect of adding output adaptation after balanced training. Its direction depends on what the first phase accomplished. After an undersampled start that scored below the untreated baseline, the return to imbalanced data could raise the AUC. That rise was a recovery relative to the undersampled network. The untreated network remained the stronger point of comparison. After an oversampled start that already yielded good discrimination, the additional phase typically moved the score downward.

These comparisons indicate that the ordering of balanced and imbalanced training matters. Output adaptation changes the part of the network that maps learned features to decisions. It can also change the rankings of examples within a class, since it updates weights using the second training set. The experiment establishes how the entire second-phase procedure behaved with the chosen layers and learning schedule. The results leave the contributions of the classifier weights, the smaller base rate and the exposure to the imbalanced subset intertwined within that procedure.

Holding a trained network fixed and applying prior scaling provides a different comparison. For that intervention the ranking property follows directly from the constant multiplier for each class. An accuracy change can therefore be attributed to a change in the selected labels, with the score rankings intact. The finding that post-training adjustment was frequently helpful alongside oversampling shows how the classification rule can benefit after the network has already learned useful discrimination from balanced exposure.

#### Whether repetition produced visible overfitting

The authors examine learning curves because an end-of-run score gives limited information about how the network got there. They compare training and test accuracy over iterations for the untreated baseline and the two sampling methods. Their main illustration uses step-imbalanced CIFAR-10 with 5 minority classes and a ratio of 50. The sampling runs showed more stable training and better generalization in that comparison. For oversampling, the gap between training and test accuracy did not grow as the iterations progressed.

That comparison addresses a concern from earlier work on classical classifiers. Repeated presentations of a small set can allow a classifier to fit those examples closely while providing little improvement on new cases. A widening train–test gap would have been one sign of that behavior. On the curves the authors examined, oversampling did not show that pattern. They report checks on additional imbalance conditions involving MNIST, CIFAR-10 and ImageNet, with the same observation.

The result qualifies what can be inferred from the presence of duplicate images. Reuse increases exposure to the specific rare examples, and it can improve held-out performance under the training budgets tested. The diagnostic is based on the reported aggregate accuracy curves. It establishes that the expected deterioration was absent in those comparisons. The behavior of a specific rare class, or of repetitions carried much further under a different schedule, would require evidence at that finer level.

### Limitations

#### Limits identified by the authors

The authors single out the extreme ImageNet conditions for caution. The largest skew leaves a training subset about 10% the size of the original ILSVRC-2012 data. That is a large change in both the amount and the distribution of evidence. Settings chosen for the original task may work differently after sub-sampling, and the authors name hyper-parameter choice as a possible confound. The high run-to-run variation makes a small advantage for ordinary training over oversampling hard to attribute to the sampling method. The authors call for a more extensive study of extreme imbalance on a task of this complexity.

The ImageNet experiments were deliberately narrow because of computational cost. The authors chose a relatively small residual architecture and tested a limited collection of step distributions and remedies. This comparison gives direct evidence for oversampling and undersampling on the larger benchmark. Evidence for the two-phase variants, thresholding combinations and linear imbalance comes from MNIST and CIFAR-10. The breadth of the smaller experiments and the scale of the ImageNet experiments each support a different part of the conclusion.

The authors also motivate their scope by the practical cost of ensembles and the special role of novelty detection. Their empirical comparison is of readily implemented single-network remedies for multiclass classification. More elaborate sampling, explicit cost-sensitive objectives and ensembles appear in the discussion of earlier approaches. The paper’s argument about the connection between oversampling and particular cost-sensitive formulations supplies a reason for the experimental selection. Comparative performance for other implementations remains open.

Finally, the authors deliberately keep the test sets balanced. The comparison benefits from a common set of cases and a large evaluation sample for each label. The accuracy measurements consequently describe decisions on that evaluation population. The paper’s concern about accuracy on skewed populations still applies when one changes the prevalence of the test cases. The operating rule and the evaluation population both matter when the objective is to maximize the number of correct predictions.

#### Limits visible in the design

The study creates rarity by drawing subsets of existing labeled benchmarks. This gives control over the count of each class and holds the underlying source of the images constant within an experiment. Naturally occurring rarity can also coincide with changes in which kinds of images are collected for a label or which variations within that label are represented. The paper reviews earlier work on imbalance inside classes, but the main experiments manipulate counts across classes. Their evidence addresses the scarcity induced by sub-sampling and the frequency changes induced by the tested remedies.

The relationship between task complexity and the effect of imbalance is observational across benchmark configurations. MNIST uses LeNet-5, CIFAR-10 uses All-CNN and ImageNet uses ResNet-10. Their preprocessing, initialization, training budget and rate policies also differ. The larger performance loss on CIFAR-10 is a measured feature of the comparison. Isolating visual complexity as its cause would call for a design that varies complexity independently of the rest of the setup.

Class identity is another part of the comparison. In MNIST the random assignment of minority classes across repeats helps average over any given digit’s difficulty. In the principal CIFAR-10 setup, the lowest-index classes always comprise the minority group. Increasing its size both widens the reach of underrepresentation and adds specific labels to the group. The checks with reshuffled stratified splits probe dependence on the selected images. Generalization across alternative choices of rare labels is a separate comparison. On ImageNet, naturally smaller classes are always included in the minority group, so the construction likewise incorporates class identity as well as count.

The CIFAR-10 results also use the test split to choose the best run among the attempted starting rates and repetitions. Thus the reported test score serves both as a selection criterion and as the number used in the comparison. It describes the best observed run under that procedure. Its level can be more favorable than performance assessed on a fresh split reserved solely for evaluation, and it provides less information about how reliably training succeeds from a random start. This detail is particularly relevant because the authors observed sensitivity to initialization and the starting rate.

An equal update budget is a sensible way to control how frequently the optimizer acts. It still permits different amounts of exposure to individual images, especially when full undersampling leaves a very small set or oversampling makes copies common. These differences are part of what the interventions do. Results under an equal number of epochs would describe a different training budget, and results under independent tuning for each sampled dataset could differ. The checks support claims about the tested procedures rather than invariance across all ways of scheduling optimization.

The mean ROC AUC resolves one concern about the frequency of labels in evaluation by giving each class equal weight. It still compresses performance across labels and across operating points. A single weak rare class can have limited influence on the mean, and performance in a region where false positives must be especially uncommon can be obscured by averaging across thresholds. Likewise, a stable aggregate train–test gap describes generalization as measured by the examined curves. It leaves open whether particular rare labels overfit even while the aggregate curves look stable. The statement about oversampling and overfitting is best anchored to the networks, datasets and training runs that the authors examined.

### What came after

The later citing papers approach unequal representation at several places in a pipeline. The titles specify the problems and, in several cases, the interventions. They support connections to Buda and colleagues’ comparisons at the level of what is changed, such as the loss, data exposure, corpus composition or final decision. The empirical outcomes of those later approaches are separate questions.

#### Class frequency as a property of the training objective

*Class-Balanced Loss Based on Effective Number of Samples* takes up the problem at the level of the loss. A loss determines how training penalizes the predictions it makes, so a class-balanced loss is a way to change how classes contribute to learning. The title’s emphasis on an effective sample count gives that intervention a different starting point from simple replication to equal raw counts. It connects directly to the earlier study’s division between remedies that change which examples appear and remedies that change what their errors contribute. [Class-Balanced Loss Based on Effective Number of Samples](https://md.research.elamur.ai/free/en/papers/cui-2019-class-balanced-loss-based-effective/)

*AraDIC* places class-balanced loss in Arabic document classification and uses image-based character embeddings. It brings together a choice about how the input is represented and a choice about how the training objective handles classes. The link to Buda and colleagues is the allocation of learning across labels, in this case for [text classification](https://md.research.elamur.ai/free/en/concepts/text-classification/) with image-based input features. The relevant comparison is between changing the training exposure of labels and giving their errors a different role in the objective. [AraDIC](https://md.research.elamur.ai/free/en/papers/daif-2020-aradic-arabic-document-classification-image/)

#### Balance in the construction of data

*Augmentation for small object detection* moves the data intervention to a detection problem focused on small objects. The object of the intervention is size within the visual task. Buda and colleagues studied class counts in whole-image classification and used random duplication as their simplest way to increase rare-class exposure. The later paper’s focus on augmentation and small objects extends the data question to a different source of scarce training evidence. A detector may need more exposure to objects with a particular visual property, even when that property is distinct from the category label. [Augmentation for Small Object Detection](https://md.research.elamur.ai/free/en/papers/kisantal-2019-augmentation-small-object-detection/)

*Mind the GAP* constructs a balanced corpus around gendered ambiguous pronouns. The point of contact is the use of controlled composition to make results interpretable. Buda and colleagues varied training frequencies and used a fixed balanced test set to help compare discrimination. In work on [coreference resolution](https://md.research.elamur.ai/free/en/concepts/coreference-resolution/), where the task concerns which expressions refer to the same entity, a corpus designed around balanced representation makes its composition part of the question being studied. The corpus design is the intervention named by the later work. Mind the GAP

#### Decisions after scores have been learned

The SemEval-2026 Task 13 work on multi-language AI code detection names stratified balancing, dynamic threshold optimization and logit bias correction. It therefore brings together ideas at different stages of the classifier. Balancing concerns the representation of groups in the data pipeline. Threshold optimization and correction of the logits, the scores before they are converted to probabilities, concern how the learned outputs are used to make decisions. This combination recalls the distinction in Buda and colleagues between training with adjusted class frequencies and correcting the scores of a trained classifier. The later title identifies a different task and a more varied set of decision adjustments than division by a fixed class prior. [SemEval-2026 Task 13 code detection](https://md.research.elamur.ai/free/en/papers/s-2026-semeval-2026-task-13-fine/)

Across these works, balance can refer to the labels emphasized by a training objective, the visual examples supplied by augmentation, the composition of a corpus or the decision rules applied to output scores. Buda and colleagues’ experiments give those choices a shared frame of reference. Changing exposure can alter what the classifier learns to distinguish. Changing the use of its outputs can alter which distinctions are reflected in final predictions. The contribution of each intervention is visible only through the data and measure used to evaluate that stage.

## Cite

Cite as Mateusz Buda, Atsuto Maki and Maciej A. Mazurowski. 2018. A systematic study of the class imbalance problem in convolutional neural networks. Neural Networks.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1016/j.neunet.2018.07.011](https://doi.org/10.1016/j.neunet.2018.07.011) · [arXiv 1710.05381](https://arxiv.org/abs/1710.05381)

```bibtex
@inproceedings{buda2018systematic,
  title = {{A systematic study of the class imbalance problem in convolutional neural networks}},
  author = {Mateusz Buda, Atsuto Maki and Maciej A. Mazurowski},
  booktitle = {Neural Networks},
  year = {2018},
  doi = {10.1016/j.neunet.2018.07.011},
  eprint = {1710.05381},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1016/j.neunet.2018.07.011}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
