“Our fraud classifier has 99.5% accuracy. Is it useful?”
Ask how common fraud is. If only 0.5% of payments are fraudulent, a model that always predicts “legitimate” reaches 99.5% accuracy and catches none of the fraud.
Class imbalance means some labels are much less frequent than others. It is a property of the data, not an instruction to automatically rebalance everything. Begin with the decision and the cost of mistakes.
01. Make the counts concrete
Consider 10,000 historical transactions with mature labels: 50 fraudulent and 9,950 legitimate. At a chosen threshold, the model flags 40 fraud cases and 160 legitimate payments.
| Actually fraudulent | Actually legitimate | |
|---|---|---|
| Flagged | 40 true positives | 160 false positives |
| Not flagged | 10 false negatives | 9,790 true negatives |
Recall = 40 / (40 + 10) = 80%
Accuracy = (40 + 9,790) / 10,000 = 98.3%
Accuracy is lower than the all-legitimate baseline, yet the model identifies 80% of the known fraud. Whether that is useful depends on what “flagged” causes: a cheap review, an extra authentication step, or an immediate rejection.
Google's metric guide defines these quantities. The numbers here are a teaching example, not measured model performance.
02. Choose the threshold for the action
A classifier produces a score. A threshold turns that score into a decision. A cutoff of 0.5 is convenient for some APIs, but it is not a business requirement.
For a fixed set of scores, lowering the cutoff flags more items. Recall cannot decrease, although precision does not have to change monotonically on every finite dataset. Inspect the actual precision–recall curve and the workload at each threshold.
If reviewers can handle 200 cases per day, compare policies under that capacity. A daily top-200 queue has a fixed count but variable quality. A fixed score threshold has a variable count. Real-time admission also needs a policy for bursts, deadlines, and cases arriving later in the day.
Select the model and action policy using validation data, then evaluate the frozen choice on untouched test data. Choosing the cutoff on the final test set makes that estimate optimistic.
scikit-learn's threshold guide distinguishes score estimation from the decision rule. Separate thresholds may be needed for review and blocking because the consequences differ.
03. Explain the role of cost and calibration
In a simplified binary action problem, assume a calibrated fraud probability p, a constant false-positive cost CFP, a constant false-negative cost CFN, and zero cost for correct decisions. Choose the positive action when:
Equivalently: p > CFP / (CFP + CFN)
This is a useful derivation, not a complete fraud policy. Costs can depend on payment amount, customer friction, and recovery probability. Challenges and reviews create additional actions. Capacity constraints can override the simple threshold.
A high ranking score is not necessarily a calibrated probability. Check calibration on representative validation data before interpreting scores as probabilities or using them in expected-cost calculations.
04. Use training interventions deliberately
| Option | Why try it? | What to watch |
|---|---|---|
| Class weighting | Make minority-class errors contribute more to the objective. | It changes the training objective and can affect calibration. |
| Majority undersampling | Reduce training volume and redundant negatives. | You may lose useful negative patterns or distort prevalence. |
| Minority oversampling | Increase minority representation during training. | Repeated examples add no new information and may overfit. |
| Better features and labels | Improve separation between classes. | Verify that each feature is available at serving time. |
Keep resampling inside each training fold. Preserve a representative evaluation distribution, or explicitly justify any evaluation weighting. If you balance the test set, its measured precision will generally not represent the natural deployment prevalence.
Try a simple baseline and threshold tuning before assuming a complex sampling method is necessary. Compare all candidates at the same operating constraint.
05. Read the curves with the base rate in mind
ROC curves summarize true-positive and false-positive rates across thresholds. With many legitimate transactions, even a small false-positive rate can generate a large review queue. Precision–recall views make that burden more visible for a rare positive class.
Neither ROC-AUC nor a precision–recall summary specifies your final action threshold. Average precision and trapezoidal PR-AUC are also different summaries; name the implementation you use.
Precision depends on prevalence. At the same sensitivity and false-positive rate, a lower fraud base rate generally yields lower precision. Reassess performance when deployment traffic differs from the validation population, and inspect important cohorts.
06. Answer the follow-up
“Should we optimize F1?”
Only if its trade-off fits the task. F1 combines precision and recall but ignores true negatives, does not directly encode monetary costs, and does not enforce a queue limit. For a review system, recall at a review budget may be more actionable.
“Our class-weighted model catches more fraud. Ship it?”
Check false positives, calibration, capacity, temporal validation, and customer impact at the selected policy. Better recall at an unspecified threshold is not enough evidence.
“I would establish the base rate, inspect the confusion matrix, and select a policy under the real cost or capacity constraint. I would compare models on representative held-out data and treat sampling, calibration, and threshold selection as separate decisions.”
Sources & further reading
Build the fraud system’s evaluation policy ↗
Connect metrics to label maturity, review capacity, and serving decisions.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.