Sub topic 12
Behavioral and Machine-Learning Detection Alongside Rules
This chapter assumes you know how a scenario turns a typology into a rule, how segments and thresholds shape what fires, and how a rule evaluation creates an alert record. Here you will see how behavioral and machine-learning detection fits next to those rules.
Why rules alone leave gaps
A rule fires only when its conditions are met. The structuring scenario from earlier needs min_count deposits between floor and ceiling inside lookback_days. A customer who makes two deposits, or deposits 7,900, never triggers it. Launderers who learn typical thresholds can stay just below them.
Rules also treat every customer in a segment alike. A deposit of 9,000 may be routine for one retail customer and a sharp change for another.
Behavioral and machine-learning detection addresses both problems. It does not replace rules. It adds a second source of alerts.
Behavioral detection: comparing a customer to a baseline
Behavioral detection asks whether activity is unusual for this customer or for their peer group. A peer group is a set of customers in the same segment with similar profiles, as covered in the segmentation chapter.
A common method is a deviation score. You compute the mean and standard deviation of a customer's past monthly activity, then measure how far the current month sits from that mean.
from statistics import mean, stdev
def deviation_score(history, current):
"""How many standard deviations the current value is above the
customer's own historical mean."""
if len(history) < 3:
return 0.0 # too little history to form a baseline
spread = stdev(history)
if spread == 0:
return 0.0
return (current - mean(history)) / spread
monthly_cash = [1200, 1500, 1100, 1400, 1300]
print(round(deviation_score(monthly_cash, 9800), 1)) # 36.9A threshold on this score, for example 3.0, becomes a scenario parameter like any other. The rule structure is the same. The difference is that the number being compared is derived from the customer's own history instead of a fixed amount.
Machine-learning detection
A machine-learning model goes further. It learns from data how combinations of features relate to outcomes. Features are measurable inputs such as transaction counts, total amounts, share of cash, number of countries involved, and account age.
There are two broad approaches:
- Supervised models learn from past alerts labeled by analysts, for example "escalated" or "closed". They predict how likely a new pattern is to be escalated. They need enough labeled examples, and the labels reflect past analyst decisions, including mistakes.
- Unsupervised models look for outliers or clusters without labels. They flag customers whose feature values differ from the rest of their peer group. They can surface unknown patterns, but a flag needs interpretation.
Models can be used in two ways. They can generate alerts directly, using a score threshold. They can also score alerts that rules already created, which feeds the prioritization step.
flowchart TDReplace the sketch above with the diagram below, which shows both paths.
Trade-offs to weigh
| Aspect | Rules | Behavioral or ML |
|---|---|---|
| Explainability | Easy: the alert names the condition met | Harder: needs reason codes or feature contributions |
| Coverage | Only known typologies | Can catch unusual patterns |
| Data needs | Low | Needs history, and labels if supervised |
| Validation effort | Test thresholds | Test data quality, drift and bias as well |
Regulators and model risk teams expect any alert to be explainable to an analyst and to an examiner. For that reason, many programs keep rules for known typologies and add models where rules are weak.
Common errors
- Treating a high score as proof. A score is a reason to look, not a finding.
- Training on analyst labels without noticing that scenarios which never alerted have no labels at all.
- Skipping a baseline check. Customers with little history produce unstable scores, which is why the code above returns 0.0 for them.
- Letting a model drift. Customer behavior changes, so scores must be monitored and revalidated, which the tuning chapter covers.
Exercise
A customer's monthly cash deposits were 1,000, 1,100, 900 and 1,000. This month they deposit 4,500, which is below every fixed rule threshold in their segment. Which kind of detection could still alert, and why?
Show answer
Behavioral detection. The customer's own baseline is about 1,000 with a small spread, so 4,500 gives a very high deviation score even though it is under the segment's fixed amount thresholds. A rule with a fixed amount would miss it.