fix(halacha): #81.7 — report Gwet AC1 + consensus-vs-human (κ paradox under skew)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 5s
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 5s
ריצת-הפאנל החיה חשפה Fleiss κ=-0.07 למרות 97.5% הסכמה-גסה (28/40 פה-אחד, 11/40 רוב). זה אינו חוסר-אמינות אלא **פרדוקס-הקאפא**: ה-marginal של is_holding מוטה קיצונית (≈הכול True, כמו 93/100 ה-keep בתוויות-האנוש), וכש-Pe→1 גם κ→0 (Feinstein & Cicchetti 1990, "high agreement, low kappa"). - gwet_ac1(): מדד הסכמה עמיד-שכיחות (Gwet 2008) — אותו Pa כמו Fleiss, אומדן-מקריות שונה (2·p·(1-p)). הופך לכותרת; Fleiss κ עדיין מודווח לשקיפות + raw 3/3. - consensus-vs-HUMAN: כשקיים תיוג-יו"ר, הדוח מודד התאמת-הקונצנזוס מולו (תוקף חיצוני). אימות בפועל על 100 תוויות-היו"ר: 29/29 = 100% התאמה. invariants: ללא שינוי בהתנהגות-הכתיבה; מטריקה בלבד. tests: 21 (3 חדשות, כולל מקרה-פרדוקס מפורש). מקור: Gwet 2008 (AC1) · Feinstein & Cicchetti 1990. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,31 @@ def test_fleiss_kappa_empty_returns_none():
|
||||
assert g.fleiss_kappa([]) is None
|
||||
|
||||
|
||||
# ── gwet_ac1() ────────────────────────────────────────────────────────────────
|
||||
|
||||
def test_gwet_ac1_perfect_agreement():
|
||||
rows = [(3, 0), (3, 0), (0, 3), (0, 3)]
|
||||
assert g.gwet_ac1(rows) == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_gwet_ac1_resolves_the_kappa_paradox():
|
||||
"""The headline reason AC1 exists here: under a heavily skewed marginal
|
||||
(almost every item is_holding=True) Fleiss κ collapses to ~0 despite very
|
||||
high observed agreement, while AC1 correctly reports near-perfect.
|
||||
9 unanimous-yes items + 1 split → 93% observed agreement."""
|
||||
rows = [(3, 0)] * 9 + [(2, 1)]
|
||||
kappa = g.fleiss_kappa(rows)
|
||||
ac1 = g.gwet_ac1(rows)
|
||||
assert abs(kappa) < 0.1 # κ paradox: near zero
|
||||
assert ac1 > 0.9 # AC1: almost-perfect, matching reality
|
||||
assert ac1 > kappa # AC1 strictly more faithful under skew
|
||||
|
||||
|
||||
def test_gwet_ac1_ragged_and_empty_return_none():
|
||||
assert g.gwet_ac1([(3, 0), (1, 1)]) is None
|
||||
assert g.gwet_ac1([]) is None
|
||||
|
||||
|
||||
# ── anonymize() ───────────────────────────────────────────────────────────────
|
||||
|
||||
def test_anonymize_masks_case_number_and_name():
|
||||
|
||||
Reference in New Issue
Block a user