Sub topic 13
Tuning Thresholds and Measuring Alert Quality
Prerequisites
This chapter assumes you have read the earlier chapters on scenarios, thresholds and parameters, alert generation, and alert review. You should know that a scenario's behavior is set by parameters such as lookback_days, min_count, floor and ceiling. You should also know that analysts close each alert with a disposition, such as closed or escalated. The code is plain Python and uses only the standard library.
Why thresholds need tuning
A monitoring scenario never has the right parameters on day one. Initial values come from a typology, regulator guidance, or a vendor default. They are guesses about how customers behave.
The guesses fail in two directions:
- Too sensitive. The scenario fires on ordinary customers. Analysts spend their time closing alerts that were never suspicious. Real cases sit in a queue behind noise, and reviewers stop paying attention.
- Too loose. The scenario misses behavior it was written to catch. Nobody sees this failure, because a missed pattern produces no alert.
Tuning is the controlled process of changing parameters to find a better balance, then proving the change did what you intended. The main difficulty is that you can easily measure the first failure and can only estimate the second.
Metrics that describe alert quality
No single number says whether a scenario is good. Teams track a small set and read them together.
| Metric | Definition | What it tells you | Main weakness |
|---|---|---|---|
| Alert volume | Alerts per scenario per period | Workload and capacity | Says nothing about quality |
| Alert precision | Escalated alerts divided by reviewed alerts | How much analyst effort produces something useful | Depends on analyst judgment and on how "escalated" is defined |
| Case or report conversion | Share of alerts that become cases or suspicious activity reports | A stronger, later signal of value | Slow, because investigations take weeks |
| Recall (detection rate) | Suspicious activity caught divided by all suspicious activity present | Whether the rule misses things | You never know the true denominator |
| Time to disposition | Days from alert creation to closure | Backlog and process health | A fast closure can be a careless one |
The precision calculation from the earlier chapters is:
def alert_precision(dispositions):
"""Share of reviewed alerts that analysts escalated."""
if not dispositions:
return 0.0
escalated = sum(1 for d in dispositions if d == "escalated")
return escalated / len(dispositions)
print(alert_precision(["closed", "closed", "escalated", "closed"])) # 0.25Low precision is normal in transaction monitoring. Many programs see well under 10 percent of alerts escalated for some scenarios. A low value is a prompt to investigate. It is not proof of a problem, because a scenario that protects against a high-severity typology may be worth keeping even with low precision.
Why recall is hard
Precision uses only data you already have: alerts and their dispositions. Recall needs to know how much suspicious activity existed, including activity that never alerted. That population is unobserved by definition.
Teams estimate it indirectly:
- Known cases. Take customers later confirmed as suspicious from outside sources, such as law enforcement requests, adverse media, or investigations started by a different scenario. Check whether your scenario would have alerted on them.
- Below-the-line testing. Sample activity that fell just below the threshold and have analysts review it as if it had alerted.
- Synthetic scenarios. Inject transactions built to match a typology and confirm the rule fires.
Above-the-line and below-the-line testing
Tuning needs evidence on both sides of the threshold.
- Above the line means the alerts the current parameters already produce. Review a sample, or use existing dispositions, to see how many are useful. This tells you whether you could raise the threshold.
- Below the line means activity that the current parameters did not alert on, for example customers with two qualifying deposits when
min_countis 3. Reviewing a sample tells you whether lowering the threshold would find real activity or just add noise.
If you only review above the line, you can only ever move thresholds up, and you will drift into missing activity without noticing. Below-the-line sampling is the check on that drift. Segmentation matters here too. Test and tune per segment, because one retail threshold applied to a business customer produces misleading results.
The tuning loop
The important property is that candidate parameters run against historical data first. You do not change production thresholds to see what happens. You replay stored transactions through the rule with the new values and compare the output against the baseline.
A worked example: sweeping `min_count`
Suppose the structuring scenario uses min_count. You have a labeled history. For each customer, you know the largest number of qualifying deposits they made inside any lookback window, and whether a later review found the activity suspicious. The labels come from a mix of past alerts and a below-the-line sample.
The sweep re-evaluates the rule at each candidate value:
def sweep_min_count(samples, candidates):
"""samples: list of (max_hits_in_window, label) with label 'suspicious' or 'normal'.
Returns one row per candidate min_count."""
total_suspicious = sum(1 for _, label in samples if label == "suspicious")
rows = []
for min_count in candidates:
fired = [label for hits, label in samples if hits >= min_count]
true_hits = sum(1 for label in fired if label == "suspicious")
precision = true_hits / len(fired) if fired else 0.0
recall = true_hits / total_suspicious if total_suspicious else 0.0
rows.append((min_count, len(fired), precision, recall))
return rows
samples = (
[(2, "normal")] * 10 + [(3, "normal")] * 6
+ [(4, "normal")] * 2 + [(5, "normal")] * 1
+ [(2, "suspicious")] * 1 + [(3, "suspicious")] * 2
+ [(4, "suspicious")] * 2 + [(5, "suspicious")] * 3
)
print("min_count alerts precision recall")
for min_count, alerts, precision, recall in sweep_min_count(samples, [2, 3, 4, 5]):
print(f"{min_count} {alerts} {precision:.3f} {recall:.3f}")Running it prints:
min_count alerts precision recall
2 27 0.296 1.000
3 16 0.438 0.875
4 8 0.625 0.625
5 4 0.750 0.375Reading the table:
- Raising
min_countfrom 2 to 3 removes 11 alerts and loses one suspicious customer. That is usually a good trade. - Going from 3 to 4 halves the volume again, but recall falls from 0.875 to 0.625. Two of the eight known suspicious customers would no longer alert.
- At 5 precision looks best, but only three of eight suspicious customers are caught.
The data does not pick a value for you. It shows the cost of each choice. The decision depends on how severe the typology is, how many alerts the team can review, and whether other scenarios cover the same behavior. A common outcome is to keep min_count at 3 for a high-risk segment and use 4 for a low-risk one.
Common errors
- Tuning to hit a volume target. Cutting alerts until the queue is manageable reduces workload but may remove detection. Volume is a constraint to plan around, not a goal to optimize.
- Treating disposition as ground truth. An analyst closing an alert means the analyst saw no suspicion, not that none existed. Inconsistent or rushed reviews corrupt the labels. Sample closed alerts for quality assurance before you rely on them.
- Ignoring segments. An overall precision of 12 percent can hide a segment at 40 percent and another at 1 percent. Report by scenario and by segment.
- Changing several parameters at once. If you alter
min_count,floorandlookback_daystogether, you cannot tell which change caused the difference. Change one at a time, or test combinations systematically. - Forgetting duplicates and consolidation. Precision measured per alert is distorted if one customer generates many alerts that are grouped into one case. Measure at the level where analysts do their work, and state which one you used.
- Not recording why. A threshold with no documented rationale cannot be defended to an examiner or reproduced later.
Validation and governance
Tuning changes how the system behaves, so it falls under change management and model risk expectations. The details differ by institution and jurisdiction, but a defensible process usually includes:
- A written rationale for each parameter, linked to the typology or risk assessment.
- Recorded test results: the data period, the candidate values, and the metrics compared.
- Approval by someone independent of the person who proposed the change.
- Version control of parameters, so you can state which values were live on a given date.
- Periodic independent validation covering data completeness, whether scenarios implement their intended logic, and whether thresholds remain appropriate.
Data checks belong here as well. If a feed drops a transaction type or a profile field is blank for a segment, alert volumes change for reasons unrelated to thresholds. Confirm input completeness before attributing a change in precision or volume to tuning.
Exercise
A scenario produced 80 alerts last quarter. Analysts escalated 6 and closed 74. What is the alert precision, and what two further checks would you run before raising the threshold to cut volume?
Show answer
Precision is 6 / 80 = 0.075, or 7.5 percent. Before raising the threshold, first sample below the line to see whether lowering or keeping the threshold would find real suspicious activity, and estimate the recall you would lose, for example against known cases. Second, break the results down by customer segment and review a sample of the closed alerts for quality, so you know the dispositions are reliable and that the low precision is not concentrated in one segment.
Exercise
Using the sweep results above (mincount 3 gives 16 alerts, precision 0.438, recall 0.875; mincount 4 gives 8 alerts, precision 0.625, recall 0.625), the team can review only 10 alerts of this scenario in a period. Which value fits capacity, and what should you tell the approver?
Show answer
mincount 4 fits capacity, with 8 alerts against a limit of 10, while mincount 3 would produce 16. The approver should be told that the change lowers recall from 0.875 to 0.625, so 2 of the 8 known suspicious customers would no longer alert. Options to present are keeping 3 for the higher-risk segment, adding capacity, or covering the lost cases with another scenario. The result should be confirmed on held-out data and documented.