Skip to main content

Risk-based testing for ML systems

Why This Matters

There is always more to test than time to test it. Risk-based testing decides where the effort goes: to what is most likely to go wrong and would hurt most if it did. For ML systems this is not optional: most AI regulation, including the EU AI Act, demands a risk-based approach. And the risks are partly new ones, so you need a way to find them.

What you will learn

  • How risk-based testing applies to ML systems
  • The three risk categories along the ML workflow: development, input data and model
  • How to build a risk table for an ML system and derive the test focus from it

Syllabus: AI-4.3.2.

Risk-based testing, briefly

A risk is something that may go wrong, with a likelihood and an impact. Risk-based testing identifies the risks, rates them, and lets the rating decide what to test, how thoroughly, and in which order. High likelihood and high impact gets the most testing.

This applies to every system. For ML systems two things are different: regulators expect it (the EU AI Act requires a risk management system for high-risk AI, lesson 4), and the list of what can go wrong is longer.

Three categories along the workflow

The syllabus groups ML risks by where they arise in the ML workflow:

CategoryExamples of risksCovered in
DevelopmentSub-optimal algorithm choice; a poor model-development process; a framework with security vulnerabilities. Mostly project risks.Module 8
Input dataBiased data; unrepresentative data; poisoned data; defects in the data pipelineModule 6
ModelNot meeting the performance criteria; overfitting; susceptibility to adversarial examplesModule 7

Each later module starts with a table of risks and the test approach that mitigates each one. This lesson is about using such tables.

An alternative way to find risks: go through the quality characteristics of ISO/IEC 25059 (lesson 6) and ask, for each one, what could go wrong here. What if it cannot explain a decision (transparency)? What if an operator cannot stop it (intervenability)? What if it fails on noisy input (robustness)? This catches risks that a workflow view misses, such as missing human oversight.

A worked risk table: a fraud-detection model

A bank flags card transactions as possibly fraudulent. Flagged transactions are blocked until the customer confirms them.

#RiskCategoryLikelihoodImpactLevelTest focus
1Fraud patterns change; the model misses new types of fraudModel (drift)HighHighHighDrift testing on weekly labelled samples; alert threshold on recall (lesson 47)
2Too many legitimate transactions blocked, customers leaveModel (performance)MediumHighHighPrecision on a representative test set, per customer segment; acceptance criteria with confidence levels (lesson 44)
3Training data contains few transactions from abroad; travellers are blocked more oftenInput data (representativeness)MediumMediumMediumCompare the training distribution with production; precision per country (lesson 37)
4Fraud labels are wrong (disputed transactions marked as fraud)Input data (labels)MediumMediumMediumLabel review on a sample with multiple annotators (lesson 39)
5Model flags customers of certain nationalities or ages more oftenInput data / model (bias)MediumHighHighDisparate impact analysis with counterfactual pairs (lesson 35)
6Fraudsters learn to split payments just below a patternModel (adversarial)MediumHighHighAdversarial testing around the decision boundary (lesson 45)
7Feature pipeline in production calculates “transactions in the last hour” differently than in trainingInput data (pipeline)LowHighMediumBack-to-back test of the training and production pipeline (lesson 36)
8Wrong data split: transactions of one customer in training and testDevelopmentLowMediumLowReview of the data allocation (lesson 51)

How to read it:

  • Four risks are high (1, 2, 5, 6). They get the most effort, are tested first, and their tests run on every model version.
  • Every risk has a test approach that fits it: drift needs monitoring, bias needs counterfactual testing, adversarial risk needs adversarial testing. A generic “run the regression suite” mitigates none of them well.
  • Some risks are only testable after release (1, partly 3). The risk table is also a monitoring plan.
  • The ratings are judgements, made with the business, data scientists and, for 5, legal. Writing them down makes them discussable.

Exercise

A hospital uses a model that predicts which emergency-department patients should be seen first (triage). Build a risk table with at least five risks: at least one from each category (development, input data, model), with likelihood, impact and test focus. Which risk would you test first?

Show suggested answer
#RiskCategoryLITest focus
1Seriously ill patients are given low priority (false negatives)ModelMediumVery highRecall on the “urgent” class, with a high confidence level; boundary testing around the priority threshold
2Training data comes from one hospital; patient mix elsewhere differsInput dataHighHighRepresentativeness testing against the target hospital’s patient data; performance per subgroup
3Model under-prioritises women or older patients because historic triage didInput dataMediumVery highTesting for bias: performance and priority per group; counterfactual pairs
4Labels (historic triage decisions) are inconsistent between nursesInput dataHighHighMultiple annotation of a sample by experienced nurses; inter-annotator agreement
5Missing vital signs make the model fail or give a default priorityModelMediumHighRobustness testing with missing and invalid values; output boundaries
6The model version deployed is not the one validatedDevelopmentLowVery highConfiguration management review; smoke test of the deployed version
7Nurses cannot override the priority quicklySystem (controllability)LowVery highUsability and controllability test of the override

Test risk 1 first: patient harm is the highest impact, and it is the core function. Risks 3 and 7 are close: risk 3 is the one that regulators and patients will ask about, and 7 is cheap to test and decisive for safety.

Exam-style questions

Quiz

1. Which is an example of an input data risk for an ML system?

  • A. Overfitting
  • B. Poisoned training data
  • C. Sub-optimal algorithm selection
  • D. Susceptibility to adversarial examples
Show answer
B. A and D are model risks, C is a development risk.
Quiz

2. Besides the ML workflow categories, how else can risks for an ML system be categorised?

  • A. By the quality characteristics of ISO/IEC 25059
  • B. By the number of lines of code
  • C. By the programming language
  • D. Only by test level
Show answer
A.
Quiz

3. Why is risk-based testing particularly expected for AI-based systems?

  • A. AI-based systems cannot be tested in any other way
  • B. Most AI regulatory frameworks require a risk-based approach
  • C. Risk-based testing is only used for AI
  • D. It removes the need for acceptance criteria
Show answer
B.