download

Two raters agree on 90% of labels. Why is kappa 0.12?

AI engineering~12 minReviewed 3 Dec 2026Free · No sign-in

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 BB: passB: failA total
A: pass89392
A: fail718
B total964100

The team celebrates 90% raw agreement. Yet Cohen's kappa is only 0.120.

  1. Implement cohen_kappa(both_pass, a_only, b_only, both_fail) using Python 3.12 stdlib.
  2. Why does 90% raw agreement mislead here, and what do you do next?
"CODE · PYTHON"
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)
  1. "COMPUTE CHANCE AGREEMENT"

    Rater A marks 92% pass and Rater B marks 96% pass. If they guessed at random with those rates, how often would they match?

  2. "APPLY KAPPA FORMULA"

    Observed agreement p_o is (89 + 1) / 100 = 0.90. Chance agreement p_e is 0.92 * 0.96 + 0.08 * 0.04. Compute (p_o - p_e) / (1 - p_e).

  3. "INSPECT THE FAILS"

    Out of 11 items flagged fail by 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.

"SOLUTION · PYTHON"
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}")
"OUTPUT"
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% pass and 8% fail; Rater B marks 96% pass and 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.

MetricValueWhat 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 kappa0.120Almost no agreement beyond chance
Fail-case overlap1 / 11Raters 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.70 to 0.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_e without guarding p_e == 1. If both raters mark every item pass, 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 fail makes 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 →

Original OfferVibe question. Jacob Cohen, "A Coefficient of Agreement for Nominal Scales" (Educational and Psychological Measurement, 1960) · scikit-learn cohen_kappa_score · Python fractions documentation.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.