Rule-based fraud detection has a predictable failure mode: fraud teams add rules in response to known attacks, fraudsters learn the rules, and new attacks bypass them for 3–5 days before the rules catch up. A London FinTech SaaS with 85,000 active users was in exactly this position: 100+ manual rules, a 4.2% false positive rate that blocked legitimate customers, and new fraud schemes appearing faster than the rules team could respond. The answer was a two-layer ML system that detects anomalies rather than matching patterns.
Layer 1: Isolation Forest for Transactional Features
Isolation Forest is an unsupervised anomaly detection algorithm that works by randomly partitioning data. Normal transactions require many partitions to isolate; anomalous transactions — those with unusual combinations of features — are isolated in very few steps. The fewer steps needed to isolate a data point, the higher its anomaly score.
For each transaction, we compute a 48-dimensional feature vector:
- **Velocity features:** transactions in last 1h / 6h / 24h, spend in last 1h / 24h
- **Geographic features:** distance from last transaction, geo-jump flag (transaction in two cities within impossible travel time)
- **Device features:** new device flag, device fingerprint match score, OS/browser consistency
- **Behavioural features:** time since last login, session age at transaction, typical transaction time (deviation from historical hour distribution)
- **Amount features:** deviation from 30-day average, percentile rank within merchant category
Isolation Forest produces an anomaly score between 0 and 1. Scores above 0.7 trigger Layer 2 analysis rather than an immediate decision — this separation is what allows the system to maintain a low false positive rate.
Layer 2: LSTM Autoencoder for Behavioural Sequences
The LSTM Autoencoder captures something Isolation Forest cannot: the sequence of actions leading up to a transaction. Normal account behaviour has structure — users typically log in, browse, add items, checkout. Fraudsters, using stolen credentials, exhibit different sequences: login → immediate high-value transaction, or login → check balance → transfer → logout in under 90 seconds.
An autoencoder is trained to reconstruct normal sequences. When given an abnormal sequence, the reconstruction error is high — this is the anomaly signal. The LSTM processes the last 30 events per account (logins, searches, page views, failed payments, password changes) and returns a reconstruction error score.
The two scores are combined: `final_score = 0.6 × isolation_score + 0.4 × lstm_error`. This weighted combination reflects that behavioural sequence analysis is somewhat less reliable for very new accounts (limited history), where we downweight Layer 2 accordingly.
Decision thresholds:
- `final_score < 0.45` → Allow (automated)
- `0.45 ≤ final_score < 0.72` → Challenge (push 2FA to user's registered device)
- `final_score ≥ 0.72` → Block + freeze + alert fraud team
FCA Compliance: Explainability and the Right to Appeal
Under FCA regulations, any automated decision that significantly affects a customer — including blocking a transaction — must be explainable, and customers must have a right of review. This is where most fraud ML systems fail the regulatory test: a black-box model that simply outputs 'blocked' doesn't satisfy FCA or GDPR Article 22 requirements.
We use SHAP (SHapley Additive exPlanations) to produce a human-readable explanation for every blocked transaction. The customer-facing message: 'This transaction was blocked as a security precaution. Main reasons: login from a new device (38% of risk score), transaction location differs from your usual area (33%), amount is 4.8× your typical transaction (29%).'
The fraud team sees the full SHAP breakdown: all 48 feature contributions, the two layer scores, and the combined score. The appeals dashboard allows a customer to explain the transaction → a human fraud analyst reviews the SHAP evidence + customer explanation → override if justified. Override decisions feed back into the training data with a 'false positive' label, improving the model over time.
For the FCA audit: every decision, its SHAP explanation, and any human review is stored in an immutable audit log. GDPR Data Subject Access Requests can be fulfilled by extracting the relevant decision records without exposing model weights or other users' data.
Kafka Real-Time Pipeline and Results
The full transaction scoring pipeline runs via Apache Kafka: transaction event → Kafka topic → scoring service → decision service → three consumers (payment processor, fraud alert system, audit log). End-to-end latency: 180 milliseconds at the 99th percentile. Payment processors typically allow 500ms for fraud checks — our system uses 36% of that budget.
Results after 6 months in production for the 85K-user FinTech:
- False positive rate: 4.2% (rule-based) → 0.8% (ML system) — an 81% reduction
- Fraud loss: −89% in the first 6 months
- FCA audit: passed on first submission; examiner specifically noted the quality of the explainability dashboard
- New fraud scheme detection: average detection time 14 minutes (vs. 3–5 days for rule updates)
- Customer complaints about legitimate transactions blocked: −76%
The system retrains weekly on the previous month's data. Model performance is monitored via a PSI (Population Stability Index) dashboard — when PSI exceeds 0.2 on any feature group, the on-call data scientist is alerted. In 6 months, two full retrains were triggered by shifts in fraud patterns.
Related Codeworth Services
Need Help with Implementation?
The Codeworth team is ready to implement these ideas in your project. Free consultation.
Discuss the ProjectCodeworth team specialist.