Recipe: Transaction fraud check
Classify transaction descriptions in real time using a lightweight heuristic model. This recipe scores merchant strings against known fraud patterns — crypto tumbler names, gift card resellers, and high-risk MCC aliases — then flags transactions exceeding a tunable threshold for manual review.
PATTERNS = {
"tumbler": 0.9, "mixer": 0.85,
"giftcard": 0.7, "prepaid": 0.6,
"crypto.com": 0.3, "binance": 0.3,
}
def score(desc: str) -> float:
d = desc.lower()
return max(
(w for p, w in PATTERNS.items() if p in d),
default=0.0,
)
def flag(tx: dict, threshold=0.6) -> bool:
return score(tx["description"]) >= threshold