How your bank spots a stolen card
The claim
A fraud system that approved every payment was right 99.8% of the time and stopped none of the stolen money.
Why I built it
Everyone has a card, and few people know why a payment gets declined or how a stolen card gets caught. I wanted to build a scoring system that explains every decision, then measure what makes the job hard.
You can let a fraudster loose on your own made-up card and click any payment to see its score.
What I built
A simulated bank of made-up cardholders with habits, and fraudsters who take a card now and then. Each payment gets twelve signals from the card’s own history and a score from a logistic regression I wrote from scratch, split into parts that add up exactly. Two lines decide whether to approve, ask the customer to confirm or decline. A dispute arrives days later, if at all. It all runs in the browser and stores nothing. AI coding agents (Claude Code) wrote the code under my direction.
Decisions
- A score in readable parts instead of a black box. The panel has to show why a payment was declined.
- Rules and model compared at equal declines of real payments. At their own settings, the looser system always looks better. Declining as many real payments as five hand-written rules, the model stopped 74% of stolen money and the rules 60%.
- Companies named only beside their own published material. The page cites Stripe’s guide, a 2016 report on Mastercard’s fraud service, a 2017 paper on late labels and the PaySim simulator, and says it is no bank’s system.
- A made-up last four, nothing more. Nothing shaped like a card number is in the code.
How I tested it
I froze and committed every setting before the first measured run. Each finding comes from 20 simulated banks of 2,000 cards with fixed seeds. Tests fail if rebuilt results stop supporting a sentence the page states in words. A control run with no change of tactics kept month three at 78%, so the drop came from the change. I ran the live day in a headless browser at 1280 and 390 pixels wide, in both themes, under the production security headers.
What broke
- My first fit returned nonsense. Newton’s method overshot with fraud this rare. Halving the step until the error fell fixed it.
- Fraud was too easy to spot. The model stopped all of it at the rules’ volume, so I gave real customers more trips and new phones before the freeze.
- Waiting for every answer did not help. I expected late labels to hurt. Here the gap was smaller than the spread between banks.
What next
Add a signal that could catch the new tactic, and measure how many months of labels it needs.