← AI glossary

AI glossary · Basic · Classic ML, recsys & search

Class imbalance

Class imbalance is a situation in a classification problem where some answer categories (classes) have a great deal of data and others have very little. A model trained on such data tends to get the common class right and miss the rare but important one.

About this term
Level
Basic · Technical terms you often meet in AI news
Added
2026-10-09
In plain words It is like a weather forecaster in a town where 99 days out of 100 have no rain, who says 'no rain' every single day. The share of correct forecasts is high, but the forecaster never once warns you on the days you actually need an umbrella.

How it works

A classification model learns by reducing its total number of wrong answers. If only 1 in 100 data points is a 'fraudulent transaction', answering 'normal' for every transaction produces just one wrong answer, so the model has no reason to learn how to recognize fraud. The result is a model with high apparent accuracy that rarely finds the minority class. Problems about finding 'rare events', such as fraud detection, rare disease diagnosis and defect detection, mostly look like this.

Only 1 in 100 is fraud

1 / 100

해당 1나머지 99

Example: each cell is one transaction. The single shaded cell is a fraudulent transaction; even if every answer is 'normal', only one answer is wrong.

Why it matters

In practice, what we want to find is usually the rare case. Missing one fraud case can cost far more than wrongly flagging one normal transaction. If you look only at accuracy without knowing about class imbalance, you can mistake a useless model for a good one. This problem needs attention from the moment you choose evaluation metrics.

Things to know

Common remedies are to add more minority-class data (oversampling, data augmentation) or to reduce majority-class data (undersampling). Another common method is to weight the loss function so that mistakes on the minority class are penalized more heavily. For evaluation, look at recall (how many of the actual minority cases were found) and precision (how many of the cases flagged were correct) together instead of accuracy. When splitting data, the training and evaluation sets should also contain the minority class in similar proportions.

Example

A card company's fraud detection system deals with a textbook class imbalance problem. Because normal transactions vastly outnumber fraudulent ones, the model is trained with more weight on fraudulent transactions, and 'how few frauds were missed' is used as the key metric. Some systems also use anomaly detection techniques and approach the problem by finding 'transactions that differ from usual'.

Related terms