Source

Module 11 · Humans in the loop: review design, spot checks and user testing

Time: about 6 hours with readings · Lab: python course/labs/lab11_spot_checks.py (about a minute)

You need: Module 2 Part B (the binomial §10, the standard error §11, the 95% interval §12), Module 9 §5 (labels and Cohen's kappa) and Module 10 (thresholds and the confusion matrix).

By the end you can:

  • explain why an AI system in a hospital kitchen needs people in the loop, and the three risks that brings;
  • say what each of TrayCheck's three review rules catches and what it can't;
  • explain automation bias and the interface choices that counter it;
  • estimate a hidden error rate from random spot checks, with an honest interval, and work out how many checks you need;
  • write user acceptance test (UAT) scenarios for an AI-assisted workflow and keep an issues register;
  • explain how corrections could improve the model, and the selection-bias trap in doing so.

Why this matters for the internship

The position description is full of this module: "coordinate testing activities with operational users", "assist with developing User Acceptance Testing scenarios", "capture testing results, issues and user feedback", "maintain an issues and improvement register", "support training and onboarding", "user experience and workflow integration". A food-recognition PoC succeeds or fails on whether kitchen staff can use it correctly during a busy service, not on the model alone.

TrayCheck's review_rules.py is built around this. Most demo projects stop at "send low-confidence predictions to a human". TrayCheck also uses information the kitchen already has (today's menu) and measures the errors that slip through unreviewed (random spot checks).


1. Why put people in the loop, and what can go wrong

Every model makes mistakes, and some of them are confident (Module 10: five test mistakes scored 0.87 or higher). When records feed real decisions, such as waste reports, ordering and menu planning, someone has to own their correctness. Human review is the oldest safeguard. It brings three risks of its own:

  • Automation bias: people tend to accept a system's suggestion even when it is wrong, especially when busy or when the system is usually right. It is well documented in aviation and in healthcare, where studies found clinicians accepting incorrect decision-support advice on cases they would otherwise have got right.
  • Review fatigue: if almost everything is flagged, nothing gets real attention, and people start clicking through.
  • Unmeasured residual error: if only flagged items are checked, nobody knows how wrong the unchecked records are, and the reports built on them look more certain than they are.

TrayCheck's design answers each one: few, targeted flags (against fatigue), an interface that forces a decision on flagged items (against automation bias), and random spot checks (to measure residual error).


2. The three review rules, and what each catches

From review_rules.decide() (Appendix B of HANDOFF.md walks through it block by block):

Rule Signal it uses Catches Can't catch
Low score (top score < 0.85) The model's own uncertainty Most of the model's unsure mistakes Confident mistakes
Not on menu Independent knowledge: today's menu Confident mistakes that name an off-menu dish, and real service errors (an off-menu dish actually served) Mistakes between two dishes that are both on the menu
Spot check (random 10% of trays not otherwise flagged) Chance alone Nothing in particular, on purpose It exists to measure the error rate, not to catch errors

Lab 11 counts what each rule flagged in the simulated month (rules can overlap, so the counts don't add up to the total checked):

model mistakes this month: 84 of 811 trays
  flagged low_score   : 175 photos, of which 61 were model mistakes
  flagged not_on_menu :  61 photos, of which 30 were model mistakes
  flagged spot_check  :  55 photos, of which  2 were model mistakes
  mistakes nobody checked: 16  (2.9% of unchecked records)

Of 84 model mistakes, 68 were caught and corrected. 261 of 811 trays (32%) were checked by a person.

Look at the menu check. Of its 61 alerts, about half are model mistakes and the other half are dishes that really weren't on the menu: a kitchen finding that a purely ML design would never surface. The general principle: wherever a system has a second, independent source of truth (a menu, an order, a schedule), use it to check the model. Independent signals catch the confident mistakes that the model's own score can't.

Interface choices against automation bias

On the Check a meal page:

  • Unflagged photos have the model's answer preselected: one click to save, because review time is precious and these are usually right.
  • Flagged photos have nothing preselected. The person must actively choose a dish, and the app refuses to save without a choice. This forces a real decision exactly where the model is least trustworthy.
  • Any result can be corrected, and the original prediction is always kept alongside the correction, so errors can be analysed later.
  • A returned weight larger than the served weight is refused at entry with a message to re-check the scale.

These choices follow widely used design guidance for systems where people work with AI (Microsoft's Guidelines for Human-AI Interaction and Google's People + AI Guidebook, both in Go deeper): make clear how well the system can do what it does (the score and the reason for a flag are shown), make correction quick, and when in doubt, ask instead of assuming (flagged cases have no answer preselected).


3. Measuring what nobody checked: spot checks

Spot checks are random audit sampling, like a quality inspector testing random items from a production line. The key word is random. Because spot-checked trays are chosen by chance from among the unflagged trays, they are a fair miniature of all unflagged trays, so the share found wrong is an unbiased estimate of the hidden error rate among all of them. "Unbiased" means right on average: over many months, the estimates would average out to the true rate, neither too high nor too low. Flagged trays can't be used for this: they were chosen because they looked wrong, so they would overstate it.

Putting a range on the estimate

With k wrong out of n spot checks, the estimate is k/n. In the simulated month, 2 of 55 spot checks were wrong: 3.6%. How sure is that?

The simple interval from Module 2 §12, estimate ± 1.96 × standard error (often called the Wald interval), behaves badly here:

'2 of 55 spot checks were wrong':
Wald (textbook p +/- 1.96 SE)    -1.3% to 8.6%        <- a negative error rate?
Wilson score interval            +1.0% to 12.3%
With 0 of 55 the Wald interval is 0.0% to 0.0%: 'certainly no errors', which is absurd.
Wilson for 0 of 55: 0.0% to 6.5%. Sensible.

Why the simple interval fails. It measures the uncertainty using the estimate itself: SE = √(p̂(1 − p̂)/n). When the estimate is 0 of 55, p̂ = 0, so the SE comes out as 0 and the "interval" is a single point. The estimate is being trusted to describe its own uncertainty, which is exactly what it can't do when the count is small. It also assumes a symmetric bell, so it happily extends below 0%.

The Wilson idea: test each possible true rate. Turn the question round. Instead of starting from the estimate, ask of every possible true error rate p: if this were the true rate, would the count we saw be surprising? "Surprising" means more than 1.96 standard errors from what that rate would produce, with the standard error computed from p itself (Module 2 §11), not from the estimate. The interval is every rate that passes.

Work it for 0 errors in 55 checks:

  • If the true rate were 6.5%, you'd expect 55 × 0.065 = 3.6 errors, give or take a standard deviation of √(55 × 0.065 × 0.935) = 1.83. Seeing 0 is 3.6 / 1.83 = 1.96 standard deviations below that: right on the edge of surprising.
  • Any true rate above 6.5% would make 0 errors more surprising still, so it's ruled out. Any rate below it isn't. The interval is 0% to 6.5%.

And for 2 errors in 55: a true rate of 1.0% expects 0.55 errors (SD 0.74), and 2 is 1.96 SDs above that; a true rate of 12.3% expects 6.8 (SD 2.44), and 2 is 1.96 SDs below. So the interval is 1.0% to 12.3%. Both edges are lopsided around the estimate of 3.6%, as they should be: an error rate can't go below 0, but it has plenty of room above.

Solving "exactly 1.96 standard errors away" for p gives the Wilson formula. You never need to compute it by hand (review_rules.wilson_interval does), but here it is for reference, with z = 1.96 for 95%:

\[\frac{\hat p + \frac{z^2}{2n} \pm z\sqrt{\frac{\hat p(1-\hat p)}{n} + \frac{z^2}{4n^2}}}{1 + \frac{z^2}{n}}\]

Statisticians who compared the options recommend Wilson over the simple interval whenever counts are small or the rate is near 0% or 100%, which describes most spot checks.

So the honest statement is: "about 3.6% of unchecked trays are wrong, plausibly anywhere from 1% to 12%". Of the 550 trays nobody reviewed, that means roughly 20 wrong records (somewhere between about 6 and 68). The true number in the simulation was 16.

Does it work? 200 simulated months

true hidden error rate across months:   mean 2.92% (range 1.4%-5.3%)
spot-check estimate across months:      mean 3.07% (5th-95th pct 0.0%-7.3%)
Wilson 95% interval contained the truth in 187 of 200 months (94%), average width 10.3%

The estimate is right on average, and the intervals contain the truth about as often as a 95% interval should. Any single month is noisy, so the dashboard reports the interval, not just "3.6%".

How many spot checks do you need?

The planning formula from Module 10, n ≈ 1.96² × p(1 − p) / E², with p ≈ 3%:

margin +/-2 points: about 280 spot checks
margin +/-1 point:  about 1,118 spot checks

At about 55 spot checks a month, ±2 points takes about five months. Checking more trays narrows the range sooner, at a cost:

rate 10%: ~ 60 extra checks/month; with a true rate near 3%, a month's 95% interval is ~0.9%-11.4%
rate 20%: ~121 extra checks/month; with a true rate near 3%, a month's 95% interval is ~1.3%-8.2%

That is a real operational trade-off: assurance costs staff time. The right rate is the food service team's decision. Your job in a PoC is to put the numbers in front of them.


4. Reviewers make mistakes too

The simulation assumes reviewers are always right. Real ones aren't, and their errors become the "ground truth" every metric is computed against (Module 9 §5). Two standard controls:

  • Double review: two people check the same random sample independently; measure agreement with Cohen's kappa (Module 9 shows how).
  • Gold items: occasionally include photos with a known, verified answer and check whether the reviewer gets them right.

5. Testing with operational users (UAT)

User acceptance testing (UAT) checks that a system supports the real work of the people who will use it, in their setting, before it is relied on. For ordinary software, UAT scenarios have one right outcome: press save, the record appears. AI changes this in one important way: the model's output is sometimes wrong by design, so UAT must test the workflow around the errors, not only the happy path. A scenario passes if the workflow handles each case correctly, whatever the model says.

Example UAT scenarios for TrayCheck

# Scenario Steps Expected result
1 Confident, correct prediction Photograph a tray of an on-menu dish; model is sure Dish preselected; saved in one click; record shows no flag
2 Low-score prediction Photograph an ambiguous tray Flagged with reason "Low score"; nothing preselected; saving without choosing is refused
3 Model names an off-menu dish Tray of an on-menu dish that the model confuses with an off-menu one Flagged "Not on menu"; best on-menu suggestion shown; person picks the dish
4 An off-menu dish was really served Serve a dish missing from today's menu Flagged "Not on menu"; person records the real dish; appears in the menu-alert count as a kitchen issue
5 Random spot check Save several confident trays About 1 in 10 is flagged "Spot check" and handled like any flagged tray
6 Correcting an unflagged result Change the preselected dish before saving Correction saved; the model's original answer kept
7 Missing returned weight Save a tray with a served weight only Saved; excluded from waste figures; counted under data problems on the dashboard
8 Impossible weights Enter a returned weight above the served weight Refused with a message to re-check the scale
9 Not food at all Photograph an empty tray or a non-food object Known limitation: the model still names a dish. Check whether a flag catches it; record the result

Scenario 9 is deliberately one the system may fail. UAT for AI should include known limitations, so users and sponsors see them in testing rather than in production.

What to measure during UAT, beyond pass or fail: how long a review takes, what share of trays gets flagged, how often people correct unflagged results (an automation-bias signal if it's near zero while spot checks find errors), and what users say is confusing.

The issues and improvement register

Every problem found goes into one shared list, so nothing is lost between meetings:

Field Example
ID, date, reported by I-014, 12 Mar, ward 3 kitchen hand
Scenario / where UAT 3, Check a meal page
What happened vs what was expected Off-menu flag shown, but the suggested dish was also off-menu
Category Model / data / workflow and interface / training / infrastructure
Severity Blocker / major / minor
Owner ISS / vendor / site
Status and resolution Open → fixed in v1.3, retested 19 Mar

Keep model observations as their own category: patterns like "bread pudding often called bibimbap under ward 5's lighting". These are evidence for the final evaluation and for the vendor, and they are what the position description means by "document model observations".

Training users

Onboarding for an AI-assisted workflow should cover what the score means (and that a high score can still be wrong), why flagged trays have nothing preselected, when and how to correct a result, and why spot checks exist. Telling people how the system fails is the most direct defence against automation bias.


6. From corrections to a better model, carefully

Every correction is a labelled example of a mistake, which is valuable training data. Two cautions:

  • Selection bias. Flagged and corrected photos are not a random sample; they over-represent hard cases. Retraining mostly on them can distort the model, and measuring accuracy on them makes it look worse than it is. Evaluate any retrained model on a representative held-out sample. The random spot checks are the cleanest source.
  • Active learning chooses which items to label next so the model improves fastest, for example the most uncertain ones. That is the same "low score" signal used for a different purpose. Keep the purposes separate in the data, so error estimates stay unbiased.

Check your understanding

1. Why are spot checks drawn only from trays that weren't otherwise flagged?

The goal is to estimate the error rate among records that would otherwise go unchecked. Flagged trays are checked anyway, and they were selected because they looked doubtful, so including them would distort the estimate.

2. Why does the flagged-tray form start with no dish selected?

To counter automation bias: on exactly the trays where the model is least trustworthy, the person must make an active choice rather than click "save" on the model's suggestion.

3. 0 corrections in 40 spot checks. What would you tell the kitchen manager?

That no errors have been seen yet, but the plausible range (95% Wilson interval) is about 0% to 9% of unchecked trays. "No errors seen yet" is not "no errors". More checks would narrow the range.

4. About how many spot checks do you need for ±1 percentage point if the error rate is around 3%?

About 1.96² × 0.03 × 0.97 / 0.01² ≈ 1,118.

5. Half the menu-check alerts are real off-menu dishes, not model errors. Is that a problem?

No, it's a benefit. The menu check surfaces genuine service issues as well as model mistakes, and the dashboard reports them separately so each goes to the right owner (kitchen or vendor).

6. How is UAT for an AI-assisted workflow different from UAT for ordinary software?

The model is sometimes wrong by design, so scenarios test how the workflow handles wrong, unsure and out-of-scope outputs, not just whether the happy path works. Include known limitations as scenarios, and measure behaviour such as review time and how often people override the model.

7. During UAT, staff almost never correct unflagged trays, but spot checks find a 4% error rate among them. What might be going on?

Possibly automation bias: people accept the preselected answer without looking. Check with a few gold items, look at review times, and cover it in training. It may also simply be that unflagged errors are hard to see at a glance, which is exactly why the spot checks exist.

8. Why shouldn't you retrain only on corrected photos and then report accuracy on corrected photos?

They are a biased sample of hard cases, both for training and especially for evaluation. Report performance on a representative held-out sample, such as random spot checks or a fresh test set.


Go deeper

Short on time? The study guide says which of these to read first.

Core (free)

  • Amershi et al. (2019), Guidelines for Human-AI Interaction, CHI: the table of 18 guidelines, each with an example. Hosted by Microsoft Research.
  • Google PAIR, People + AI Guidebook: the chapters Errors + Graceful Failure and Feedback + Control. pair.withgoogle.com/guidebook
  • Brown, Cai & DasGupta (2001), Interval Estimation for a Binomial Proportion, Statistical Science: the introduction and the recommendations section are readable on their own.

Optional

  • Goddard, Roudsari & Wyatt (2012), Automation bias: a systematic review of frequency, effect mediators, and mitigators, JAMIA 19(1): the healthcare evidence.
  • Parasuraman & Manzey (2010), Complacency and Bias in Human Use of Automation: An Attentional Integration, Human Factors 52(3).
  • Monarch, Human-in-the-Loop Machine Learning (Manning, 2021): Chapter 1, then the chapters on annotation quality control and interfaces. Paid.
  • Settles (2009), Active Learning Literature Survey, University of Wisconsin–Madison technical report 1648. §1–2 are enough.

Interview angle

"In a hospital kitchen the model will be wrong some of the time, so the design question is how people and model work together. TrayCheck uses three review rules: low score, not on today's menu, and a random 10% spot check of everything else. The menu check uses information the kitchen already has; half its alerts were real off-menu dishes, not model errors. Spot checks are random audit sampling, so they give an unbiased estimate of errors in records nobody checked, which I report with a Wilson interval: 2 of 55 means somewhere between 1% and 12%.

For user testing I'd write UAT scenarios around the errors, not just the happy path: unsure predictions, off-menu answers, impossible weights and known limitations like non-food photos. I'd log everything in one issues register, with model observations as their own category, because they feed the final evaluation."