ML model risks and mitigations
Why This Matters
Clean, representative data does not guarantee a good model. The model can still overfit, be fooled by a crafted input, drift as the world changes, or simply lose to the version it replaces. Each of those risks has its own test technique, and choosing the wrong one tests nothing. This lesson is the map for the rest of the module.
What you will learn
- The functional, non-functional and deployment risks of an ML model
- Which test approach mitigates which model risk
- Where in this course each approach is covered
Syllabus: AI-6.1.1.
Three kinds of model risk
Model testing addresses:
- functional risks: the model gives wrong or unfair answers (bias, overfitting, vulnerability to adversarial input)
- non-functional risks: it is not robust, or not efficient enough
- deployment risks: it behaves differently once deployed or updated
Risks and mitigations
| Model risk | Test approach | Lesson |
|---|---|---|
| Biased model | Testing for bias | 35 |
| Unethical model | Ethical system testing | 35, 29 |
| Vulnerable to adversarial examples | Adversarial testing | 45 |
| Overfitting or underfitting | Testing for overfitting and underfitting | 48 |
| Data drift or concept drift | Drift testing | 47 |
| Side effects | Side-effects testing | below |
| Reward hacking | Reward hacking testing | below |
| Defects in the model’s API | API testing | 52 |
| Accuracy, recall or other targets not met | ML functional performance testing | 44 |
| The test oracle problem | Metamorphic, back-to-back and A/B testing | 46, 49 |
| Poor requirements | Requirements review | 8 |
| Harmful outputs | Red teaming and exploratory testing | 29, 30 |
| Unexpected inputs | Adversarial and fuzz testing | 45 |
| Poor efficiency | Performance testing | 52 |
| Poor documentation | Model documentation review | 43 |
| Model updates | Back-to-back, A/B, smoke and regression testing | 49, 52 |
| Security, safety and privacy issues | Red teaming | 29 |
Two risks in the table are not covered elsewhere in this course:
Side effects. A system reaches its goal but causes something else nobody wanted: a cleaning robot that knocks over a vase on the shortest route; a recommender that maximises viewing time by promoting ever more extreme content. Side-effects testing looks beyond the target metric: what else changes in the environment when the system does its job?
Reward hacking. A system that learns from a reward (reinforcement learning, lesson 10) finds a way to get the reward without doing the task: the game-playing agent that scores points by looping in a corner instead of finishing the race; the robot rewarded for “no visible mess” that learns to cover the mess. Reward hacking testing checks whether high reward really means the intended behaviour, for example by watching the behaviour, not only the score.
How to use the table
Start from your risk analysis (lesson 32). For each model risk rated high, pick the matching approach; for the oracle problem, plan at least one of metamorphic, back-to-back or A/B testing. Notice how often a single risk needs a test after release (drift, updates): model testing does not end at deployment.
Exercise
Match each situation to the test approach that addresses it.
- A traffic sign classifier misreads a stop sign with a small sticker on it.
- A new model version will replace the current one next week.
- The model is 99% accurate on training data and 70% on new data.
- Six months after release, the share of approvals has slowly risen from 40% to 60%.
- There is no way to say what the correct output is for most inputs.
- Nobody can say which data the model was trained on or what its intended use is.
Show suggested answer
- Adversarial testing (a small, deliberate perturbation).
- Back-to-back and A/B testing, plus smoke and regression testing.
- Testing for overfitting.
- Drift testing (data or concept drift).
- Metamorphic, back-to-back or A/B testing (the oracle problem).
- Model documentation review.
Exam-style questions
1. A reinforcement learning agent in a game scores many points by circling in one spot instead of completing the course. Which risk does this illustrate?
- A. Data drift
- B. Reward hacking
- C. Overfitting
- D. Poor documentation
Show answer
2. Which test approaches are suggested for the test oracle problem in ML model testing?
- A. Performance and load testing
- B. Metamorphic, back-to-back and A/B testing
- C. Static analysis and code review
- D. Usability testing