Sub topic 3
Fleiss' kappa for more than two annotators
This section assumes you have computed Cohen's kappa for two annotators, can load label lists in Python, and understand what a chance-corrected score means.
Fleiss' kappa measures agreement when every item gets the same number of annotators, and that number can be three or more. Build a table with one row per item and one column per category. Each cell counts how many annotators chose that category for that item.
from statsmodels.stats.inter_rater import aggregate_raters, fleiss_kappa
# Rows are items, columns are annotators, values are label codes
ratings = [
[0, 0, 0],
[0, 1, 0],
[1, 1, 1],
[2, 2, 1],
[0, 0, 0],
[1, 1, 2],
]
table, categories = aggregate_raters(ratings)
print(fleiss_kappa(table, method="fleiss"))The score is kappa = (P - Pe) / (1 - Pe). P is the mean agreement across items, and Pe is the agreement expected by chance from the category proportions.
Weighted kappa for ordinal labels
Ordinal labels, such as a 1 to 5 rating, have an order. Quadratic weights penalize a 1-versus-5 disagreement more than a 3-versus-4 one.
from sklearn.metrics import cohen_kappa_score
r1 = [1, 2, 3, 4, 5, 3, 2]
r2 = [1, 3, 3, 5, 4, 3, 1]
print(cohen_kappa_score(r1, r2, weights="quadratic"))Krippendorff's alpha for missing data and different scales
Krippendorff's alpha handles missing ratings and works with nominal, ordinal, interval and ratio scales. Install it with pip install krippendorff. Mark each missing rating with np.nan. Rows are annotators and columns are items.
import numpy as np
import krippendorff
data = np.array([
[1, 2, 3, np.nan, 1],
[1, 2, 2, 3, np.nan],
[1, 3, 3, 3, 1],
])
print(krippendorff.alpha(reliability_data=data, level_of_measurement="nominal"))Agreement for spans
Kappa needs a fixed list of items. Named-entity spans have no fixed list, so compare two annotators' spans with exact-match F1. A span counts as a match only when its start, end and label are identical.
Analyzing disagreements
Sort the disagreements by label pair, such as "neutral" versus "negative". A frequent pair usually signals an unclear guideline. Check whether the guideline gives a rule for that pair.
Adjudication and building gold labels
An adjudicator resolves each disagreement. Use the flow below to decide the next step.
Reporting annotation quality
Report each agreement measure with its item count and annotator count, so readers can judge the result.
| Measure | Value | Items | Annotators |
|---|---|---|---|
| Fleiss' kappa | 0.52 | 500 | 3 |
Include the label schema, the guideline version, and how adjudication was done.
Exercise
Six items are rated by three annotators. Why can you not use Fleiss' kappa if one item has only two ratings?
Show answer
Fleiss' kappa assumes every item has the same number of ratings. Use Krippendorff's alpha instead, because it handles missing ratings.