AI in payments today: fraud scores, smart routing and support bots
A fraud rule is a model with one feature. Count what it flags against everyone it could have flagged, and the suspects turn out to be your best merchants
Ese's rule flags any customer with 3 or more attempts to move money inside one clock hour. In the lab's data merchants are 138 of 2,000 customers (6.9%). About what share of the customers the rule flags are merchants?
Money in a payment moves in a few seconds. The decisions around it have to be quick too. Three of those decisions are now often made or assisted by a statistical model, and a fourth class of tool talks to the customer when something goes wrong. The earlier chapters of this module showed how money moves and where it can go wrong. This chapter asks a different question: when software that learns from data makes the decision, what changes, and how do you check it?
You do not need to know how a model is trained. How models work is the AI Engineering course’s subject: start with what an LLM is and hallucination and grounding. Here you meet the models as a payments engineer meets them, from outside, as components that return an answer you have to decide whether to trust.
The lab uses Owoleaf’s books (a fictional Lagos wallet company; every limit, fee and code in the data is illustrative). The example company in the prose is the 200-person gateway, which is not Owoleaf.
Three jobs and one shape
Look at what a payment gateway does between a customer pressing Pay and the merchant seeing a result. Three decisions sit on that path, and a fourth conversation sits beside it.
The three jobs look different, but they share one shape. Each takes some inputs, returns a number or a text, and the system acts on it. Each can be wrong in two directions, and each wrong direction has a cost: a declined good customer or a paid thief, a slow route or a dead one, a helpful answer or an invented one. Each can drift: the data it learned from stops matching today’s traffic. The method in this chapter is the same for all three. Say what it decides, say what the two kinds of error cost, measure the errors against a record you trust, and decide who is accountable.
Notice what is missing: a claim that AI is better. Sometimes it is. A published survey of UK financial firms found adoption was already common by late 2024, the Bank of England and the Financial Conduct Authority (FCA)’s third survey (118 firms, published 21 November 2024) reported that 75% of firms were already using AI, with a further 10% planning to within three years, up from 58% and 14% in 2022, and that 46% of firms using or planning AI said they had only a partial understanding of the technologies they usedas of 2026-11. Those figures come from a search summary of the report, so read the report itself before you quote them, and note that they describe the UK, not Nigeria. What they show is that you will meet these tools at work, and that using a tool and understanding it are different things.
Fraud scores: from a rule to a model
Start with the oldest fraud control, a rule. A velocity rule counts how often something happens in a window of time and flags a count above a threshold. “Two or more card payments from one customer in an hour” is a velocity rule. It is a model with one feature, a threshold and no learning, and everything that can go wrong with a trained model can go wrong with it. That is why you build one first.
A fraud score generalises it. Instead of one count, a model takes many features (counts over several windows, the amount against the customer’s usual amount, whether the device or the card is new, the hour, the merchant) and returns a number, often between 0 and 1, for how risky the payment looks. The system then compares the number with thresholds: below the lower one, approve; above the upper one, decline; between them, hold for a person or ask the customer for more proof.
The scoring model is trained on past payments that someone labelled as fraud or not. The labels usually come late and are incomplete. A cardholder disputes a charge weeks after it happened. A fraud that nobody noticed is labelled “good”. A payment the model declined never gets a label at all, because nobody learns whether it would have been fraud. Keep that in mind: the data the next model learns from was shaped by the last model’s decisions. Bolton and Hand’s review of statistical fraud detection, written before most of today’s tools, separates preventing fraud from detecting it and supervised methods (trained on labels) from unsupervised ones; it is the right first paper to read.
Why the base rate decides everything
Fraud is rare. That single fact explains most of the disappointment with fraud models, so work the arithmetic. These numbers are a hypothetical, not a measurement from any real gateway.
Suppose 10,000 payments arrive and 1 in 500 is fraud. That is 20 frauds and 9,980 good payments. A model that catches 90% of frauds catches 18. If it also wrongly flags 5% of good payments, it flags 9,980 × 0.05 = 499 of them. It flags 18 + 499 = 517 payments in all, and 18 of the 517 are fraud: 18 / 517 = 3.5%. About 29 of every 30 flags are a customer you have inconvenienced.
Now suppose a better model cuts the false-alarm rate to 1%. It wrongly flags 9,980 × 0.01 = 99.8 (about 100), flags about 118 in all, and 18 / 118 = 15.3% of flags are fraud. The model barely changed how many frauds it catches, and the review queue shrank by more than three quarters (517 flags down to 118).
Two lessons follow. First, quote both numbers. The share of frauds caught is called recall, and the share of flags that are fraud is called precision. A vendor that quotes one is quoting the flattering one. Second, a threshold is a business decision. Moving it up declines fewer good customers and lets more fraud through. The model does not choose the threshold. Somebody who owns the cost of both mistakes does.
What the lab’s rule shows
The lab has you write the rule. On the card fundings in Owoleaf’s data, counting attempts per customer per clock hour and flagging two or more, the rule flags 34 customers. All 34 are individuals, because in this data merchants fund their wallets by bank transfer and never by card. Nothing in the data labels any customer as a fraudster, so you cannot say how many of the 34 are real suspects. You can say that of the 1,565 customers who ever funded by card, 34 (2.2%) tripped the rule.
Widen the rule to count every attempt a customer starts (card funding, bank-transfer funding, wallet-to-wallet transfers and payouts) and flag three or more in an hour. It flags 66 customers, and 31 of them are merchants. Merchants are 138 of the 2,000 customers, 6.9%, but they are 47% of the flagged list. Put another way, 31 of 138 merchants (22.5%) trip the rule, against 35 of 1,862 individuals (1.9%). The rule is not wrong about what it counts. It is wrong about what it means.
This is the same trap as the decline reasons in the loan lifecycle, where a count hid the order the rules ran in: a list is only meaningful next to its denominator. Before you act on a flag, ask three questions. Who could have been flagged? Who was? What does the rule measure besides fraud?
Smart routing
A gateway rarely uses one provider. It may connect to several acquirers (the banks or processors that pass a card payment to the card networks, which the next chapters explain) and to several routes for transfers. Routing is the choice, per payment, of which one to try. A static rule can route by card type or amount. “Smart” routing adds a model: it tracks how each provider has been succeeding recently and sends more traffic to the one that is doing best.
Vendors sell this. As a labelled vendor claim, the open-source payments orchestrator Hyperswitch (from the company Juspay) describes an auth-rate routing feature that ranks eligible processors by recent success rate and keeps updating its scores from live trafficas of 2026-11. That description is from the vendor’s documentation as it appeared in a search summary (the same material says the router keeps a small share of traffic for exploring other processors), and any improvement figures its materials report are the vendor’s own, from its own traffic. They tell you what the class of tool does. They do not tell you what it would do for your payments.
Three things go wrong with routing by recent success rate, and each is visible in a few lines of arithmetic.
Small samples. Suppose provider A succeeded on 46 of its last 50 payments (92%) and provider B on 44 of 50 (88%). The gap looks like four points. With 50 payments each, the standard error of a success rate near 90% is √(0.9 × 0.1 / 50) = 4.2 points, and for the difference between two rates it is about 4.2 × √2 = 6.0 points. A gap of four points is inside that noise. A router that moves traffic on it is reacting to luck. Real systems need a minimum sample size and a rule for exploring a provider that currently looks worse, or the router never learns that it recovered.
What a decline means. A router that counts every non-success as the provider’s failure punishes a provider for declines that were the customer’s: an empty account, a wrong card number. Compare providers on a mixed stream, or the one that is sent the hard cards looks worst. In the Owoleaf data 400 card fundings failed with card_declined, which is a decision about the card and not about the processor.
Retrying elsewhere. After a decline or an error the router may try another provider. If the first attempt actually succeeded and the response was lost, a second attempt charges the customer twice. That is why every retry needs an idempotency key (the lesson on idempotency shows the failure) and why the later chapter on routing across providers also checks what the card schemes’ rules allow for re-presenting a declined authorisation. This chapter does not state those rules, because they are scheme rules to be read at the source.
A router also concentrates risk. If it learns that one provider is best, it sends it nearly everything, and an outage at that provider now takes the gateway down. Financial regulators have noticed the same pattern in the wider use of AI. The Financial Stability Board’s report of 14 November 2024, The Financial Stability Implications of Artificial Intelligence, names four vulnerabilities that AI could amplify: third-party dependencies and service-provider concentration, market correlations, cyber risk, and model risk, data quality and governanceas of 2026-11. The list rests on a search summary of the report, whose own PDF and press release the FSB publishes. It is an analytical report, not a rule.
Support bots
A support bot is a language model, usually behind a chat window or a WhatsApp number, that answers customers. A good one is retrieval-grounded: it looks up help-centre pages or the customer’s own payment record and writes the answer from them. A poor one answers from what the model remembers, which is language in general and nothing about your system.
For payments the dangerous requests are the ordinary ones. “Why did my transfer fail?” “Where is my ₦15k?” “Reverse it.” The model has to read an amount, find the payment, state a status and sometimes take an action.
It fails in four ways, and you should look for each.
- It explains what the record does not say. A failed row in the lab carries a
failure_reason, but a model that is shown only the amount, the time and the word “failed” has to guess. Why does a ₦150,803 bank-transfer funding fail withbalance_cap? Only the customer’s balance and tier explain it, and neither is on the row. A model asked “why did this fail?” with only the row produces a reason anyway, because a reason is what the sentence calls for. - It misreads money. Nigerians write the same amount many ways: “₦1.5k”, “N1,500”, “1500 naira”, “15k”. The first three are ₦1,500 and the last is ten times that. A model that does well on English with “N1,500” may stumble on “15k” or on a sentence in Pidgin or Yoruba, or read “N1.500” (a dot as a thousands separator, as in some European writing) as one and a half naira. The lab gives you the exact answers to check against, in integer kobo.
- It is steered by what it reads. Anything the bot reads, such as a narration, a message or a merchant description, can contain instructions. That is prompt injection, covered in guardrails and injection. A bot that can act (refund, reverse, change a phone number) needs its actions checked by code, not by its own judgement.
- It stands between a customer and a person. A customer whose money has gone missing wants a person. The United States consumer regulator, the Consumer Financial Protection Bureau (CFPB), looked at chatbots in banking and reported many complaints from customers who could not get answers or raise disputes. The CFPB’s June 2023 issue spotlight Chatbots in consumer finance describes risks of non-compliance with consumer financial protection law, poorer customer service and consumer harm, and says firms should adopt such technology in a way that complies with the lawas of 2026-11. That is a US document and a search summary of it. It is here for the principle, which carries over: a bot is not a way to avoid a duty.
The fix for the first failure is design, not a better prompt. Look the reason up in the system of record and let the model only put it in words. That is the choice in this chapter’s decision.
Governing a model
A model that touches money is a risk the company owns. Four ideas apply to all three jobs.
Validation. Someone other than the builder tests the model on data it was not built on and writes down what it does well, what it does badly and what it must not be used for. For the rule in the lab, validation is the table of who it flagged and why.
Explainability, to a customer and to an examiner. A customer who was declined needs a reason they can act on. An examiner needs to see how a decision was reached. A fraud score alone is neither. You need the features that moved it, or a rule-based reason code beside it.
Bias testing. A model can decline one group of customers much more often than another without ever using the group as a feature, because a proxy such as a state, a phone type or the hour carries it. Measure false-decline rates by kyc_tier (the customer’s know-your-customer verification level) and by state, as you can in the lab’s data. A gap does not prove unfairness, but you have to be able to explain one.
Model risk management. The US banking regulators’ 2011 supervisory guidance on model risk management, SR 11-7, set out an approach (develop, validate, govern) that others copied. The Federal Reserve’s letter SR 26-2, Revised Guidance on Model Risk Management, issued on 17 April 2026, supersedes SR 11-7 and SR 21-8as of 2026-11. Search summaries of it disagree on how far it covers generative AI, and this build did not read its full text, so read the letter before you cite it. The practical point is older than both: a model needs an owner, a validation, a monitoring plan and a way to switch it off.
Data protection applies as well. Fraud scoring and support chats both process personal data, and a decision made only by software about a person is regulated. Search results on the Act’s text, published by the Nigeria Data Protection Commission, describe section 37 of the Nigeria Data Protection Act 2023 as giving a data subject a right not to be subject to a decision based solely on automated processing, including profiling, that has a legal or similar effect, with exceptions, and with safeguards (human involvement, stating views, contesting the decision) where automated decisions are allowedas of 2026-11. Commentary disagrees about how the exceptions are worded, and this build could not open the PDF itself. Take the wording from the Act, and ask your counsel what “legal or similar effect” covers for a declined payment.
On Nigeria’s central bank: this chapter states no Central Bank of Nigeria (CBN) rule on AI models, because this build could not confirm one from the CBN’s own text. Look for any CBN circular on automated fraud or anti-money-laundering monitoring on the CBN’s site before you design a control.
Finally, do not hand money decisions to a tool nobody can switch off. Every model in a payment path needs a fallback that works without it: a plain rule, a default route, a human queue.
You work in labs/finance. Owoleaf’s data is generated, every limit and code in it is illustrative, and no customer in it is labelled as a fraudster. The sqlite3 command-line tool may not be installed, so each query runs through Python’s sqlite3 module, which needs nothing else.
1. Write the rule and list who it flags. Generate the data if data/ does not exist (the first line), then count card funding attempts per customer per clock hour and flag two or more.
cd labs/finance
python3 generate.py && python3 check.py
python3 - <<'EOF'
import sqlite3
db = sqlite3.connect("data/finance.sqlite")
RULE_A = """
WITH h AS (
SELECT customer_id, substr(created_at, 1, 13) AS hr, COUNT(*) AS n
FROM transactions WHERE kind = 'funding_card'
GROUP BY customer_id, hr)
SELECT c.ref, c.kind, c.kyc_tier, COUNT(*) AS flagged_hours, MAX(h.n) AS most_in_an_hour
FROM h JOIN customers c ON c.id = h.customer_id
WHERE h.n >= 2
GROUP BY c.id ORDER BY flagged_hours DESC, most_in_an_hour DESC, c.ref LIMIT 20"""
for r in db.execute(RULE_A): print(r)
print(len(db.execute(RULE_A.replace("LIMIT 20", "")).fetchall()), "customers flagged by rule A")
print(db.execute("SELECT COUNT(*) FROM customers c WHERE kind='merchant' AND EXISTS (SELECT 1 FROM transactions t WHERE t.customer_id=c.id AND t.kind='funding_card')").fetchone()[0], "merchants have any card funding")
EOF('C0000742', 'individual', 1, 3, 2)
('C0001126', 'individual', 1, 3, 2)
('C0000139', 'individual', 2, 2, 2)
('C0000952', 'individual', 2, 2, 2)
('C0001085', 'individual', 1, 2, 2)
('C0001429', 'individual', 1, 2, 2)
('C0000202', 'individual', 3, 1, 3)
('C0000018', 'individual', 1, 1, 2)
('C0000192', 'individual', 1, 1, 2)
('C0000193', 'individual', 1, 1, 2)
('C0000291', 'individual', 1, 1, 2)
('C0000405', 'individual', 2, 1, 2)
('C0000493', 'individual', 1, 1, 2)
('C0000513', 'individual', 1, 1, 2)
('C0000564', 'individual', 1, 1, 2)
('C0000607', 'individual', 1, 1, 2)
('C0000765', 'individual', 1, 1, 2)
('C0000766', 'individual', 2, 1, 2)
('C0000839', 'individual', 2, 1, 2)
('C0000860', 'individual', 1, 1, 2)
34 customers flagged by rule A
0 merchants have any card fundingThe columns are the customer’s reference, kind, KYC tier, the number of clock hours in which the rule fired, and the most attempts in one hour. All 34 flagged customers are individuals, because no merchant in the data funds by card. 34 of the 1,565 customers who ever funded by card is 2.2%. Nothing here says which of the 34 is a real fraudster: the data has no label.
2. Widen the rule and compare the flagged list with the customer base. Count every attempt a customer starts, and flag three or more in an hour.
python3 - <<'EOF'
import sqlite3
db = sqlite3.connect("data/finance.sqlite")
KINDS = "('funding_card','funding_transfer','p2p_transfer','payout_nip')"
RULE_B = f"""
WITH h AS (
SELECT customer_id, substr(created_at, 1, 13) AS hr, COUNT(*) AS n
FROM transactions WHERE kind IN {KINDS}
GROUP BY customer_id, hr)
SELECT c.ref, c.kind, c.kyc_tier, COUNT(*) AS flagged_hours, MAX(h.n) AS most_in_an_hour
FROM h JOIN customers c ON c.id = h.customer_id
WHERE h.n >= 3
GROUP BY c.id ORDER BY flagged_hours DESC, most_in_an_hour DESC, c.ref"""
rows = db.execute(RULE_B).fetchall()
for r in rows[:20]: print(r)
print(len(rows), "customers flagged by rule B")
by = {}
for r in rows: by[r[1]] = by.get(r[1], 0) + 1
print("flagged by kind:", by)
print("all customers by kind:", dict(db.execute("SELECT kind, COUNT(*) FROM customers GROUP BY kind")))
EOF('C0001621', 'merchant', 1, 22, 4)
('C0000688', 'merchant', 3, 11, 4)
('C0000735', 'merchant', 3, 9, 3)
('C0001731', 'merchant', 3, 9, 3)
('C0000742', 'individual', 1, 7, 3)
('C0001975', 'merchant', 3, 6, 4)
('C0001441', 'merchant', 3, 5, 3)
('C0000743', 'individual', 1, 4, 4)
('C0001269', 'merchant', 1, 4, 4)
('C0000687', 'merchant', 3, 4, 3)
('C0001982', 'individual', 1, 3, 4)
('C0000384', 'merchant', 1, 3, 3)
('C0000607', 'individual', 1, 3, 3)
('C0001085', 'individual', 1, 3, 3)
('C0001607', 'individual', 1, 3, 3)
('C0001624', 'merchant', 3, 3, 3)
('C0000139', 'individual', 2, 2, 3)
('C0000199', 'merchant', 1, 2, 3)
('C0000202', 'individual', 3, 2, 3)
('C0000521', 'merchant', 3, 2, 3)
66 customers flagged by rule B
flagged by kind: {'merchant': 31, 'individual': 35}
all customers by kind: {'individual': 1862, 'merchant': 138}The top of the list is mostly merchants. 31 of the 66 flagged customers are merchants (47%), though merchants are 138 of 2,000 customers (6.9%). As a share of each group, 31 of 138 merchants (22.5%) are flagged, against 35 of 1,862 individuals (1.9%). The rule counts activity, and merchants are active.
3. Ask an assistant to explain five failures. This script prints five anonymised rows: no customer reference and no external reference, with the amount in naira, and the failure reason held back. Four failed and one succeeded.
python3 - <<'EOF'
import sqlite3
db = sqlite3.connect("data/finance.sqlite")
def naira(k): return f"N{k // 100:,}.{k % 100:02d}"
picks = []
for reason in ("balance_cap", "daily_limit", "beneficiary_bank_unavailable", "card_declined"):
picks.append(db.execute("SELECT id, kind, amount_kobo, rail, created_at, counterparty_bank, status, failure_reason FROM transactions WHERE failure_reason=? ORDER BY id LIMIT 1", (reason,)).fetchone())
picks.append(db.execute("SELECT id, kind, amount_kobo, rail, created_at, counterparty_bank, status, failure_reason FROM transactions WHERE status='succeeded' AND kind='funding_transfer' ORDER BY id LIMIT 1").fetchone())
print("--- PASTE THIS INTO THE ASSISTANT ---")
for i, (tid, kind, amt, rail, ts, bank, status, why) in enumerate(picks, 1):
print(f"{i}. type={kind}, amount={naira(amt)}, rail={rail}, time={ts[:16].replace('T', ' ')}, other_bank={bank or '-'}, status={'failed' if status == 'failed' else 'succeeded'}")
print("--- KEEP THIS TO YOURSELF ---")
for i, p in enumerate(picks, 1):
print(i, "transaction id", p[0], "failure_reason:", p[7])
EOF--- PASTE THIS INTO THE ASSISTANT ---
1. type=funding_transfer, amount=N150,803.00, rail=nip, time=2026-01-18 14:28, other_bank=B23, status=failed
2. type=payout_nip, amount=N45,075.06, rail=nip, time=2026-01-26 15:02, other_bank=B10, status=failed
3. type=payout_nip, amount=N3,818.84, rail=nip, time=2026-01-10 17:58, other_bank=B10, status=failed
4. type=funding_card, amount=N7,272.00, rail=card, time=2026-01-13 20:15, other_bank=-, status=failed
5. type=funding_transfer, amount=N42,389.00, rail=nip, time=2026-01-03 16:03, other_bank=B17, status=succeeded
--- KEEP THIS TO YOURSELF ---
1 transaction id 344 failure_reason: balance_cap
2 transaction id 876 failure_reason: daily_limit
3 transaction id 85 failure_reason: beneficiary_bank_unavailable
4 transaction id 141 failure_reason: card_declined
5 transaction id 2 failure_reason: NonePaste the five lines into a free assistant (or a local model) and ask: “Why did each of these payments fail? Say if you cannot tell.” Then compare with the key. What you check, and what the data supports: row 5 did not fail, so any reason given for it is invented. Rows 1 and 2 turn on the customer’s balance and daily total, which are not on the row, so an answer naming them is a guess, however plausible. No row carries its reason, so an honest answer for rows 1 to 4 is a short list of possible causes and not one confident cause. Count how many of its five reasons match the key, how many it gave for a payment that succeeded, and whether it ever said “I cannot tell”. Run the same prompt twice and count again.
4. Test amounts in English, Pidgin and Yoruba. First write a reference parser and eight test sentences. The parser returns integer kobo and refuses a dot-grouped number it cannot interpret. Ask a Yoruba speaker to check the two Yoruba sentences before you rely on them.
cat > amounts.py <<'EOF'
import re
import sys
from decimal import Decimal
SENTENCES = [
(1, "English", "Please send ₦1.5k to my landlord today."),
(2, "English", "The app charged me N1,500 twice."),
(3, "English", "I topped up 1500 naira by card and it failed."),
(4, "English", "Refund my 15k, the transfer never arrived."),
(5, "Pidgin", "Abeg, I don send N1,500 give my sister but she never see am."),
(6, "Pidgin", "Dem debit me 15k, but the money no reach her account."),
(7, "Yoruba", "Mo fi ₦1.5k ranṣẹ́ sí Bàbá mi, ṣùgbọ́n kò dé."),
(8, "Yoruba", "Mo san 1500 naira, ṣùgbọ́n owó náà kò dé."),
]
PATTERN = re.compile(r"(?:₦|N)\s?([0-9][0-9,]*(?:\.[0-9]+)?)\s?(k|K)?\b|\b([0-9][0-9,]*(?:\.[0-9]+)?)\s?(k|K|naira)\b")
def to_kobo(text):
"""Return the amount in integer kobo, or raise ValueError when the text is ambiguous."""
m = PATTERN.search(text)
if not m:
raise ValueError("no amount found")
number, k, number2, unit = m.groups()
number, k = (number, k) if number else (number2, unit if unit and unit.lower() == "k" else None)
if re.fullmatch(r"[0-9]{1,3}\.[0-9]{3}", number):
raise ValueError(f"{number!r} could be 1.5-style decimals or dot-grouped thousands")
value = Decimal(number.replace(",", ""))
if k:
value *= 1000
kobo = value * 100
if kobo != kobo.to_integral_value():
raise ValueError("fraction of a kobo")
return int(kobo)
if __name__ == "__main__":
if len(sys.argv) == 1:
for n, lang, s in SENTENCES:
print(f"{n} {lang:7} {to_kobo(s):>8} kobo {s}")
else:
got = {}
for line in open(sys.argv[1], encoding="utf-8"):
if line.strip():
n, naira = line.split()
got[int(n)] = int(Decimal(naira.replace(",", "")) * 100)
right = [n for n, _, s in SENTENCES if got.get(n) == to_kobo(s)]
wrong = [n for n, _, s in SENTENCES if n not in right]
print(f"{len(right)} of {len(SENTENCES)} match; check sentences {wrong}")
EOF
python3 amounts.py1 English 150000 kobo Please send ₦1.5k to my landlord today.
2 English 150000 kobo The app charged me N1,500 twice.
3 English 150000 kobo I topped up 1500 naira by card and it failed.
4 English 1500000 kobo Refund my 15k, the transfer never arrived.
5 Pidgin 150000 kobo Abeg, I don send N1,500 give my sister but she never see am.
6 Pidgin 1500000 kobo Dem debit me 15k, but the money no reach her account.
7 Yoruba 150000 kobo Mo fi ₦1.5k ranṣẹ́ sí Bàbá mi, ṣùgbọ́n kò dé.
8 Yoruba 150000 kobo Mo san 1500 naira, ṣùgbọ́n owó náà kò dé.Sentences 4 and 6 are ₦15,000 (1,500,000 kobo): “15k” is ten times “1.5k”. The others are ₦1,500 (150,000 kobo).
Now give the eight sentences to your assistant, ask for the amount in naira as a plain number for each, and save its answers as answers.txt, one number amount pair per line. To see how the scorer works before you use real answers, write a hand-made file in which every answer is right, then one in which sentence 6 is wrong. These two files are yours, not an assistant’s output.
printf '1 1500\n2 1500\n3 1500\n4 15000\n5 1500\n6 15000\n7 1500\n8 1500\n' > right.txt
printf '1 1500\n2 1500\n3 1500\n4 15000\n5 1500\n6 1500\n7 1500\n8 1500\n' > wrong6.txt
python3 amounts.py right.txt
python3 amounts.py wrong6.txt
python3 amounts.py answers.txt8 of 8 match; check sentences []
7 of 8 match; check sentences [6]The third command prints your assistant’s score, which you measure: it has no expected value here. Note which sentences it misses, and whether the misses cluster in one language or one format (15k, 1.5k, N1,500).
5. Name the control. In four lines, write what an examiner would ask about the rule from steps 1 and 2: its purpose, the cost of each error, who validates it, and what the fallback is when you switch it off. Compare your lines with the four ideas in the last section of the chapter.
Break it. The rule in step 1 counts in clock-hour buckets: 10:59 and 11:01 land in different hours, so two attempts two minutes apart escape it. Replace the buckets with a sliding window, and flag a customer when two card fundings are less than an hour apart.
python3 - <<'EOF'
import sqlite3, datetime as dt
db = sqlite3.connect("data/finance.sqlite")
by = {}
for cid, ts in db.execute("SELECT customer_id, created_at FROM transactions WHERE kind='funding_card' ORDER BY customer_id, created_at"):
by.setdefault(cid, []).append(dt.datetime.fromisoformat(ts))
sliding = set()
for cid, times in by.items():
for i in range(len(times) - 1):
if times[i + 1] - times[i] < dt.timedelta(hours=1):
sliding.add(cid)
bucket = {cid for (cid,) in db.execute("""SELECT customer_id FROM (SELECT customer_id, substr(created_at,1,13) hr, COUNT(*) n FROM transactions WHERE kind='funding_card' GROUP BY 1,2) WHERE n >= 2""")}
print(len(bucket), "flagged by clock-hour buckets;", len(sliding), "by a sliding 60 minutes;", len(sliding - bucket), "only by the sliding window;", len(bucket - sliding), "only by buckets")
EOFYou get 34 flagged by clock-hour buckets; 61 by a sliding 60 minutes; 27 only by the sliding window; 0 only by buckets. The same data and the same threshold give 34 or 61 flagged customers depending on how the window is drawn. Neither is the right answer. This is the point: a threshold, a window and a feature set are choices, and the model’s owner has to be able to say why they were made and what they cost.
Template
# Evaluation brief: <tool> for <job>
Author <name, role> · Signs <head of payments> · Date <date> · Test starts <date>
## The claim being tested
<One sentence: what the tool will do, against what, for whom.>
## Base rate and denominator
<How often the event you care about (a fraud, a failed payment) happens, out of how many cases, over what period.>
## The baseline it must beat
<What runs today and its numbers: flagged or routed, caught or succeeded, wrongly flagged or failed, and which customers.>
## The held-back test
Data: <cases the tool has not seen>. Size: <cases, and how many rare ones>.
Mode: <shadow, so no customer is affected>. Labels from: <source, and how late>.
## What each error costs
- False positive: <what happens to a good payment, and the cost>
- False negative: <what happens to a bad payment, and the cost>
## The human control that stays
<Who reviews, who can switch it off, the fallback when it is off.>
## Go or no-go bar (fixed before the test)
Go only if: <numbers>. No-go if: <numbers>. Otherwise: <extend or stop>.
## What this test cannot see
<One way it could mislead us, and what result would show it.> WORKED EXAMPLE
At a real company a PM or the head of risk writes this brief, and the head of payments signs it before the test starts. Here Ese, who leads risk at the 200-person gateway, writes it for a vendor’s fraud score that would replace the weekend velocity rule.
Claim: the score catches at least as many frauds as the rule while flagging fewer good merchants.
Base rate: the chapter’s hypothetical of 1 fraud in 500 payments, so 10,000 payments hold 20 frauds.
Baseline: the lab’s wider rule flagged 66 of 2,000 customers (3.3%). Merchants are 138 customers (6.9%) but 31 of the 66 flagged (47%): 22.5% of merchants against 1.9% of individuals. The lab data has no fraud labels, so these figures give the rule’s flag rate and not its accuracy. The gateway’s own dispute labels will supply that, weeks late.
Test: four weeks in shadow mode, no decision changed, at least 10,000 payments. With about 20 frauds, one catch more or fewer moves recall by 5 points, so this is a screen and not proof.
Costs: a false positive holds a good payment and risks a merchant. A false negative is the loss plus a dispute. Finance supplies both in ₦ before the test; with no figure, the answer is no-go.
Control: the score never declines alone. The middle band goes to a person, and the rule stays as the fallback and the off switch.
Bar: go only if recall is no lower than the rule’s on the same payments and fewer than 22.5% of merchants are flagged.
Could be wrong: late labels may hide frauds the score caught.
Now you
You are the PM for payments at Ojaline, the marketplace with its own seller wallet. A vendor says its smart router lifts the card success rate and wants live traffic from next month. Write the brief that you, as author, would hand to the head of payments, who must sign it before any test starts. Use the chapter’s routing arithmetic: provider A succeeded on 46 of its last 50 payments (92%) and provider B on 44 of 50 (88%), a gap of four points against a noise of about 6.0 points for a difference between two rates. In the lab data 400 card fundings failed with card_declined, which says the card failed and not the processor. State your own assumptions for Ojaline’s card volume and the cost of a failed checkout, and label them as assumptions. The brief supports one decision: whether the head of payments lets the vendor route a small share of live traffic.
Self-check
Terfa wants the gateway's support bot to answer 'why did my payment fail?' for merchants. The failure reason is in the payment record, but Terfa's first version gives the model only the payment's amount, time and status and lets it explain. Ese asks for the design to be settled before launch. In Owoleaf's lab data, a failed ₦150,803 transfer needed the balance and the tier to explain it, and neither was on the row.
- PAPER Statistical fraud detection: a review Richard J. Bolton and David J. Hand, 2002
The standard introduction to the problem: the difference between prevention and detection, supervised and unsupervised methods, and why labels are scarce. Read the first three sections; skip the application areas, which have dated. Read: Statistical Science 17(3): sections 1 to 3.
- DOC Artificial intelligence in UK financial services - 2024 Bank of England and Financial Conduct Authority, 2024
A survey of 118 UK firms on how widely AI is used, how material the uses are and how well firms understand them. Read the adoption and materiality sections and check the figures this chapter quotes. It describes the UK, not Nigeria.
- DOC The Financial Stability Implications of Artificial Intelligence Financial Stability Board, 2024
The international standard-setters' view of where AI could amplify risk: concentration in third parties, correlation, cyber and model risk. Read the vulnerabilities section. It is an analytical report, not a rule.
- DOC Chatbots in consumer finance Consumer Financial Protection Bureau, 2023
A US regulator's account of what goes wrong when customers meet a bot instead of a person, with the complaints it drew on. Read for the failure patterns. It is a US issue spotlight, not Nigerian law, and commentators dispute some of its evidence.
- DOC SR 11-7: Guidance on Model Risk Management Board of Governors of the Federal Reserve System, 2011
The text that made development, validation and governance the standard shape of model risk management. The Federal Reserve has since superseded it with SR 26-2, so read the current letter too, and use this one for the ideas.
- DOC SR 26-2: Revised Guidance on Model Risk Management Board of Governors of the Federal Reserve System, 2026
The current US supervisory letter on model risk, issued on 17 April 2026, which supersedes SR 11-7. Read its scope section first: summaries disagree on how it treats generative AI, and it is guidance for US banks, not Nigerian law.
- DOC Hyperswitch: auth rate based routing Juspay (Hyperswitch documentation)
A vendor's own description of success-rate routing, as one concrete design. Read it to see how the strategy is configured. Treat any improvement figure as the vendor's claim.
- DOC A primer on machine learning for fraud detection Stripe (vendor)
A vendor's explanation of scoring, precision and recall, and how thresholds are chosen. Read the sections on precision and recall to practise the arithmetic; skip the product pages. Labelled as a vendor source.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.