FA-99966 / Evaluation metric aggregation / Open access
Macro F1 averages pooled counts instead of class scores · case 01
Macro F1 averages pooled counts instead of class scores.
ROOT CAUSE
Counts are pooled before the harmonic mean, hiding per-class imbalance.
THE FAILURE
Counts are pooled before the harmonic mean, hiding per-class imbalance.
Unsuccessful approach: Adding an absent label to the macro denominator dilutes otherwise valid class scores.
Case contract
For each supplied label calculate 2TP/(2TP+FP+FN), using zero for a zero denominator, then average labels; empty labels returns 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(truth, pred, labels):
tp=sum(a==b and a in labels for a,b in zip(truth,pred)); fp=sum(b in labels and a!=b for a,b in zip(truth,pred)); fn=sum(a in labels and a!=b for a,b in zip(truth,pred)); return 2*tp/(2*tp+fp+fn) if 2*tp+fp+fn else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('imbalance',solve([0,0,0,1],[0,1,1,1],[0,1]),.5)
check('pooled differs',solve([0,0,0,0,1],[0,0,0,1,0],[0,1]),.375)
check('perfect',solve([0,1],[0,1],[0,1]),1)
check('all wrong',solve([0,1],[1,0],[0,1]),0)
check('empty labels',solve([0],[0],[]),0)
check('empty data',solve([],[],[0,1]),0)
check('only absent label',solve([1],[1],[2]),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 |
|---|---|---|---|
| imbalance | 0.5 | 0.5 | Passed |
| pooled differs | 0.6 | 0.375 | Failed |
| perfect | 1.0 | 1 | Passed |
| all wrong | 0.0 | 0 | Passed |
| empty labels | 0 | 0 | Passed |
| empty data | 0 | 0 | Passed |
| only absent label | 0 | 0 | Passed |
SHA-256 / 87a6d7ef8483310761f1c6e6814b72d86ba6613ab8dc17ede1fecce5678fce41
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(truth, pred, labels):
scores=[]
for k in labels:
tp=sum(a==k and b==k for a,b in zip(truth,pred)); fp=sum(a!=k and b==k for a,b in zip(truth,pred)); fn=sum(a==k and b!=k for a,b in zip(truth,pred)); den=2*tp+fp+fn
scores.append(2*tp/den if den else 0)
return sum(scores)/len(labels+[99]) if labels else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('imbalance',solve([0,0,0,1],[0,1,1,1],[0,1]),.5)
check('pooled differs',solve([0,0,0,0,1],[0,0,0,1,0],[0,1]),.375)
check('perfect',solve([0,1],[0,1],[0,1]),1)
check('all wrong',solve([0,1],[1,0],[0,1]),0)
check('empty labels',solve([0],[0],[]),0)
check('empty data',solve([],[],[0,1]),0)
check('only absent label',solve([1],[1],[2]),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 |
|---|---|---|---|
| imbalance | 0.3333333333333333 | 0.5 | Failed |
| pooled differs | 0.25 | 0.375 | Failed |
| perfect | 0.6666666666666666 | 1 | Failed |
| all wrong | 0.0 | 0 | Passed |
| empty labels | 0 | 0 | Passed |
| empty data | 0.0 | 0 | Passed |
| only absent label | 0.0 | 0 | Passed |
SHA-256 / ff8d36ff4ee7034136c165ec7377d5088dc8b8ea1104d55b9886e1fe7ce473ec
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 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.355729+00:00.
Case digest / 81288f8a537a0548a6c493dc257b3dc81654a80d370098659f0f0154b37b016f