# Class Imbalance

*noun*

say it: **“KLAS im-BAL-unss”** **/ˈklæs ɪmˈbæləns/**

A situation in which one category appears far more often than another in a set of data.

## What is **class imbalance**?

**Class imbalance** is when one class is much rarer than another, such as 1 fraud in every 100 payments. A model can
then score 99% accuracy by never flagging anything, so you judge it by precision, recall, F1 or balanced accuracy
instead, and split with `stratify`.

```python
import pandas as pd
payments = pd.Series(["ok"] * 99 + ["fraud"])
print(payments.value_counts(normalize=True).to_dict())   # {'ok': 0.99, 'fraud': 0.01}
```

## In a sentence

- “With 1 fraud per 100 payments, **class imbalance** made accuracy almost useless.”
- “The shelter's data had a **class imbalance**: few rabbits, many dogs.”

Level: Journeyman · [More AI Basics terms at this level](https://www.ask-codey.com/glossary?category=ai&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/class-imbalance
