Home / Machine Learning

Label Imbalance & The Accuracy Paradox

By Updated

Adjust the class distribution to see why Accuracy is a dangerously misleading metric when dealing with imbalanced datasets like fraud detection or rare diseases.

50%
Dataset Status

PERFECTLY BALANCED

Classes are equal. Accuracy is a reliable and safe metric to use.
Feature Space
Normal (0)
Anomaly (1)
Standard Model Boundary

The "Naive" Model

Predicts ONLY Class 0
Accuracy 0%
Precision (1) N/A
Recall (1) 0%

Standard Trained Model

Logistic Regression
Accuracy 0%
Precision (1) 0%
Recall (1) 0%
What this means:

Waiting for training...

Overview

Imagine 100,000 transactions, 500 of which are fraudulent. A model that predicts “legitimate” every time gets 99.5% accuracy and catches no fraud. The score is correct as a fraction of all predictions, but it says little about the rare class the system is meant to find.

Why accuracy can hide failure

This is the accuracy paradox: high accuracy can coexist with poor performance on the minority class. It does not mean accuracy is always useless; it means the class distribution and decision costs matter when interpreting it.

Read beyond the overall score

  • Recall = TP / (TP + FN): the share of actual positives detected. It matters when missed cases are costly.
  • Precision = TP / (TP + FP): the share of positive predictions that are correct. It matters when false alarms are costly.
  • F1 combines precision and recall using their harmonic mean, but ignores true negatives.
  • Balanced accuracy averages recall for each class, so the majority class does not dominate the average.

No metric is universally best. A fraud team with limited review capacity may prioritize precision; a safety screen may accept more false alarms to improve recall. Report the confusion matrix, class prevalence, selected threshold, and the metric tied to the decision.

Explore prevalence and overlap

Adjust Class 0 (Normal) % and Data Overlap in the visualizer. As normal examples become more common, a model can achieve high overall accuracy without finding many anomalies. Increasing overlap makes the classes harder to separate even if their proportions stay fixed. These controls vary two different properties: prevalence and separability.

A threshold changes the trade-off

Suppose the 500 positive cases receive model scores. At one threshold, the system might raise 610 alerts and catch 280 positives: 330 alerts are false and 220 positives are missed. Lowering the threshold to raise 2,400 alerts and catch 420 positives increases recall from 56% to 84%, but precision falls from about 46% to 18%. The model’s ranking did not change; the operating point did.

These counts are illustrative. Estimate them on validation data and choose the threshold using error costs or real review capacity. Keep the final test set out of those choices.

Common mistakes with Label Imbalance Problem

  • Treating 99% accuracy as proof of usefulness: compare against a majority-class baseline.
  • Reporting recall without false alarms: a system can catch more positives by flagging nearly everyone.
  • Assuming resampling is the first fix: inspect metrics and threshold behavior before changing training data.
  • Using only ROC AUC: it summarizes ranking over thresholds, not the precision or workload at the chosen threshold.

Sources and next steps

Predict, then reveal

About to run: set Class 0 (Normal) % to its maximum (99). Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. What does this module say about “Why accuracy can hide failure”?

  2. What does this module say about “Read beyond the overall score”?

  3. What does this module say about “Explore prevalence and overlap”?

Cheat sheet

Label Imbalance Problem

See how a model scores 99% accuracy while missing every fraud case, and why imbalance breaks your intuition about metrics.

MACHINE LEARNING · vizlearn.in/machine_learning/label_imbalance_problem.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.