Sub topic 10
Where kappa misleads: prevalence and bias
This chapter assumes you can compute Cohen's kappa for two annotators (observed agreement minus chance agreement, divided by one minus chance agreement). It also assumes you are comfortable reading a 2x2 confusion matrix. Here you learn two situations where a kappa value says less than it appears to, and what to report instead.
Why kappa can mislead
Kappa corrects observed agreement for chance. The chance term is built from each annotator's label frequencies, so kappa depends on how often each label occurs and on how the annotators use the labels. It does not depend only on how well they understand the guidelines. Two effects follow:
- Prevalence effect. When one label is very common, chance agreement is high. Kappa can be low even though the annotators agree on almost every item.
- Bias effect. When annotators use a label at different rates, one is systematically stricter than the other. Kappa can look acceptable while the two label sets are not interchangeable.
Neither effect means kappa is wrong. The arithmetic is correct, but a single number cannot show which situation you are in.
The prevalence effect
Take 100 items with a binary label, "toxic" or "ok". For a rare label such as toxic, most items are "ok". In a 2x2 table, call the cells:
a: both annotators say the first label.b: annotator 1 says first, annotator 2 says second.c: annotator 1 says second, annotator 2 says first.d: both say the second label.
Compare two datasets that both have 90% observed agreement.
Balanced: a=45, b=5, c=5, d=45. Both annotators use each label 50% of the time, so chance agreement is 0.5. Kappa is (0.9 − 0.5) / 0.5 = 0.8.
Skewed: a=85, b=5, c=5, d=5. Each annotator uses the common label 90% of the time. Chance agreement is 0.9 × 0.9 + 0.1 × 0.1 = 0.82. Kappa is (0.9 − 0.82) / 0.18 ≈ 0.444.
The raw agreement is identical. Kappa drops from 0.8 to 0.444 because two annotators who guess at random according to their own habits would already agree 82% of the time.
This is not only a nuisance. The skewed result also contains real information: the annotators agree on 85 common items and on only 5 of the 15 items that either of them labeled with the rarer label. The rare label is usually the one you care about, and kappa is correctly telling you that agreement on it is weak.
The bias effect
Now suppose the annotators disagree in a lopsided way. Annotator 1 uses the first label on 40 items and annotator 2 uses it on 70. The table is a=40, b=0, c=30, d=30.
- Observed agreement is 0.7.
- Chance agreement is 0.4 × 0.7 + 0.6 × 0.3 = 0.46.
- Kappa is 0.24 / 0.54 ≈ 0.444.
Annotator 2 never says "second label" when annotator 1 says "first", but says "first label" on 30 items where annotator 1 disagrees. This is a calibration difference, which is often a sign of an unclear boundary in the guidelines or a different reading of a threshold. Kappa gives the same 0.444 as the skewed case, so the number cannot tell you whether the problem is rare labels or a systematic difference between annotators.
Measuring both effects in code
Three extra quantities help separate the causes. All three come from the 2x2 table.
- Prevalence index: |a − d| / n. It is near 1 when one label dominates.
- Bias index: |b − c| / n. It is near 0 when disagreements are symmetric.
- Specific agreement: agreement on each label separately, 2a / (2a + b + c) for the first label and 2d / (2d + b + c) for the second.
The code also computes PABAK (prevalence-adjusted bias-adjusted kappa), which is 2 × p_o − 1 for two categories. It is a sensitivity check, not a replacement for kappa.
def binary_report(name, a, b, c, d):
n = a + b + c + d
p_o = (a + d) / n
p1 = (a + b) / n # annotator 1 uses the first label
p2 = (a + c) / n # annotator 2 uses the first label
p_e = p1 * p2 + (1 - p1) * (1 - p2)
kappa = (p_o - p_e) / (1 - p_e)
prevalence_index = abs(a - d) / n
bias_index = abs(b - c) / n
pabak = 2 * p_o - 1
pos_agree = 2 * a / (2 * a + b + c)
neg_agree = 2 * d / (2 * d + b + c)
print(
f"{name:9s} po={p_o:.3f} pe={p_e:.3f} kappa={kappa:.3f} "
f"PI={prevalence_index:.3f} BI={bias_index:.3f} PABAK={pabak:.3f} "
f"pos={pos_agree:.3f} neg={neg_agree:.3f}"
)
binary_report("balanced", 45, 5, 5, 45)
binary_report("skewed", 85, 5, 5, 5)
binary_report("biased", 40, 0, 30, 30)The output values are:
| Case | p_o | p_e | Kappa | Prevalence index | Bias index | PABAK | Agreement on first label | Agreement on second label |
|---|---|---|---|---|---|---|---|---|
| Balanced | 0.900 | 0.500 | 0.800 | 0.000 | 0.000 | 0.800 | 0.900 | 0.900 |
| Skewed | 0.900 | 0.820 | 0.444 | 0.800 | 0.000 | 0.800 | 0.944 | 0.500 |
| Biased | 0.700 | 0.460 | 0.444 | 0.100 | 0.300 | 0.400 | 0.727 | 0.667 |
The two kappa values of 0.444 have different explanations. In the skewed case the prevalence index is 0.8 and agreement on the rare label is only 0.5. In the biased case the bias index is 0.3 and observed agreement itself is low.
Deciding what to do
In practice:
- Always show the confusion matrix or the label counts next to kappa. Readers can then see the prevalence themselves.
- Report per-label agreement for any label that is rare or important. Overall kappa can hide a label that annotators cannot reproduce.
- Pilot on a stratified sample when the rare label is the target. If the real rate is 3%, a random 100-item pilot may contain three examples. Add items from candidate-rich sources, then report that the pilot was enriched, because enrichment changes prevalence and therefore kappa.
- Check each annotator's label rate. A large gap suggests a threshold problem in the guidelines, so use disagreement analysis (covered in a later chapter) to find the boundary cases.
- Consider alternatives when prevalence is extreme. Gwet's AC1 is less sensitive to prevalence, and Krippendorff's alpha has similar behavior to kappa but handles more annotators and missing data. Report whichever you use by name, and keep kappa visible so others can compare.
Common errors
- Reporting only kappa, or only percent agreement. Report both, plus the label counts.
- Concluding that the annotators are unreliable because kappa is low on a heavily skewed label, without checking per-label agreement.
- Concluding that the data are reliable because kappa is moderate, without checking whether one annotator labels far more items positive.
- Using PABAK as the headline number. It removes the effect of label frequencies, so it can make a hard task look easy.
- Changing the sample composition between pilot and main round without saying so.
Exercise
Two annotators label 100 messages as "fraud" or "ok". Both mark 2 messages as fraud in different places: there are 0 messages both call fraud, 2 where only annotator 1 says fraud, 2 where only annotator 2 says fraud, and 96 where both say ok. Compute observed agreement, chance agreement and kappa, and say what this shows about prevalence.
Show answer
Observed agreement is (0 + 96) / 100 = 0.96. Each annotator labels fraud 2% of the time and ok 98% of the time, so chance agreement is 0.02 × 0.02 + 0.98 × 0.98 = 0.0004 + 0.9604 = 0.9608. Kappa is (0.96 − 0.9608) / (1 − 0.9608) = −0.0008 / 0.0392 ≈ −0.02. Despite 96% raw agreement, the annotators never agree on a fraud message, and kappa correctly shows that they do no better than chance on the rare label. Agreement on the fraud label alone is 0. This is why per-label agreement and a stratified pilot matter.