Sub topic 13
Krippendorff's Alpha for Missing Data and Different Scales
Assume you know Python lists and functions, basic proportions, and the ideas behind Cohen's and Fleiss' kappa. This chapter focuses on choosing and interpreting Krippendorff's alpha when annotators do not label every item or when labels have different measurement levels.
Why use Krippendorff's alpha?
Krippendorff's alpha measures agreement among annotators while correcting for agreement expected by chance. It is useful when:
- There are two or more annotators.
- Some annotators skipped some items.
- Different items have different numbers of ratings.
- Labels are nominal, ordinal, interval, or ratio measurements.
- You need one general framework for several annotation designs.
Cohen's kappa expects two annotators and a complete set of paired labels. Fleiss' kappa supports several annotators, but it also expects every item to have the same number of ratings. Alpha can ignore missing ratings on an item-by-item basis.
The working model
Alpha is based on disagreement rather than agreement:
\alpha = 1 - \frac{D_o}{D_e}- \(D_o\) is the observed disagreement between annotators.
- \(D_e\) is the disagreement expected from the overall distribution of labels.
If \(D_o = 0\), annotators agree perfectly and alpha is 1. If observed disagreement equals expected disagreement, alpha is 0. Negative values mean the annotators disagree more than the chance model predicts.
For each item, alpha forms pairs from the available ratings. An item with three ratings contributes more possible pairs than an item with two ratings. An item with only one rating contributes no agreement information, so it is skipped for that calculation.
Choosing a distance function
The distance function determines what counts as a serious disagreement.
| Data scale | Example | Meaning of disagreement |
|---|---|---|
| Nominal | `positive`, `negative`, `neutral` | Any unequal labels disagree equally |
| Ordinal | `low`, `medium`, `high` | `low` versus `high` is worse than adjacent labels |
| Interval | Temperature in Celsius | Numeric differences have meaningful size |
| Ratio | Duration or count | Ratios and zero have meaningful interpretations |
For nominal labels, use a distance of 0 for a match and 1 for a mismatch. For ordinal and numeric data, use an implementation that applies the standard alpha distance for that scale. Do not treat category names as numbers unless their order has been defined first.
The following small implementation shows nominal alpha with missing values represented by None.
from collections import Counter, defaultdict
def nominal_alpha(ratings):
coincidence = defaultdict(float)
for item in ratings:
values = [value for value in item if value is not None]
n = len(values)
if n < 2:
continue
counts = Counter(values)
for first, count_first in counts.items():
for second, count_second in counts.items():
pairs = count_first * count_second
if first == second:
pairs -= count_first
coincidence[first, second] += pairs / (n - 1)
total = sum(coincidence.values())
if total == 0:
raise ValueError("At least one item needs two ratings")
marginals = Counter()
for (first, _), count in coincidence.items():
marginals[first] += count
observed = 0.0
for (first, second), count in coincidence.items():
if first != second:
observed += count
observed /= total
expected = 0.0
for first in marginals:
for second in marginals:
if first != second:
expected += marginals[first] * marginals[second] / (total - 1)
expected /= total
if expected == 0:
raise ValueError("Expected disagreement is zero")
return 1 - observed / expected
ratings = [
["pos", "pos", "neg"],
["pos", None, "pos"],
["neg", "neg", "neg"],
["neu", "neg", None],
]
print(round(nominal_alpha(ratings), 3))Limits and reporting
Missingness is not automatically harmless. If one annotator skips difficult items while another labels them, alpha describes the remaining paired data and may hide a sampling problem. Record how many items each annotator labeled and why values are missing.
Alpha can also be undefined when every observed label is the same. In that case, expected disagreement is zero. Report this condition instead of replacing it with a convenient score.
When reporting alpha, include the number of items, number of annotators, missing-label policy, label scale, distance function, and the resulting score. Also report disagreement counts or examples. A single alpha value cannot show whether disagreements came from ambiguous guidelines, rare labels, or systematic annotator bias.
Exercise
Three annotators label an item as high, high, and medium. A fourth annotator leaves it blank. Should the blank be treated as a fourth disagreement?
Show answer
No. Missing values are omitted from that item's pair calculations. The item contributes pairs from the three available ratings, and the missing-label policy should be reported.