MODULE 11 ยท Middle-track ยท 2 hours

93% of the alerts are false โ€” and the economics still work

One fraudster per thousand honest users, 500 manual checks a day and two errors with very different price tags. The threshold here is arithmetic, not 0.5 by default.

Open this module in the simulator All 23 lessons

The first two modules are free, no card. The rest are $20/month.

๐Ÿข The situation

You are transferred to the anti-fraud sub-project. Igor brings you up to speed:

"The Datacore wallet processes 400,000 transactions a day. Fraud is 0.1%, but every missed case averages โˆ’$220, and every false block of an honest customer means a support call (โˆ’$5) and an angry user. The manual review team handles at most 500 alerts a day. Your model must live within these constraints. A 1:1000 imbalance is where all the textbook habits break."

๐ŸŽฏ Your task

  1. Understand what breaks under heavy imbalance and how to fix it.
  2. Master class weights, oversampling/undersampling, SMOTE โ€” and their limits.
  3. Choose the threshold from economics and operational limits.

๐Ÿ“š Theory

What breaks at 1:1000

  1. Accuracy is meaningless (module 6): the constant "not fraud" gives 99.9%.
  2. The loss function barely sees the rare class: 0.1% of examples contribute 0.1% of the gradient โ€” the model learns to ignore fraud.
  3. ROC-AUC is deceptively high; look at PR-AUC and precision/recall at the operating point.

Ways to fight it

Method Essence Pros / cons
Class weights (class_weight="balanced", scale_pos_weight) errors on the rare class cost more simple, no data distortion; the first choice
Undersampling drop part of the majority class faster training; loses information
Oversampling duplicate the rare class overfitting risk on duplicates
SMOTE synthetic examples between rare-class neighbors helps weak models; often useless for boosting, creates unrealistic points
Threshold tuning don't touch the data, shift the decision mandatory always, whatever you do above

Industry practice: for boosting โ€” class weights + threshold tuning. Sampling โ€” when the data doesn't fit in memory or the model is very weak.

โš ๏ธ Golden rules:

The threshold from economics

The expected value of an alert at threshold t: V(t) = TP(t)ยท220 โˆ’ FP(t)ยท5, subject to TP(t)+FP(t) โ‰ค 500/day. The threshold is the solution of an optimization problem, not the constant 0.5.

Imbalance 1:1000 find the โ— fraud among thousands of honest ones Precision-Recall curve operating point: 500 alerts/day, recall 0.62 recall โ†’ precision โ†’
With a rare class, evaluate the model on the PR curve and pick the operating point from the team's throughput and the economics of errors.

What to remember

  • Under imbalance: PR-AUC + operating-point metrics; accuracy and "bare" ROC-AUC mislead.
  • The first tool is class weights; sampling โ€” train only; probabilities afterwards are biased.
  • The threshold is derived from error costs and the team's throughput.
  • Report to the business in money.

Next in this module: Practice

Open the module โ†’

Nearby lessons

10 Squeezing out 2% more quality 12 Who are our customers, really?

The whole program โ€” 23 lessons