A fraud detection model achieves high accuracy during evaluation. The team examines its predictions and discovers that the model misses most fraudulent transactions while correctly classifying many legitimate ones.
Class imbalance is a condition in a classification dataset in which a particular label occurs much less frequently than other labels, making aggregate measures such as accuracy potentially misleading when a model needs to recognize rare cases such as fraudulent transactions, manufacturing defects or customer churn.
Why does class imbalance make accuracy misleading?
Accuracy measures the share of predictions that a model classifies correctly. When most records belong to the majority class, a model can achieve high accuracy while failing to recognize the rare cases that the team wants to identify. In CUBIG’s October 2026 UCI Wilt experiment, only 15 of 868 evaluation segments were diseased.
CUBIG’s October 2026 UCI Wilt write-up describes an example. The original UCI Wilt training file contains 4,339 rows, of which only 74 represent diseased-tree segments.
A team assessing predictions on such data needs to examine precision and recall alongside accuracy. Recall measures how many actual positive cases the model identifies, while precision measures how many of its positive predictions correspond to actual positive cases.
How do teams handle class imbalance?
Google’s Machine Learning Crash Course notes that accuracy is usually a poor metric for a model trained on a class-imbalanced dataset. A team can still train a baseline on the original data first and examine its results before deciding whether the imbalance needs more treatment.
Google also describes downsampling the majority class and increasing the weights of the retained examples by the downsampling factor. The course recommends treating that factor as a hyperparameter that teams can examine during model development.
Machine learning teams can consider several approaches according to their task:
- Class weights: Change how strongly errors from different classes contribute to model training.
- Threshold tuning: Adjust the decision threshold to examine the trade-off between missed cases and false alarms.
- Resampling: Change the representation of classes using methods such as oversampling or SMOTE.
- Additional examples: Add relevant real or synthetic examples of rare cases to the training data.
How do you check that a fix for class imbalance worked?
Teams should compare the baseline model and the modified model on original held-out records. The comparison should examine whether the model identifies more rare cases and whether additional positive predictions introduce unacceptable false alarms.
Teams examining the effect of additional synthetic examples should keep model settings and evaluation conditions fixed. CUBIG’s guide to checking generated data before training describes how engineers can isolate changes to training data.
The team should select an approach based on the model’s intended decisions rather than the appearance of a balanced training dataset. CUBIG’s article on class imbalance in machine learning examines these choices in more detail.