Two raters agree on 90% of labels. Why is kappa 0.12?
Question
Two human raters grade 100 LLM answers as pass or fail before you scale labeling to 5,000 rows and train an LLM judge:
| Rater A / Rater B | B: pass | B: fail | A total |
|---|---|---|---|
A: pass | 89 | 3 | 92 |
A: fail | 7 | 1 | 8 |
| B total | 96 | 4 | 100 |
The team celebrates 90% raw agreement. Yet Cohen's kappa is only 0.120.
- Implement
cohen_kappa(both_pass, a_only, b_only, both_fail)using Python 3.12 stdlib. - Why does 90% raw agreement mislead here, and what do you do next?
def cohen_kappa(both_pass, a_only, b_only, both_fail): # Return (p_o, p_e, kappa) for a 2x2 rater agreement table. pass
Show hints (3)
- "COMPUTE CHANCE AGREEMENT"
Rater A marks 92%
passand Rater B marks 96%pass. If they guessed at random with those rates, how often would they match? - "APPLY KAPPA FORMULA"
Observed agreement
p_ois(89 + 1) / 100 = 0.90. Chance agreementp_eis0.92 * 0.96 + 0.08 * 0.04. Compute(p_o - p_e) / (1 - p_e). - "INSPECT THE FAILS"
Out of 11 items flagged
failby at least one rater, they agreed on just 1. Fix the rubric before labeling 5,000 rows.
Show checked explanation
Raw agreement ignores class imbalance. Because Rater A marks 92% pass and Rater B marks 96% pass, random guessing with those rates already agrees 88.64% of the time. Observed 90% agreement is barely above chance, giving Cohen's kappa 0.120. Pause scaling, inspect the 10 disagreements, and tighten the rubric first.
from fractions import Fraction def cohen_kappa(both_pass, a_only, b_only, both_fail): total = both_pass + a_only + b_only + both_fail p_o = Fraction(both_pass + both_fail, total) a_pass = Fraction(both_pass + a_only, total) b_pass = Fraction(both_pass + b_only, total) p_e = a_pass * b_pass + (1 - a_pass) * (1 - b_pass) if p_e == 1: return p_o, p_e, None kappa = (p_o - p_e) / (1 - p_e) return p_o, p_e, kappa p_o, p_e, kappa = cohen_kappa(89, 3, 7, 1) print(f"p_o={float(p_o):.2%} p_e={float(p_e):.2%} kappa={float(kappa):.3f}")
p_o=90.00% p_e=88.64% kappa=0.120
Code and exact rational Cohen's kappa calculations run on CPython 3.12.10 against the 100-item table above; official scikit-learn and Python documentation links checked. Checked by an editor other than the author.
Walkthrough
When almost every output passes, raw percent agreement flatters noisy labels.
1. Observed vs chance agreement. Cohen's kappa compares observed agreement p_o to chance agreement p_e from each rater's own class rates:
- Observed agreement:
p_o = (89 + 1) / 100 = 0.90(90.00%). - Marginal rates: Rater A marks 92%
passand 8%fail; Rater B marks 96%passand 4%fail. - Chance agreement:
p_e = 0.92 * 0.96 + 0.08 * 0.04 = 0.8832 + 0.0032 = 0.8864(88.64%). - Cohen's kappa:
(0.90 - 0.8864) / (1 - 0.8864) = 0.0136 / 0.1136 = 17/142 ≈ 0.120.
Look at the failure rows directly. Eleven items received a fail from at least one rater (3 + 7 + 1 = 11), yet both raters agreed on only 1 of 11 (9.1%). That means the raters do not share a clear definition of failure.
| Metric | Value | What it tells you |
|---|---|---|
Raw agreement (p_o) | 90.00% | Mostly reflects the high pass rate |
Chance agreement (p_e) | 88.64% | Agreement expected by random matching |
| Cohen's kappa | 0.120 | Almost no agreement beyond chance |
| Fail-case overlap | 1 / 11 | Raters disagree on what counts as a bug |
2. Fix the rubric before scaling or training an LLM judge. Never train an LLM judge on noisy labels with kappa 0.120. Hold a calibration round on the 10 disagreements:
- Replace vague words like "helpful" with binary checks (fact supported, policy condition kept, refusal when unknown).
- Add concrete border examples to the labeling guide.
- Re-label a fresh 100-item sample (oversampling likely failures) until kappa reaches your target bar (often
>= 0.70to0.80).
Common mistakes
- Scaling annotation to 5,000 rows after seeing 90% raw agreement. You pay to collect thousands of inconsistent labels.
- Training an LLM judge against disagreed human labels. Your judge cannot beat the noise ceiling of its ground truth.
- Dividing by
1 - p_ewithout guardingp_e == 1. If both raters mark every itempass, kappa is undefined (0/0). - Using unweighted kappa on a 1-to-5 quality scale. For ordered scores, use weighted kappa (linear or quadratic) so a 1-vs-5 clash counts more than 4-vs-5.
Follow-up questions
- "What if your product really passes 98% of queries? Won't kappa stay low even with strong raters?" Yes. Extreme class skew depresses kappa (the prevalence paradox). On the calibration audit, oversample hard, flagged, or low-confidence cases so
failmakes up roughly 30% to 50% of the audit batch, and report per-class F1 alongside kappa. - "You have five raters instead of two, and not every rater grades every item. What metric do you use?" Cohen's kappa only handles two raters on the same cases. Use Fleiss' kappa when a fixed number of raters grade each case. Use Krippendorff's alpha when raters vary or labels are missing.
What a strong answer covers
Computes p_o = 0.90, p_e = 0.8864, and kappa = 0.120 cleanly in Python stdlib. Points out that raters agreed on only 1 of 11 flagged failures, pauses scaling, and tightens binary rubric rules before training an LLM judge.
Open in interactive practice deck →