A fraud dataset has 99.5% legitimate and 0.5% fraudulent transactions, and your classifier reports 99.5% accuracy. Is it a good classifier, and how would you handle the imbalance?

Supervised learning, Classification
Level L1 Beginner. Length Short. Nature Th Theoretical.

What's being asked

Whether you know why accuracy misleads on imbalanced data, and the standard fixes.

Key idea

A model that always says “legitimate” already gets 99.5% accuracy while catching no fraud. So judge the model on the rare class, with precision, recall, F1 or PR-AUC. Then fix the imbalance with class weights, resampling of the training set, or a tuned decision threshold.

Steps

  1. Point out the trivial baseline. Always predicting “legitimate” scores 99.5% accuracy and catches zero fraud, so 99.5% tells us nothing.
  2. Switch metrics. Take fraud as the positive class; TP, FP and FN are the counts of true positives, false positives and false negatives. Precision =TPTP+FP is how many flagged cases are really fraud. Recall =TPTP+FN is how much of the fraud we catch. F1 is their harmonic mean, and PR-AUC is the area under the precision–recall curve.
  3. Loss-level fix: weight each class in the loss, for example by n/(2nc), where n is the number of samples and nc the number in class c. Mistakes on the rare class then cost more.
  4. Data-level fix: oversample the minority class (copy it, or make synthetic points with SMOTE) or undersample the majority class. Do this on the training split only.
  5. Threshold fix: the default cut-off of 0.5 on the predicted probability is arbitrary. Choose the cut-off on a validation set to reach the recall or precision you need.

Common mistakes

How long your answer should be

4–6 sentences.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: In a soft-margin support vector machine (SVM), what does the hyperparameter C control?
Next in Supervised learning: What is the Bayes classifier for minimum error rate, and why does picking the most probable class minimise your chance of being wrong?