Real-Time Risk Scoring for Account Linking and Payments
Machine LearningModel answerLast updated
Design an ML pipeline that scores bank-link attempts, identity checks, and transactions in real time, mapping risk to graded actions while keeping false positives low.
You are building the risk layer for a financial data-connectivity platform. Users connect their bank accounts to third-party apps, verify who they are, and then move or expose financial data. Bad actors try to abuse each of these stages.
Design an ML system that spots risky users, account connections, and transactions close to real time. The output should drive one of four graded responses: allow, step-up verification, manual review, or block. Legitimate users must almost never be interrupted, so the false-positive rate has to stay very low.
Your design should cover:
- Which fraud scenarios you target, and how you frame the prediction problem.
- Data sources and how you construct labels.
- Features, including relational or graph-based signals.
- Modeling approach.
- The offline training pipeline and the online serving architecture.
- Offline and online evaluation.
- Delayed labels, class imbalance, adversarial adaptation, privacy and compliance, and monitoring.
Assumptions for sizing
- Millions of end users, thousands of bank and partner integrations.
- Tens of millions of link attempts and transaction events per day, with thousands of requests per second at peak.
- The user flow waits on the decision, so p99 scoring latency should be tens to low hundreds of milliseconds.
- Confirmed fraud (chargebacks, partner reports, account closures) shows up days to weeks later. Positives are well under 1% of events, and some fraud is never reported.
- Attackers probe the system, adapt, reuse devices, IPs, and accounts, and work in rings.
- Financial PII is involved. Decisions may need reason codes and must not cause disparate impact on protected groups.
State any clarifying questions you would ask (decision point, available labels, cost of a miss vs. a false block, regulatory limits) and the assumptions you make in their absence.
Hints
Hint 1
Start by picking one decision point (for example the link attempt) and defining the target, the action thresholds, and the cost of each error type before discussing models.
Hint 2
Labels mature slowly and are biased by past decisions: think about maturation windows, excluding immature negatives, time-based splits, and how blocked traffic never reveals its true label.
Hint 3
Combine cheap deterministic rules, a supervised gradient-boosted scorer on velocity/device/graph features, and an offline-computed graph signal served from a feature store, with a safe fallback if any dependency is slow.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Framing and clarifying assumptions
I would first confirm the decision point, the available labels, and the relative costs. Absent answers, I assume the first deployment scores the bank-link attempt and later extends to identity verification and transactions with the same platform.
- Target: probability that an event leads to confirmed fraud or abuse within a fixed window (for example 30 to 60 days). I'd train separate heads or models per stage, since signals and base rates differ.
- Scenarios: account takeover, synthetic or stolen identities, mule accounts and cash-out rings, credential stuffing and link-probing, and anomalous post-link transaction behavior.
- Actions: the model outputs a calibrated probability. Thresholds are set from the cost matrix (loss from a miss, friction from a false stop, cost of a review). Typical bands: low risk allow, middle step-up, narrow high band to manual review (capacity-limited), extreme or rule-confirmed block.
2. Data and labels
Sources: link and session events, identity verification results, device and network fingerprints, transaction streams, partner and bank responses, historical case outcomes from analysts, chargebacks, and partner fraud reports.
Label construction:
- Positive: confirmed fraud via chargeback, partner report, account closure for fraud, or analyst confirmation.
- Negative: events that survive a maturation window (say 45 days) with no fraud signal. Younger events are excluded or marked "unknown", never treated as clean.
- Analyst decisions are higher quality but biased toward what the system already flagged.
Problems to address honestly:
- Delay: train on matured data, and use fast proxy labels (step-up failures, early account closures) as auxiliary targets or for quick drift detection.
- Selection bias: blocked events never reveal their outcome. Keep a small randomized holdout (for example 0.5 to 1% of low-risk traffic allowed without extra friction, with strict loss caps) and use inverse-propensity weighting or reject inference.
- Unreported fraud: treat negatives as noisy; prefer robust losses and evaluate on cleaner subsets (reviewed cases).
3. Features
All features must be computable as of event time to avoid leakage.
- Identity/account: account age, verification outcomes, name/email/phone consistency, email and phone reputation.
- Velocity: link attempts, failures, and new institutions per user, device, IP, and email over 1 min, 1 h, 1 d, 7 d windows.
- Device/network: device fingerprint age, emulator or VPN/proxy flags, ASN, geo distance from prior sessions, impossible travel.
- Behavioral: typing and navigation timing, session anomalies, retries.
- Transaction: amount versus personal baseline, new payee, time of day, balance patterns, merchant category.
- Relational/graph: build a graph of users, devices, IPs, accounts, and emails. Features include shared-entity counts, connected-component size, proximity to known-fraud nodes, and community-level fraud rate. Compute heavy graph features (label propagation, embeddings) in batch every few hours and serve them from the feature store; compute cheap one-hop counts in streaming.
4. Modeling
- Primary scorer: gradient-boosted trees. They handle mixed, sparse tabular data, tolerate missing values, are fast (sub-10 ms), and are explainable with SHAP for reason codes.
- Rules layer: deterministic blocks for known-bad entities, sanctions or consortium hits, and hard velocity caps. Rules respond within minutes to new attacks, before a model can be retrained.
- Unsupervised/graph signals: anomaly scores (isolation forest, autoencoder) and graph embeddings as features into the main model, which helps with novel patterns that have no labels yet.
- Imbalance: prefer class weights or mild downsampling of negatives with later recalibration (isotonic or Platt) over heavy synthetic oversampling. Calibrated probabilities are essential since thresholds map to costs.
- Later options: a sequence model over user event history or a GNN once the simple stack is solid. These add serving complexity, so justify them with measured lift.
5. Pipelines and serving
Offline: event logs land in a warehouse; a point-in-time-correct feature store builds training sets; split by time (train on older, validate on newer) with a gap equal to the maturation window; retrain on a schedule (weekly) plus on drift triggers; register and version models.
Online:
- Request hits the risk service with event context.
- Fetch precomputed features from a low-latency store (Redis or similar) and merge streaming counters (Kafka/Flink updating windowed aggregates).
- Run rules, then the model; map the score to an action and attach reason codes.
- Log the full feature vector, score, and decision for training and audit.
Budget: roughly 10 to 20 ms feature fetch, under 10 ms inference, and the rest as headroom. Thousands of QPS is served by a stateless, horizontally scaled service. If the feature store or model times out, fall back to a rules-only or simplified model with a conservative default (typically step-up rather than block), and alert.
6. Evaluation
Offline: PR-AUC and recall at fixed low false-positive rates (for example recall at 0.1% FPR), not ROC-AUC alone. Evaluate on a time-held-out set, per segment (institution, geography, new vs. old users), and with cost-weighted loss. Check calibration.
Online: shadow mode first (score, log, do not act), then canary at a few percent, then ramp. Track fraud loss, step-up rate, step-up pass rate for good users, review precision, link conversion, and support complaints. Use the randomized holdout for unbiased lift, and A/B or interleaved tests for policy changes.
7. Hard realities
- Adversaries: attackers probe thresholds. Avoid exposing scores or precise reasons to clients, add randomization near thresholds, use features that are costly to fake (device and graph history), retrain often, and keep a fast rules path.
- Drift and monitoring: monitor feature distributions (PSI), score distribution, approval and step-up rates, label arrival, and proxy-label performance. Alert on shifts; trigger retraining or rollback.
- Privacy and compliance: minimize PII, tokenize and encrypt, enforce access controls and retention limits, and avoid protected attributes and close proxies. Run fairness checks (error rates across groups), and keep reason codes plus a full audit log of model version and inputs for each decision.
- Feedback loops: the model changes who gets blocked, which changes future labels. The randomized holdout and periodic re-labeling of reviewed samples mitigate this.
Trade-offs
- Rules are fast and transparent but brittle; ML generalizes but lags on new attacks; graph signals catch rings but add pipeline cost and staleness.
- Lower thresholds catch more fraud but increase friction; set them from the cost matrix and review capacity.
- A more complex model (GNN, sequences) should only be adopted if it beats the tuned tree model by a measurable margin at the target FPR.
Common mistakes
- Treating unmatured events as negatives.
- Random train/test splits that leak future information.
- Optimizing accuracy or ROC-AUC on a 0.1% base rate.
- Ignoring selection bias from past blocking decisions.
- Using features at training time that are not available at serving time.
- No fallback path when a dependency is slow.