FA-100021 / Evaluation metric aggregation / Open access
Grouped accuracy includes empty groups as zero · case 01
Grouped accuracy includes empty groups as zero.
ROOT CAUSE
Groups with no evaluation rows are inserted into the average with zero score.
THE FAILURE
Groups with no evaluation rows are inserted into the average with zero score.
Unsuccessful approach: Weighting each group score by its row count turns the requested group mean into pooled accuracy.
Case contract
Rows are [group,truth,prediction]. Return the unweighted mean accuracy among requested groups represented by rows; no represented requested groups yields 0.
Why this case matters
A small explicit evaluation contract makes aggregation behavior reproducible across labeled examples.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, groups):
return sum(sum(t==p for g,t,p in rows if g==x)/sum(g==x for g,t,p in rows) if any(g==x for g,_,_ in rows) else 0 for x in groups)/len(groups) if groups else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty requested group',solve([['a',1,1]],['a','b']),1)
check('unequal groups',solve([['a',1,1]]*N+[['b',0,1]],['a','b']),.5)
check('all empty',solve([],['a','b']),0)
check('no group names',solve([['a',1,1]],[]),0)
check('single represented',solve([['x',0,1]],['x']),0)
check('unlisted row ignored',solve([['x',1,1]],['a']),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| empty requested group | 0.5 | 1 | Failed |
| unequal groups | 0.5 | 0.5 | Passed |
| all empty | 0.0 | 0 | Passed |
| no group names | 0 | 0 | Passed |
| single represented | 0.0 | 0 | Passed |
| unlisted row ignored | 0.0 | 0 | Passed |
SHA-256 / 05620536c8a96685b127e36e4f969ad506c8de264b5d19f32acea5e52e4f80bf
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, groups):
present=sorted({g for g,_,_ in rows}); return sum(sum(t==p for g,t,p in rows if g==x)/sum(g==x for g,t,p in rows) for x in present)/len(groups) if groups else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty requested group',solve([['a',1,1]],['a','b']),1)
check('unequal groups',solve([['a',1,1]]*N+[['b',0,1]],['a','b']),.5)
check('all empty',solve([],['a','b']),0)
check('no group names',solve([['a',1,1]],[]),0)
check('single represented',solve([['x',0,1]],['x']),0)
check('unlisted row ignored',solve([['x',1,1]],['a']),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| empty requested group | 0.5 | 1 | Failed |
| unequal groups | 0.5 | 0.5 | Passed |
| all empty | 0.0 | 0 | Passed |
| no group names | 0 | 0 | Passed |
| single represented | 0.0 | 0 | Passed |
| unlisted row ignored | 1.0 | 0 | Failed |
SHA-256 / cbd3d4c26ea2460a61b3ee6a298636fba7a64a696fd8965eb016504c1177ae0f
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
Inputs are finite toy labels and scores; this defines no benchmark protocol, production metric library, or model quality claim. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-30T16:48:30.810585+00:00.
Case digest / e7b18c6a80189dedde80a6cb8a1909ad22bfa5b2ae6a605ab774b78ac715178f