Book a free call

How Machine Learning Catches Credit Card Fraud

Machine learning scores each card payment for fraud risk in a fraction of a second. Here is how the signals, models and thresholds work together.

Hertiv engineering teamReviewed by a senior engineer
8 min read
How Machine Learning Catches Credit Card Fraud
On this page

Short answer

Machine learning catches credit card fraud by scoring each transaction against patterns learned from past genuine and fraudulent payments. The model weighs signals such as amount, location, velocity and device, then returns a risk score that decides whether the payment is approved, checked further or declined.

What is credit card fraud detection with machine learning?

Credit card fraud detection with machine learning is the use of trained models to score each card transaction for fraud risk before the payment is approved. The model learns from past transactions, including examples labelled as genuine and fraudulent, and then judges new transactions against those patterns.

When you tap, insert or type in a card number, the issuer has only a fraction of a second to decide whether to approve the payment. A model gives the issuer a risk score for that single transaction, and the score decides whether the payment goes through, is held for a check, or is declined.

This is different from a fixed rule list. Rules say things like 'decline any transaction over a set amount in a new country'. A model weighs many signals together, so a large purchase from a familiar shop on a familiar device can still pass, while a small purchase that breaks several patterns at once can be stopped. The general method is covered in fraud detection using machine learning.

What card fraud signals does a model use?

A card fraud model uses signals from the transaction itself, the cardholder's history and the device or channel, and it combines them into one risk score. No single signal proves fraud; the pattern across several signals is what matters.

Signal groupExamplesWhat it tells the model
TransactionAmount, merchant type, time of dayWhether the purchase fits the cardholder's normal spending
LocationCountry, city, distance from last purchaseWhether the card could plausibly be in two places
VelocityTransactions in the last hour, day or weekWhether someone is testing or draining the card
Device and channelDevice fingerprint, browser, card-present or onlineWhether the buyer matches the usual device
HistoryPast chargebacks, past declines, account ageWhether this card or account has been attacked before

Velocity is often the strongest early warning. A genuine cardholder rarely makes five purchases in ten minutes from three different countries, while a fraudster who has just obtained card details often tests the card with small purchases before trying a large one.

How does a model score a transaction in real time?

A model scores a transaction by turning its signals into numbers, feeding them through the trained model, and returning a risk score, all inside the short window the payment network allows for an approval decision.

The flow has four steps. First, the transaction data arrives from the merchant or payment processor. Second, a feature service looks up the cardholder's recent history, such as purchases in the last hour and the usual countries. Third, the model produces a score, often a number between zero and one, where a higher number means higher risk. Fourth, a decision layer compares the score with thresholds set by the issuer.

Thresholds usually create three outcomes. Low scores approve the payment at once. Middle scores trigger a step-up check, such as a one-time code sent to the cardholder's phone. High scores decline the payment or hold it for a human review. The thresholds are a business choice: a lower threshold catches more fraud but blocks more genuine customers, so teams tune them against real outcomes rather than guessing.

What kinds of models do issuers use?

Issuers use three kinds of models together: rules for known fraud patterns, supervised models trained on labelled fraud cases, and anomaly models that flag behaviour unlike the cardholder's own history.

Rules are the oldest layer. A rule might block a transaction when the card is used in a country where it has never been used, or when ten purchases happen in one minute. Rules are easy to explain and quick to change, which is why they stay in place even after models arrive.

Supervised models learn from history. They are trained on transactions labelled as fraud or genuine, and they find combinations of signals that rules miss, such as a normal amount at a normal merchant that still looks wrong because of the device, the time and the velocity together. These models need fresh labels, because fraud patterns change and a model trained on last year's cases slowly goes stale.

Anomaly models work without fraud labels. They learn what normal looks like for one cardholder and flag what does not fit, which helps with new fraud types that have no labelled examples yet. Many teams combine all three layers, and banks often coordinate them with AI orchestration for banking fraud detection.

How do you train and test a card fraud model?

You train a card fraud model by building a labelled dataset from past transactions, splitting it by time, training on the earlier period, and testing on the later period so the test matches how the model will face new fraud.

  1. Collect labelled transactions. Gather past card transactions with confirmed fraud labels from chargebacks and investigations, plus a sample of genuine transactions.
  2. Build features. Turn raw fields into signals the model can use, such as purchases in the last hour, distance from the last purchase, and whether the device is new.
  3. Split by time, not at random. Train on earlier months and test on later months, because fraud changes over time and a random split would overstate accuracy.
  4. Handle the imbalance. Fraud is a tiny share of transactions, so use sampling or class weights that keep the model from simply predicting 'genuine' every time.
  5. Measure what matters. Track how much fraud the model catches and how many genuine transactions it blocks, not just overall accuracy.
  6. Run a shadow test. Score live transactions without acting on the scores, compare the model's calls with the old system's decisions, and only then switch it on.

The time-based split matters more than most teams expect. A model that scores well on a random split can still fail in production, because it has effectively seen the future during training. Testing on later months is the honest check, and teams that need help building this pipeline can start with machine learning development support.

How do you keep false declines low?

You keep false declines low by tuning thresholds against real outcomes, adding step-up checks for middle scores, and feeding the results of reviews and chargebacks back into the model.

A false decline is a genuine purchase that the system blocks, and it costs more than the lost sale: the cardholder may stop using that card, or switch to another card for good. That is why issuers treat the decline rate as a product metric, not only a security metric.

Step-up checks are the main tool. Instead of declining a middle-score transaction, the issuer asks the cardholder to confirm it with a code or a banking app prompt. The check adds friction, but only for the small share of transactions that look uncertain, so most genuine purchases still go through without a pause.

Teams that run fraud analytics in finance review which step-up checks actually confirm fraud and which ones only annoy genuine customers, then adjust the thresholds.

Feedback loops close the gap. Every confirmed fraud case and every wrongly declined purchase becomes a new label for retraining, so the model learns from its own mistakes instead of repeating them.

Example (hypothetical): a mid-size issuer's first fraud model

Example (hypothetical): a mid-size card issuer processes 400,000 transactions a month and relies on rules alone. Its team builds a first supervised model and tests it on the last three months of data before switching anything on.

In the test period, the rules catch 240 of the 400 confirmed fraud cases, which is 6 in 10. The model catches 320 of the same 400 cases, which is 8 in 10, while blocking the same number of genuine transactions as the rules. The extra 80 caught cases matter, because each one is a chargeback the issuer would otherwise pay.

The team then runs the model in shadow mode for one month, scoring live transactions without acting on the scores. The shadow run confirms the test result: the model would have caught 105 of 130 fraud cases in that month, against 78 caught by the rules, with 90 fewer genuine transactions flagged. Only after that check does the team switch the model on for real decisions, with step-up checks for middle scores.

The lesson is the sequence, not the numbers. Test on later months, shadow-test live, and switch on only when the live scores match the test scores.

What are the common mistakes?

The most common mistakes in card fraud detection with machine learning are training on a random split, ignoring the cost of false declines, and letting the model go stale while fraud patterns move on.

  • Random train-test splits. A random split lets the model see the future, so the test score looks better than the live result will be.
  • Chasing accuracy. A model can be 99% accurate by approving everything, because fraud is rare. Measure fraud caught and genuine transactions blocked instead.
  • Ignoring false declines. Every blocked genuine purchase pushes the cardholder toward another card. Track the decline rate as a product metric.
  • No feedback loop. Without confirmed fraud labels and wrongly declined cases flowing back into training, the model freezes while fraud moves on.
  • Too many signals, too little care. Adding every available field without checking for leaks, such as a field that only exists after a fraud decision, produces a model that works in testing and fails live.
  • Skipping the shadow test. Switching a model on without scoring live traffic first means the first real test happens on customers.

Key takeaways

  • A fraud model scores each transaction on amount, location, velocity, device and history combined
  • Rules, supervised models and anomaly checks work best together, not alone
  • Train on earlier months and test on later months, or the test score will mislead you
  • Step-up checks for middle scores cut false declines without letting fraud through
  • Feed confirmed fraud and wrongly declined purchases back into training so the model stays current

Frequently asked questions

How fast does a fraud model have to decide?

Within the short window the payment network allows for an approval, usually well under a second. That is why issuers precompute history features and keep the model small enough to score in real time, rather than running a heavy batch job after the payment has already been approved.

Why do fraud models go stale?

Fraud patterns change as attackers adapt, and cardholder behaviour changes too, for example when people travel or start shopping online more. A model trained on last year's cases slowly loses accuracy, so teams retrain on recent labelled data and watch the fraud catch rate over time.

What is a false decline?

A false decline is a genuine purchase that the fraud system blocks. It costs the issuer the sale and can push the cardholder to use a different card, so issuers track the decline rate closely and use step-up checks to confirm uncertain transactions instead of declining them outright.

Do rules still matter once you have a model?

Yes. Rules handle known fraud patterns quickly and are easy to explain to auditors and regulators. Most issuers run rules alongside models, using rules for the obvious cases and models for the combinations of signals that no single rule can describe.

What data does a card fraud model need?

It needs labelled transactions, meaning past payments marked as fraud or genuine, plus the signals around each one: amount, merchant type, location, device, channel and recent history. Without reliable labels, usually from chargebacks and investigations, a supervised model cannot learn what fraud looks like.

Can a small issuer build a fraud model?

Yes, if it has enough labelled history or works with a vendor or processor that provides one. The key requirements are clean labels, a time-based test split and a shadow test before going live, which matter more than the size of the team. For help scoping the work, see machine learning development services.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a fraud detection model for card payments? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Machine Learning Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call