FAILURE MAP
← Case archive

FA-100031 / Evaluation metric aggregation / Open access

Multiclass MCC reports accuracy instead of correlation · case 01

Multiclass MCC reports accuracy instead of correlation.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The evaluator reports the diagonal fraction and loses the predicted and actual class marginals.

THE FAILURE

The evaluator reports the diagonal fraction and loses the predicted and actual class marginals.

Unsuccessful approach: Dividing the covariance numerator by squared sample count fails to normalize by class marginals.

Case contract

Return multiclass Matthews correlation coefficient for the supplied label set using the confusion-matrix formula; zero denominator 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(truth, pred, labels):
    return sum(a==b for a,b in zip(truth,pred))/len(truth) if truth else 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('binary perfect',solve([0,1],[0,1],[0,1]),1)
check('binary inverse',solve([0,1],[1,0],[0,1]),-1)
check('constant prediction',solve([0,1],[0,0],[0,1]),0)
check('empty',solve([],[],[0,1]),0)
check('three-class perfect',solve([0,1,2],[0,1,2],[0,1,2]),1)
check('three-class cycle',solve([0,1,2],[1,2,0],[0,1,2]),-.5)
check('unbalanced binary',solve([0,0,1,1,1],[0,1,1,1,1],[0,1]),3/(24**0.5))
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 fixtureActualExpectedOutcome
binary perfect1.01Passed
binary inverse0.0-1Failed
constant prediction0.50Failed
empty00Passed
three-class perfect1.01Passed
three-class cycle0.0-0.5Failed
unbalanced binary0.80.6123724356957946Failed

SHA-256 / 33c6174dcd18aac3661d773b44decc8300e03179c08db4b298d51e0492ab5342

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(truth, pred, labels):
    from math import sqrt
    C=[[sum(a==i and b==j for a,b in zip(truth,pred)) for j in labels] for i in labels]; s=sum(map(sum,C)); c=sum(C[i][i] for i in range(len(labels))); r=[sum(row) for row in C]; q=[sum(C[i][j] for i in range(len(labels))) for j in range(len(labels))]; numerator=c*s-sum(x*y for x,y in zip(q,r)); return numerator/(s*s) if s else 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('binary perfect',solve([0,1],[0,1],[0,1]),1)
check('binary inverse',solve([0,1],[1,0],[0,1]),-1)
check('constant prediction',solve([0,1],[0,0],[0,1]),0)
check('empty',solve([],[],[0,1]),0)
check('three-class perfect',solve([0,1,2],[0,1,2],[0,1,2]),1)
check('three-class cycle',solve([0,1,2],[1,2,0],[0,1,2]),-.5)
check('unbalanced binary',solve([0,0,1,1,1],[0,1,1,1,1],[0,1]),3/(24**0.5))
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 fixtureActualExpectedOutcome
binary perfect0.51Failed
binary inverse-0.5-1Failed
constant prediction0.00Passed
empty00Passed
three-class perfect0.66666666666666661Failed
three-class cycle-0.3333333333333333-0.5Failed
unbalanced binary0.240.6123724356957946Failed

SHA-256 / 05bda0f8cab95b8c9ec7b5db747837f347aaf456c0a41381f2fac08bede3e31b

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.810501+00:00.

Case digest / 648dfbfe1f6ab11672b973db01f105cc3d160c09663c28b0d56aa1c493af1320