KatInterview

Real-Time Transaction Fraud Scoring System

Machine LearningModel answer
HardModel answerMachine Learningfraud-detectionreal-time-mlimbalanced-classification

Last updated

Design a complete ML pipeline to classify payment fraud in under 100ms, addressing delayed labels, streaming features, class imbalance, and cost-aware decisions.

Context

You're building a machine learning system to detect fraudulent transactions for a payment platform that handles checkout flows for thousands of online merchants. The platform processes roughly 500,000 transactions daily. Each time a customer completes a purchase, your model must return a risk score within 100 milliseconds to decide one of three outcomes:

  • Accept the transaction immediately
  • Challenge with additional verification (SMS code, 3D Secure authentication)
  • Block the transaction outright

Operating Environment

  • Volume: Peak load reaches 500 transactions per second; approximately 20 million monthly transactions
  • Fraud prevalence: Around 0.15% of transactions are eventually confirmed as fraudulent
  • Feedback latency: Chargebacks and fraud confirmations typically surface 30–90 days after the original purchase
  • Data sources: Transaction details (amount, currency, addresses, IP, device ID), customer transaction history, merchant risk profile, payment instrument metadata

Your Task

Design the end-to-end fraud detection system. Address each of the following:

1. Training Labels Under Delayed Feedback

How do you define the fraud label when ground truth arrives months later? What strategy handles transactions that haven't matured yet, and how do you account for fraud that's never reported?

2. Feature Design for Low-Latency Scoring

Propose 4–6 strong predictive features spanning customer behavior, transaction velocity, and entity relationships. Explain how you compute time-windowed aggregations (like "transactions in the last hour") at serving time while avoiding temporal leakage during training.

3. Model Selection and Training with Extreme Imbalance

Recommend a model architecture considering both the 100ms latency budget and the 0.15% positive class rate. How do you train it without distorting probability estimates?

4. Offline Evaluation and Decision Boundaries

Which metrics should you track, and why are standard accuracy or AUC misleading here? How do you determine the two score thresholds that separate accept / challenge / block decisions?

5. Production Monitoring Before Labels Arrive

Fraud patterns shift constantly, but labels lag by months. What signals can you monitor to detect model degradation, distribution shift, or adversarial adaptation in near real-time?

Hints

Hint 1

Think about which transactions are safe to include in your training set based on label maturity time

Hint 2

Velocity features are powerful but require precomputed streaming aggregates with strict time boundaries

Hint 3

Calibrated probabilities enable threshold selection based on business costs, not just ranking performance