class imbalance
/ KLASS im-BAL-uns /
Class imbalance is when the categories you want a model to distinguish appear in wildly different amounts. Picture training a fraud detector where 999 of every 1,000 transactions are legitimate and only 1 is fraud. The rare class — the one you usually care about most — is buried under a mountain of the common one.
The trap is that overall accuracy becomes a liar. A model that simply predicts "not fraud" every single time is 99.9% accurate while catching exactly zero fraud — useless, but it looks great by the wrong yardstick. So with imbalanced data, accuracy is meaningless; you need measures that look at the rare class directly, like precision (of the cases I flagged, how many were really positive?), recall (of all the true positives, how many did I catch?), and their balance.
Why it matters: the most important problems are often imbalanced — disease screening, fraud, equipment failure, rare events of every kind — precisely because the thing you're hunting is rare. Common remedies include resampling (oversample the rare class, undersample the common one, or synthesize new rare examples), assigning a higher cost to missing the rare class, and choosing the right evaluation metric. None of these conjures real information about the rare class that the data doesn't contain — they only help the model and your judgment stop being dominated by the majority.
Out of 100,000 mammograms, 200 show cancer. A lazy model that always says "healthy" is 99.8% accurate yet misses every single cancer. Recall — the share of real cancers actually caught — exposes it instantly: that lazy model's recall is 0%.
99.8% accurate, 0% useful — why accuracy lies on imbalanced data.
On imbalanced data, accuracy is a vanity metric. Always report precision, recall, or their combination — and remember that resampling tricks rebalance how the model sees the classes, they do not create new knowledge about the rare one.