Machine Learning

Class Balance

Class balance describes how evenly the categories a model predicts are represented in the training data; class imbalance, where one outcome is rare, distorts both training and accuracy.

What is class balance?

Class balance is the proportion of training records that belong to each class a model is asked to predict. A dataset where half the records are “fraud” and half are “legitimate” is balanced. A dataset where one record in a thousand is fraud is imbalanced, and most real business problems look like the second case. Equipment failures, fraudulent claims, customers who churn, and disputed invoices are all rare compared with their normal counterparts.

Why class balance matters

Imbalance distorts two things. During training, a model that minimizes overall error can achieve a very low error rate by predicting the majority class every time, and many algorithms will do exactly that. During evaluation, accuracy becomes meaningless for the same reason: a fraud model that flags nothing is almost always right. Precision, recall, and the F1 score describe performance on the rare class, which is the class the business cares about.

An insurer building a model to flag claims for investigation has a few hundred confirmed fraudulent claims among hundreds of thousands. The usual remedies are to weight the rare class more heavily in the loss function, to undersample the majority class, to oversample or synthesize minority records, or to choose a confidence threshold that trades precision for recall. Each remedy changes the confidence scores the model produces, so calibration must be checked afterward. The prevalence of the rare class in production should be measured separately, because a training set enriched with rare cases no longer reflects it.

← Back to AI Glossary