WRITE · TRACE · UNDERSTAND

Require complete evaluation coverage before reporting category rates

expected is a nonempty versioned inventory of unique id,category rows.

Read lesson: Require complete evaluation coverage before reporting category rates →

Your experiment

expected is a nonempty versioned inventory of unique id,category rows. results contains unique id and explicit boolean passed. Require exactly the same identity set; missing, unknown and repeated cases raise ValueError. Return a category-sorted mapping with total,passed,rate and sorted failed IDs. Aggregate by inventory category, not a category supplied by the candidate. These are descriptive rates, not confidence estimates.

Python runs in your browser. Your draft stays on this device.

What to look for

Review inventory versioning, category balance and the definition of a passing case. Missing observations are not successful evaluations.

Watch your code work

Ready to experiment

Write a solution or load the worked answer, then choose Trace & check.

Step through arrays, variables and training curves produced by your own Python.

About this algorithm

How Require complete evaluation coverage before reporting category rates works

The idea

A pass rate means little unless you know what it was computed over. If a hard case quietly drops out of an evaluation run, the rate goes up and nobody sees why. The defence is a fixed inventory: a versioned list of case IDs and their categories that sets the denominator before any result exists.

evaluation_matrix(expected, results) refuses to report unless the result IDs are exactly the inventory IDs, with no missing case, no unknown case and no repeat, and every passed is a real boolean. Only then does it group cases by the category the inventory assigns, never by one the candidate supplies, and return for each category the total, the number passed, the rate and the sorted IDs that failed.

How it works

  1. Raise ValueError if expected is empty, because there is no denominator to report against.
  2. Collect the IDs from both lists and reject duplicates on either side.
  3. Require set(expected_ids) == set(result_ids), which catches missing and unexpected cases in one test.
  4. Check that every passed has type bool, so 1, a string or None cannot stand in for an outcome.
  5. Group the inventory IDs by category and look up each outcome by ID.
  6. For each category in sorted order, report total, passed, rate and the sorted failed IDs.

What it costs

Time
O(n log n)
Space
O(n)

Set and dictionary operations touch each of the n cases once, and sorting the categories and their IDs adds the log factor that makes the report order repeatable.

Where it is used

  • SWE-bench Verified is a fixed set of 500 task instances, so every system is scored against the same denominator.
  • Inspect, the open-source evaluation framework from the UK AI Security Institute, logs a scored record per sample ID that can be checked against the dataset.
  • Benchmarks such as MMLU report accuracy for each of 57 subjects as well as overall, which shows weak categories that an average hides.

Watch out for

  • Computing the rate over the results that came back, so a crashed or skipped hard case raises the score.
  • Grouping by a category field in the results, which would let the system under test move its failures into another category.
  • Accepting truthy values for passed: the nonempty string "false" counts as true in Python, and None is not an outcome.