ealeng

Episode 03 of 15 · How many test cases?

The hidden 1%: stratified sampling for rare critical cases

A simulated support assistant passes 94.5% of requests, but 1 request in 100 is critical and 3 in 10 of those fail. A random 100-case test set has no critical case a third of the time. Sampling each group separately, with a floor of 20, shrinks the critical group's interval from 79 points to 37 (19 with most cases on critical); weighting the score back to real traffic keeps the overall number honest; and the critical group's own interval, 53–89%, fails a 90% bar that the 95.4% overall score hides.

Lab 04 · Why Random Sampling Isn't Enough14 min read
Video transcript6:45

0:00Cold open

0:01

Our support assistant passes ninety-four and a half percent of its requests. That looks great.

0:08

But one request in a hundred is critical: a refund, private data, a safety question.

0:14

And three in ten of those fail.

0:17

A random set of a hundred test cases will usually miss every one of those failures.

0:23

So which cases should you actually test?

0:27Intro

0:28

Hands-on AI evals: how many test cases? Part three.

0:33

Today: the hidden one percent, and how to test the cases that matter most.

0:39Meet Maya

0:40

I’m Maya, an ML engineer. So far in this series, we put a range on a test score, and worked out how many cases a range needs. Today: which cases.

0:51

First, the words. A test case is one real request with a known right answer. The assistant’s reply passes or fails.

1:00

The score is the share that pass. Nine out of ten is ninety percent.

1:05

I sort requests into four groups: normal, difficult, ambiguous, and critical.

1:10

This assistant isn’t real. I simulated a hundred thousand requests, so I know exactly how well each group does.

1:18

Normal requests are ninety percent of the traffic. Critical ones are just one percent.

1:2501 · The hidden 1%

1:27

Think of a fire inspector who checks ten random rooms in a hotel. She sees bedroom after bedroom. She may never open the kitchen, the room most likely to catch fire.

1:38

A random test set works the same way. Here’s one: a hundred requests, drawn at random. Each dot is one test case, colored by its group.

1:47

It has one critical case. It failed. But one case can’t tell you how often that happens.

1:54

A second random set: no critical case at all.

1:58

A third: none again.

2:01

Over a thousand random sets, about a third had no critical case at all. Most had one or two.

2:08

Three in ten critical requests fail, yet only one set in four showed even a single critical failure.

2:17

To be fairly sure of getting twenty critical cases by chance, you’d need about twenty-eight hundred random cases. Almost all of them aren’t critical.

2:27

Or you could just take twenty critical cases directly.

2:3102 · Sample each group

2:33

A good inspector always checks the kitchen.

2:36

For tests, split the requests into their groups first. Then draw cases from each group separately. That’s called stratified sampling.

2:44

I gave every group at least twenty cases. That minimum is called a floor. Normal requests get the rest.

2:51

How well does each design measure the critical group? Here’s its ninety-five percent range: where its true pass rate could be.

2:59

With a hundred and fifty random cases, you typically get just one critical case, and one time in five, none.

3:07

With one case, the range runs from about twenty percent to a hundred: seventy-nine points wide. It could be almost anything.

3:16

With twenty critical cases, it shrinks to thirty-seven points.

3:21

Put most of the cases where failures hurt most, and it’s nineteen.

3:26

Same hundred and fifty cases. Only where they go has changed.

3:3203 · Which score?

3:33

But there’s a catch. Here’s one test with that design.

3:37

My test set is heavy on the rare groups, on purpose. Far heavier than real traffic.

3:43

So there are two ways to score it. The raw score counts every case the same: ninety point seven percent.

3:50

The weighted score counts each group by how common it really is. Critical cases are thirteen percent of my test set, but in the weighted score they count for one percent. That gives ninety-five point four.

4:03

So which one do I report?

4:07

The weighted one. The truth is ninety-four and a half. Weighted is off by less than a point, which is just chance. Raw is off by four.

4:17

The raw score is low because my test set is full of hard cases. It describes my test set, not my traffic.

4:25

Over two thousand tests like this, the raw score came out low almost every time. The weighted score was right on average.

4:34

So I report the weighted score for the whole system, and every group’s own score next to it.

4:4104 · Zero failures

4:42

Now suppose I fix the assistant, and all twenty critical cases pass. Zero failures. Is it safe?

4:50

Not yet. With twenty cases, the true failure rate could still be as high as fourteen percent.

4:57

A rule of thumb, called the rule of three: it could be up to about three divided by the number of cases.

5:04

To claim critical requests fail less than one percent of the time, I’d need about three hundred cases, all passing.

5:13

So size the floor from the claim you need to make.

5:1705 · Where the harm is

5:18

One more question: where do failures hurt the most? Here are the failures in every thousand requests.

5:25

Normal requests cause most of them: two in every three.

5:30

But failures don’t all cost the same. A wrong refund or a data leak is far worse than a clumsy answer. Here, a critical failure counts as fifty times worse. That’s a judgment call: agree it with whoever owns the risk.

5:45

So which group does the most harm?

5:49

Critical. One percent of the traffic, sixty-nine percent of the harm.

5:55

That’s where extra test cases pay off most.

5:5906 · What I report now

6:00

So here’s what I report now, for the test from earlier. First, the score for the whole system, weighted back to real traffic.

6:08

Then every group on its own line, with its range.

6:12

The critical line is the one that matters. Its whole range is below ninety percent. If ninety is my bar, this release fails, even though the overall score looks great.

6:24

Next time: how many cases it takes to find the different ways an AI fails, not just how often.Maya: Always check the kitchen.

6:31Summary

6:33

Random tests miss rare groups. Sample each group. Weight the score back. Report every group.

6:39

Then a great average can’t hide the one percent that matters.Maya: Thanks!

Key takeaways

  • ✓A random test set copies the traffic mix, so a group that is 1% of traffic gets about 1% of the cases. In 1,000 simulated random sets of 100, 345 had no critical case at all, and only 26% showed even one critical failure, although 3 in 10 critical requests fail.
  • ✓Getting enough of a rare group by chance is wasteful: at least 20 critical cases, 19 times in 20, takes 2,784 random cases, 2,756 of them not critical. Stratified sampling takes the 20 directly: split requests into groups first, then draw from each group separately.
  • ✓Where the cases go matters more than how many. The same 150 cases measure the critical group with a 95% interval 79 points wide when drawn at random (typically one critical case), 37 points with a floor of 20 per group (90/20/20/20), and 19 points with most cases on critical (20/20/20/90).
  • ✓A test set that over-represents rare groups needs a weighted score: each group's pass rate times its share of real traffic. One evaluation scored 90.7% raw and 95.4% weighted against a true 94.55%. Over 2,000 simulated evaluations the raw score was 5.5 points low on average; the weighted one was right on average (+0.1).
  • ✓Zero failures prove less than they seem: 20 of 20 clean leaves the failure rate possibly as high as 13.9% (about 3 ÷ n, the rule of three). Claiming “fails under 1%” takes 299 cases that all pass, so size a group's floor from the claim it must support.
  • ✓Count harm, not just failures: normal requests cause two in three failures (36 of 54.5 per 1,000), but with a critical failure counted as 50× worse (a judgment call), 1% of traffic causes 69% of the harm.
  • ✓Report the weighted overall score and every group on its own line with its interval. Here the critical interval, 53–89%, is entirely below a 90% bar: the release fails although the overall score looks great.

A support assistant passes 94.5% of its requests. That looks great. But 1 request in 100 is critical (a refund, private data, a safety question), and 3 in 10 of those fail. A random test set of 100 cases usually misses every one of those failures. This chapter is about which cases to test: how a random test set hides a rare group, how sampling each group separately fixes it, how to keep the overall score honest afterwards, and what to report.

The examples come from Lab 04 (Why Random Sampling Isn't Enough) of the AI evaluation labs. Its four scripts: 01_zero_catastrophe.py (how often a random test set misses the rare group), 02_stratified_designs.py (ways to split a fixed number of cases across groups, and what zero failures prove), 03_reweighting.py (raw against weighted scores, and a verdict per group) and 04_risk_based.py (where the harm is). Everything here is a simulation: the lab builds 100,000 support requests whose true results are fixed in advance, so every estimate can be checked against the truth. No real assistant was tested, and the failure costs are the lab's judgment call. The chapter leaves out the last part of Script 4, which plans a real test set for Lab 01's example store (it needs that lab's data), and covers effective sample size, the other ways to split cases and the weighted score's margin only briefly.

The simulated traffic

A test case is one request with a known right answer; the assistant's reply passes or fails. The score is the share that pass. The lab sorts requests into four groups (statisticians say strata, one stratum):

Group Share of traffic True pass rate Cost of one failure
normal 90% 96% ×1
difficult 5% 85% ×2
ambiguous 4% 80% ×2
critical 1% 70% ×50
overall 94.55%

The critical group is a hidden problem: 300 of its 1,000 requests fail, and the overall score, 94,550 of 100,000, still looks excellent. (The video rounds it to 94.5%.) The cost column says how much worse one failure is than a clumsy answer to a normal request; we'll need it at the end.

The hidden 1%

Think of a fire inspector who checks 100 random rooms in a big hotel. She sees bedroom after bedroom, and she may never open the kitchen, the room most likely to catch fire. A random test set works the same way: it copies the traffic mix, so a group that's 1% of traffic gets about 1% of the cases.

Try it · The inspector's random roomsLab 04 · 01_zero_catastrophe.py · simulated traffic

A fire inspector opens 100 random rooms of a hotel. Here each “room” is a test case drawn at random from 100,000 simulated support requests, coloured by its group. Critical requests are the kitchen: 1 in 100, and 3 in 10 of them fail. These are the first six random sets the lab's script drew, in order (not picked).

normal (90% of traffic) difficult (5% of traffic) ambiguous (4% of traffic) critical (1% of traffic)failed
Passed (all groups)
93 / 100
Critical cases
1
Critical failures seen
1

One critical case, and it failed. One case can't tell you how often that happens.

Critical cases in each of 1,000 random 100-case sets (highlighted: the set above)

3450 critical4011 critical1662 critical663 critical194 critical35 critical

345 of 1,000 sets (34.5%) had no critical case; the formula 0.99100 says 36.6%. Only 26% showed even one critical failure.

A bigger random set?

No critical case
34.5%
Typical critical count
1
Shows a critical failure
26.1%
Critical interval
79 pts

“Typical” is the median over 1,000 random sets of that size; the interval is the critical group's 95% Wilson interval, median width in percentage points. Even at 2,000 random cases it's 37 points wide. To get at least 20 critical cases 19 times in 20 by chance takes 2,784 random cases, 2,756 of them not critical. Or take 20 critical cases directly.

The lab drew 1,000 random test sets of 100 cases each (Script 1):

  • 345 of 1,000 had no critical case at all (34.5%; the formula 0.99¹⁰⁰ says 36.6%). Most of the rest had one or two.
  • Only 26% showed even one critical failure, although 3 in 10 critical requests fail.
  • The overall score was right on average (94.7% against the true 94.55%). Nothing in it warns you.

A bigger random set helps slowly. At 2,000 random cases the typical set has 20 critical cases, and the critical group's confidence interval (the range its true pass rate is likely in, here at 95%; Chapter 1 covers them) is still 37 percentage points wide. The lab measures all intervals here with the Wilson interval, the one Chapter 1 recommends for pass rates; "points" means percentage points throughout. To be fairly sure of getting 20 critical cases (19 times in 20) by chance takes 2,784 random cases, 2,756 of them not critical. Or you could take 20 critical cases directly.

Sample each group

A good inspector always checks the kitchen. For tests, split the requests into their groups first, then draw cases from each group separately. That's stratified sampling. Usually you also give every group a minimum number of cases, a floor, so each one can be measured at all.

Script 2 splits the same 150 cases six ways and runs each design 2,000 times. Plans are written normal / difficult / ambiguous / critical, so 90/20/20/20 means 90 normal cases and 20 of each other group:

Design How it splits 150 Critical interval width (median) Overall score SD Worth (effective n)
Random by chance (critical: typically 1, none in 22.7% of sets) 79 points 1.84 points 150
Proportional to traffic 135 / 8 / 6 / 1 79 1.82 150
Neyman 124 / 12 / 11 / 3 73 1.83 145
Floor of 20 90 / 20 / 20 / 20 37 1.93 109
Equal 38 / 38 / 37 / 37 28 2.96 47
Risk-based, floor of 20 20 / 20 / 20 / 90 19 3.92 25

What the columns mean:

  • Critical interval width: how precisely the design measures the critical group. With 150 random cases you typically get one critical case, and one pass in one gives a Wilson interval from 21% to 100%: 79 points wide, so the true rate could be almost anything. Twenty critical cases (14 passing, at the true 70%) give 48–85%, 37 points. Ninety (63 passing) give 60–78%, 19 points.
  • Overall score SD: how much the overall score (weighted back to real traffic, as in the next section) moved from one evaluation to the next. The standard deviation (SD) is the typical distance from the average.
  • Effective n: how many equally weighted cases the design is worth for the overall score (Kish's effective sample size, Script 3). Oversampled cases get small weights, so 150 risk-based cases are worth about 25 for the overall number. Neyman's 145 was computed with the lab's code; the script doesn't print it.

Neyman allocation gives each group cases in proportion to its traffic share times how much its results vary (√(p(1−p)), largest for pass rates near 50%); it gives the most precise overall score for the budget. Risk-based gives cases in proportion to traffic share × failure rate × cost of one failure.

No design wins everywhere. Random, proportional and Neyman tie on the overall number (SD about 1.8 points), because the groups' pass rates are close, and all three leave the critical group unmeasured. A floor of 20 gives up about 0.1 point of overall SD and halves the critical interval. Equal and risk-based pay more overall precision for the best critical measurement. Same 150 cases; only where they go has changed.

Try it · Where the 150 cases goLab 04 · 02_stratified_designs.py · 2,000 simulated evaluations per design

at least 20 per group; normal gets the rest.

The 150 cases, by group

90
20
20
20

normal 90 · difficult 20 · ambiguous 20 · critical 20

normal (90% of traffic) difficult (5% of traffic) ambiguous (4% of traffic) critical (1% of traffic)

A typical critical result, at the true 70%, and its 95% interval

true 70%90% bar0%25%50%75%100%

14 of 20 passed → 48% to 85%, 37 points wide

Critical interval
37 pts
Overall score SD
1.93 pts
Worth (effective n)
109

Critical interval: the median width over 2,000 simulated evaluations (the bar above is one typical result). Overall score SD: how much the overall score (weighted back to traffic) moved between evaluations. Effective n: how many equally weighted cases the design is worth for the overall score (Kish).

All clean: what can zero failures prove?

Failure rate could still be
up to 13.9%
Rule of three: 3 ÷ n
15.0%

95% upper bound = 1 − 0.05^(1/20). Not enough to claim "fails under 1%": that takes 299 clean cases.

Raw or weighted score?

There's a catch. A 90/20/20/20 test set is heavy on the rare groups on purpose: they are 40% of the test set and 10% of real traffic. So there are two ways to score it. Here is one evaluation (Script 3, Exercise 1):

Group Passed Rate Share of the test set Share of real traffic
normal 87 / 90 96.7% 60% 90%
difficult 17 / 20 85% 13.3% 5%
ambiguous 17 / 20 85% 13.3% 4%
critical 15 / 20 75% 13.3% 1%
  • The raw score counts every case the same: 136 of 150, 90.7%.
  • The weighted score counts each group by its share of real traffic: 0.90 × 96.7% + 0.05 × 85% + 0.04 × 85% + 0.01 × 75% = 95.4%. Critical cases are 13% of the test set but count for 1%.

The truth is 94.55%. The weighted score is off by less than a point, which is chance. The raw score is off by about four, and not by chance: it's low because the test set is full of hard cases. It describes the test set, not the traffic. Over 2,000 such evaluations (Exercise 2), the raw score averaged 89.0%, 5.5 points low on average and below the truth in 98.9% of them; the weighted score averaged 94.6%, +0.1 points, right on average.

So report the weighted score for the whole system, and every group's own score next to it.

What zero failures prove

Suppose you fix the assistant and all 20 critical cases pass. Zero failures. Is it safe? Not yet. With 0 failures in n cases, the true failure rate could still be as high as 1 − 0.05^(1/n) at 95% confidence:

Clean cases (0 failures) Failure rate could still be up to Rule of three: 3 ÷ n
10 25.9% 30%
20 13.9% 15%
50 5.8% 6%
100 3.0% 3%
300 1.0% 1%

The rule of three is the shortcut: up to about 3 ÷ the number of cases. Turned around, it tells you how many clean cases a claim needs: "fails under 10%" takes 29, "under 5%" 59, "under 1%" 299, "under 0.1%" 2,995, and every one must pass; a single failure means you need more. So size a group's floor from the claim it has to support, not from a round number.

Where the harm is

Which group deserves the extra cases? Count the failures per 1,000 requests: 1,000 × traffic share × failure rate (Script 4, Exercise 1).

Group Failures per 1,000 Cost of one failure Harm per 1,000 Share of harm
normal 36 ×1 36 17%
difficult 7.5 ×2 15 7%
ambiguous 8 ×2 16 7%
critical 3 ×50 150 69%
total 54.5 217

Normal requests cause two in three failures. But failures don't all cost the same: a wrong refund or a data leak is far worse than a clumsy answer. With a critical failure counted as 50 times worse, 1% of traffic causes 69% of the harm. That ×50 is a judgment call: agree it with whoever owns the risk (support leads, legal, safety), and write it down, because it decides where the test budget goes. A pass rate counts every failure the same and points you at the wrong group. This is risk-based testing, borrowed from QA: test where a failure is both likely and expensive.

The same script also estimates harm from 150-case test sets: with proportional allocation (one critical case) the estimate swung from 27 to 598 harm units (the middle 95% of 2,000 runs); any design that gives critical a real share was about 5× steadier (SD 45–55 against 232). Most of that gain came from the floor, not from fine-tuning the split.

What to report

For the evaluation above: first the score for the whole system, weighted back to real traffic. Then every group on its own line, with its interval, against its own bar. Script 3 sets bars per group (normal 95%, difficult 80%, ambiguous 75%, critical 90%) and reads each line the same way: a group meets its bar if the whole interval is above it, fails if the whole interval is below, and otherwise you can't tell yet.

Try it · One evaluation, reportedLab 04 · 03_reweighting.py, 04_risk_based.py · simulated

One 90/20/20/20 test set (90 normal, 20 of each other group), run once. Rare groups are 40% of the test set but 10% of real traffic. Two ways to score it:

grouppassedratecounts for
normal87/9096.7% 60.0% (90 of 150)
difficult17/2085.0% 13.3% (20 of 150)
ambiguous17/2085.0% 13.3% (20 of 150)
critical15/2075.0% 13.3% (20 of 150)
Raw score
90.7%
The truth
94.55%
Off by
3.9 pts

136 of 150 passed. The raw score describes this test set, which is full of hard cases, not real traffic. Over 2,000 such evaluations it averaged 89.0%: 5.5 points low on average, and below the truth in 98.9% of them.

Every group with its 95% interval, against its target

normal87/90 · 91%–99% · target 95% · can't tell
difficult17/20 · 64%–95% · target 80% · can't tell
ambiguous17/20 · 64%–95% · target 75% · can't tell
critical15/20 · 53%–89% · target 90% · fails
40%60%80%100%

Red tick: the group's target (the lab's Script 3 targets). A group meets it if its whole interval is above, fails if all of it is below, and otherwise we can't tell. The critical interval, 53–89%, sits entirely below 90%: the release fails, though the weighted score is 95.4%.

Where the harm is, per 1,000 requests

normal
36 · 66%
difficult
7.5 · 14%
ambiguous
8 · 15%
critical
3 · 6%

Failures per 1,000 requests = 1,000 × traffic share × failure rate: 36 + 7.5 + 8 + 3 = 54.5. Normal requests cause two in three of them.

The critical line is the one that matters: 15 of 20, interval 53–89%, all of it below 90%. The release fails, although the overall score is 95.4%. Twenty cases were enough to fail it because 70% is far from 90%; the other three groups sit close to their bars and stay "can't tell". Script 3's own release table runs the same check on a fresh draw (critical: 13 of 20, 43–82%) and reaches the same verdicts; it estimates that deciding the close groups would take roughly 50 to 1,600 cases each, more the closer a group sits to its bar. Spend extra cases where the decision is close and the stakes are high.

What to do

  1. Name your groups before you sample: by topic, intent, account type, or a classifier. Find the rare ones where a failure is expensive.
  2. Sample each group separately, with a floor so every group is measurable. Put extra cases where failures are likely and costly.
  3. Size the floor from the claim. "Fails under X%" with zero failures needs about 3 ÷ X clean cases (299 for 1%).
  4. Weight the overall score back to real traffic. Never report the raw score of an oversampled test set as "the score".
  5. Report every group on its own line with its interval, and decide per group: meets, fails, or can't tell.
  6. Write down the failure costs with whoever owns the risk, and revisit them after incidents.

Caveats

  • It's a simulation. The traffic, the groups and their true pass rates are made up so the truth is known exactly. Real groups won't be this clean, and the numbers here are illustrations of the method, not facts about any assistant.
  • The groups must be labelled correctly. Stratified sampling assumes you know which requests are critical before you sample. If some critical requests are filed as normal, the critical estimate and the weights are both off. The lab leaves that as an exercise.
  • The weighted score's margin is a bit optimistic. Its 95% margin (half the interval's width; Chapter 1) contained the truth in 90% of the 2,000 evaluations, not 95%, because it uses the simple normal-approximation formula inside each group, and that formula undercovers for a group near 100% (normal: 96% on 90 cases), as Chapter 1 showed. Resampling within each group (a stratified bootstrap) is the better interval.
  • Weighting costs overall precision. A design that measures critical well is worth fewer cases for the overall number (risk-based 150: about 25). Teams often run both: a small proportional set for the headline score, and a stratified set for the release decision.
  • The costs are a judgment call. Change ×50 and the share of harm changes with it (the widget's slider shows how much).
  • Rounded in the lab's printout. Script 1 prints the 34.5% of random sets with no critical case as "34%"; this chapter uses the exact share.

The checklist

  1. Why can a random test set give a good overall score and still miss the problem that matters?
  2. What is stratified sampling, and what is a floor for?
  3. How do the main ways to split cases (proportional, Neyman, equal, risk-based) differ, and when would you use each?
  4. Why does an oversampled test set need a weighted score, and what do you report?
  5. What can you conclude from zero failures in n cases?
  6. Why count harm, not just failures, when deciding where cases go?

Practice: score a stratified test set

Write Lab 04's math: the chance a random test set misses a rare group, how many random cases it takes to get 20 of them, the Wilson interval, raw and weighted scores, what zero failures prove, a verdict per group, and harm per 1,000 requests. The tests use the lab's recorded numbers: 36.6% with no critical case, 2,784 random cases, the 79 / 37 / 19-point critical intervals, 90.7% raw against 95.4% weighted, 13.9% and 299, the critical group failing at 53–89%, and 69% of the harm.

Try it · Practice in PythonRuns in your browser · ⌘/Ctrl + Enter to run
strata_practice.py89 lines

Quiz

Try it · Check your understanding0 of 6 answered
  1. 1.1 request in 100 is critical. How often does a random test set of 100 cases contain no critical case at all?

  2. 2.You have 150 test cases. Which split measures the critical group most precisely?

  3. 3.One test set with 90 normal cases and 20 from each rarer group passed 136 of 150: 90.7%. Real traffic is 90 / 5 / 4 / 1%. Which number do you report as the overall score?

  4. 4.After a fix, all 20 critical test cases pass. What can you claim?

  5. 5.Normal requests cause 36 of 54.5 failures per 1,000; critical ones cause 3. A critical failure costs 50× a normal one. Where do extra test cases pay off most?

  6. 6.The weighted overall score is 95.4%. The critical group scored 15 of 20, with a 95% interval of 53–89%, and its bar is 90%. What's the release verdict?

Check your understanding

Try each question before opening its answer.

Why can a random test set give a good overall score and still miss the problem that matters?

It copies the traffic mix, so a group that's 1% of traffic gets about 1% of the cases. In the lab, 345 of 1,000 random 100-case sets had no critical case at all, and only 26% showed even one critical failure, while the overall score was right on average (94.7% against 94.55%). The average is dominated by common, easy requests.

What is stratified sampling, and what is a floor for?

Split the requests into groups first, then draw test cases from each group separately. A floor is a minimum number of cases per group, so every group can be measured at all. With 150 cases, a floor of 20 (90/20/20/20) shrank the critical group's interval from 79 points (random) to 37.

How do proportional, Neyman, equal and risk-based splits differ, and when would you use each?

Proportional follows traffic: an unbiased overall score with no weighting, but rare groups get almost nothing. Neyman adds more cases where results vary more: the most precise overall score, though here it barely beat proportional because the pass rates are close. Equal gives each group the same number: best for comparing groups. Risk-based follows traffic × failure rate × cost: best for measuring harm. Add a floor to any of them; most of the practical gain came from the floor.

A test set with 90 normal cases and 20 from each rarer group scored 90.7% raw and 95.4% weighted. Which do you report, and why?

The weighted score: each group's rate times its share of real traffic. The test set is 40% rare, harder groups against 10% of traffic, so the raw score describes the test set. Over 2,000 simulated evaluations, raw was 5.5 points low on average and below the truth 98.9% of the time; weighted was right on average. Report it with every group's own rate and interval.

All 20 critical cases pass. What can you claim, and how many clean cases would “fails under 1%” take?

Only that the failure rate is probably under 13.9% (1 − 0.05^(1/20)), about 3 ÷ 20 by the rule of three. “Under 1%” takes 299 cases, all passing. Size the floor from the claim the group has to support.

Normal requests cause most failures. Why do extra cases go to critical ones?

Because harm, not the failure count, is what matters: traffic share × failure rate × cost of one failure. With a critical failure counted as 50× worse (a judgment call agreed with whoever owns the risk), critical requests cause 150 of 217 harm units per 1,000 requests, 69%, from 1% of traffic.

The weighted score is 95.4%, and the critical group's interval is 53–89% against a 90% bar. Ship it?

No. A group fails when its whole interval is below its bar, and 89% is below 90%. The overall score can't show it: the critical group counts for 1% of it. That's why every group gets its own line in the report.

Next up: Chapter 4, saturation: this chapter sized test sets to measure how often each group fails. The next one asks how many cases it takes to find the different ways an AI fails (its failure modes), and why that takes far more.

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.