Handling Class Imbalance: Downsampling, SMOTE, and Class Weighting

GCP Study Hub
September 11, 2026

Class imbalance occurs when one class appears far more often than other classes in a dataset, commonly at ratios such as 90% to 10% or even 99% normal cases to 1% failure cases. Because real-world data is rarely evenly distributed, this skew creates direct challenges for both model training and evaluation. On the Professional Machine Learning Engineer exam, scenarios involving rare events test whether you recognize why accuracy becomes unreliable, how imbalance disrupts convergence, which mitigation strategy fits a given dataset, and why switching model architectures does not solve the problem.

Why accuracy fails on imbalanced datasets

When thousands of majority class examples dominate the feature space and only a small number of minority class examples are scattered throughout, a model has a difficult time learning to predict the rare class. In this setting, overall accuracy becomes a misleading metric. On a dataset where 99% of examples belong to class 0 and 1% belong to class 1, a model that predicts class 0 for every input achieves 99% accuracy while completely failing to detect the minority class. High accuracy can therefore mask a model that is useless for its intended purpose.

In practice, the minority class is often the main reason to build a machine learning system in the first place:

  • Credit card fraud detection: fraudulent transactions may account for less than 1% of all transactions, and missing them leads to financial losses and compromised customer accounts.
  • Lung cancer detection: cancerous cases are rare in screening populations, and failing to identify them carries serious, potentially life-or-death consequences.
  • Equipment failure prediction: machines, planes, and cars operate normally most of the time, while rare failure events must be predicted to prevent costly downtime or safety incidents.
  • Severe weather forecasting: events such as blizzards are infrequent, and missing a major storm creates serious consequences for public safety and economic planning.

Because overall accuracy hides poor minority class performance, models trained on imbalanced data require evaluation metrics that measure how well the rare class is detected. Metrics such as precision, recall, and F1 score for the minority class focus directly on those predictions, while area under the ROC curve accounts for performance across different decision thresholds.

How class imbalance affects model convergence

Balanced datasets improve convergence, which refers to how quickly and smoothly a model's training loss decreases and stabilizes during training. When a dataset is balanced, each training batch contains enough examples from all classes for the model to learn consistent patterns and make steady progress toward a low final loss.

With imbalanced data, training batches are dominated by the majority class. That skew produces inconsistent gradient updates, leading to erratic and unstable training behavior that plateaus at a higher final loss and can remain volatile late in training. Recognizing that balanced datasets support steadier convergence is an important training consideration for the Professional Machine Learning Engineer exam.

Downsampling the majority class

Downsampling addresses class imbalance by randomly removing examples from the majority class until the dataset has roughly equal numbers of majority and minority class records. While this approach restores balance, it carries a clear tradeoff because it permanently discards data from the training set.

Removed majority class examples may contain useful patterns or edge cases that would help the model generalize better, leaving the training set smaller and potentially less representative of the true data distribution. Downsampling works well when majority class data is abundant and losing some examples is acceptable, but it is a poor fit if the discarded records carry information needed for a robust model.

Oversampling the minority class with SMOTE

Oversampling balances a dataset without discarding majority class data by duplicating or synthesizing minority class examples. Keeping every original majority class record preserves all of its patterns and edge cases while giving the model roughly equal representation of the rare class.

The most common oversampling method is SMOTE, which stands for Synthetic Minority Oversampling Technique. Rather than simply duplicating existing rare records, SMOTE locates minority class examples that are close to each other in the feature space and generates new synthetic minority examples. Because these synthetic samples give the model more varied and realistic representations of the rare class, SMOTE is typically preferred over simple duplication. Oversampling works well when overall data is limited and discarding examples is not viable, with the tradeoff that it produces a larger final dataset.

Class weighting through up-weighting and down-weighting

Class weighting leaves the dataset unchanged and instead adjusts how heavily the training algorithm penalizes mistakes on each class. Because no examples are removed or artificially generated, the original data distribution remains intact while training focus shifts toward learning minority class patterns rather than optimizing only for the abundant majority class.

Class weighting can be applied in two ways:

  • Up-weighting increases the loss penalty for the minority class. Keeping the majority class at a standard weight of 1 while up-weighting the minority class to 4 gives every minority class mistake four times the penalty of a majority class mistake.
  • Down-weighting decreases the loss penalty for the majority class. Lowering the majority class weight to 0.5 while keeping the minority class at 1 makes majority class mistakes less costly relative to minority class mistakes.

Both mechanisms achieve the same objective through different adjustments to the loss function, directing the model to learn how to identify the rare class effectively.

Why changing model architecture does not fix class imbalance

Class imbalance is a data problem rather than a model problem. Switching from a linear model or a simple neural network to a more complex deep learning architecture, or changing model families entirely, does not correct an underlying 99% to 1% class skew. Both simple and complex architectures face the exact same training challenge when the input distribution remains imbalanced.

On the Professional Machine Learning Engineer exam, an option that proposes adopting a more complex model architecture to resolve class imbalance is not appropriate. We would address the data imbalance first using downsampling, oversampling with synthetic data generation, or class weighting, and only then choose the model architecture best suited to learn from the properly balanced or weighted training data.

Our Professional Machine Learning Engineer course covers class imbalance alongside evaluation metrics and feature engineering, with practice questions that drill these distinctions.

Get tips and updates from GCP Study Hub

arrow