GAgreement & reliability · agreement.dawid_skene
Annotator models (Dawid–Skene, GLAD, MACE)
Which label is most likely right for each item, and how reliable is each annotator?
Latent-class models for labels given by several annotators, one row per label (item, annotator, label). Dawid–Skene (1979) learns a confusion matrix for every annotator and the share of each class; GLAD (Whitehill et al. 2009) gives each annotator an ability and each item a clarity, for two-class labels; MACE (Hovy et al. 2013) learns how often each annotator's label reflects the item and which labels they give otherwise. Reports a consensus label with its confidence for every item, each annotator's estimated accuracy, and a check for annotators who agree more than the model expects (copied or shared labels).
A real result
Example “Dawid skene”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
Dawid–Skene model, 6 annotators, 120 items, 534 labels; log-likelihood = −442.12
- Mean confidence
- 0.9664
- Matches majority vote
- 96.7%
- Log-likelihood
- −442.12
Plots
View data
| Annotator | Measure | Share |
|---|---|---|
| a1 | Estimated accuracy | 0.8573 |
| a2 | Estimated accuracy | 0.7767 |
| a3 | Estimated accuracy | 0.7940 |
| a4 | Estimated accuracy | 0.6725 |
| a5 | Estimated accuracy | 0.6052 |
| a6 | Estimated accuracy | 0.9204 |
| a1 | Agrees with consensus | 0.8539 |
| a2 | Agrees with consensus | 0.7865 |
| a3 | Agrees with consensus | 0.7978 |
| a4 | Agrees with consensus | 0.6782 |
| a5 | Agrees with consensus | 0.6087 |
| a6 | Agrees with consensus | 0.9318 |
View data
| Annotator | Label given | True class | Probability |
|---|---|---|---|
| a1 | positive | positive | 0.8910 |
| a1 | neutral | positive | 0.1087 |
| a1 | negative | positive | 0.0003 |
| a1 | positive | neutral | 0.0840 |
| a1 | neutral | neutral | 0.8765 |
| a1 | negative | neutral | 0.0395 |
| a1 | positive | negative | 0.0878 |
| a1 | neutral | negative | 0.1366 |
| a1 | negative | negative | 0.7756 |
| a2 | positive | positive | 0.7611 |
| a2 | neutral | positive | 0.1565 |
| a2 | negative | positive | 0.0824 |
| a2 | positive | neutral | 0.0359 |
| a2 | neutral | neutral | 0.9121 |
| a2 | negative | neutral | 0.0520 |
| a2 | positive | negative | 0.0444 |
| a2 | neutral | negative | 0.3278 |
| a2 | negative | negative | 0.6278 |
| a3 | positive | positive | 0.7618 |
| a3 | neutral | positive | 0.2379 |
| a3 | negative | positive | 0.0003 |
| a3 | positive | neutral | 0.0457 |
| a3 | neutral | neutral | 0.8714 |
| a3 | negative | neutral | 0.0828 |
| a3 | positive | negative | 0.0005 |
| a3 | neutral | negative | 0.2348 |
| a3 | negative | negative | 0.7648 |
| a4 | positive | positive | 0.7483 |
| a4 | neutral | positive | 0.1310 |
| a4 | negative | positive | 0.1207 |
| a4 | positive | neutral | 0.1612 |
| a4 | neutral | neutral | 0.6077 |
| a4 | negative | neutral | 0.2312 |
| a4 | positive | negative | 0.2346 |
| a4 | neutral | negative | 0.1354 |
| a4 | negative | negative | 0.6301 |
| a5 | positive | positive | 0.5783 |
| a5 | neutral | positive | 0.1561 |
| a5 | negative | positive | 0.2656 |
| a5 | positive | neutral | 0.1912 |
| a5 | neutral | neutral | 0.6513 |
| a5 | negative | neutral | 0.1575 |
| a5 | positive | negative | 0.2384 |
| a5 | neutral | negative | 0.1737 |
| a5 | negative | negative | 0.5879 |
| a6 | positive | positive | 0.8840 |
| a6 | neutral | positive | 0.1148 |
| a6 | negative | positive | 0.0013 |
| a6 | positive | neutral | 0.0554 |
| a6 | neutral | neutral | 0.9442 |
| a6 | negative | neutral | 0.0004 |
| a6 | positive | negative | 0.0535 |
| a6 | neutral | negative | 0.0005 |
| a6 | negative | negative | 0.9460 |
View data
| Confidence |
|---|
| 0.8079 |
| 1.0000 |
| 0.9999 |
| 1.0000 |
| 1.0000 |
| 0.9994 |
| 0.9992 |
| 0.9879 |
| 0.9830 |
| 0.9999 |
| 0.9920 |
| 0.9978 |
| 1.0000 |
| 1.0000 |
| 0.9755 |
| 0.9996 |
| 0.9901 |
| 0.9986 |
| 0.9999 |
| 0.9611 |
| 0.9616 |
| 0.9992 |
| 0.9891 |
| 0.9629 |
| 0.9602 |
| 0.8953 |
| 0.9960 |
| 0.9938 |
| 0.9966 |
| 1.0000 |
| 0.9912 |
| 1.0000 |
| 0.9998 |
| 0.9998 |
| 0.9999 |
| 0.9986 |
| 0.9963 |
| 0.9999 |
| 1.0000 |
| 0.9997 |
| 0.9995 |
| 0.9999 |
| 0.9996 |
| 0.9993 |
| 0.9767 |
| 0.9998 |
| 1.0000 |
| 0.9967 |
| 1.0000 |
| 1.0000 |
| 0.9994 |
| 0.9390 |
| 0.5766 |
| 0.9995 |
| 1.0000 |
| 0.9956 |
| 0.9966 |
| 0.9985 |
| 0.4666 |
| 0.9995 |
First 60 of 120 rows.
Assumptions
- Annotators overlap — 100% of items have two or more labels.
- Every class has items — Every class has at least 5 expected items.
- Convergence — EM converged after 107 iterations.
- Annotators label independently — No pair agrees more than 15 points above what independent labeling would give.
Annotators
| Annotator | Labels | Estimated accuracy | Agrees with consensus |
|---|---|---|---|
| a1 | 89 | 85.7% | 85.4% |
| a2 | 89 | 77.7% | 78.7% |
| a3 | 89 | 79.4% | 79.8% |
| a4 | 87 | 67.2% | 67.8% |
| a5 | 92 | 60.5% | 60.9% |
| a6 | 88 | 92.0% | 93.2% |
Labels
| Label | Estimated share | Items (consensus) | Items (majority vote) |
|---|---|---|---|
| positive | 45.6% | 56 | 59 |
| neutral | 29.8% | 35 | 36 |
| negative | 24.6% | 29 | 25 |
Least certain items
| Item | Consensus | Confidence | Majority vote | Labels |
|---|---|---|---|---|
| t059 | positive | 46.7% | positive | 3 |
| t119 | negative | 52.1% | neutral | 4 |
| t053 | neutral | 57.7% | neutral | 4 |
| t098 | positive | 70.6% | positive | 4 |
| t120 | neutral | 71.5% | neutral | 4 |
| t090 | positive | 71.7% | positive | 4 |
| t064 | positive | 76.0% | positive | 4 |
| t067 | neutral | 79.6% | neutral | 3 |
| t001 | positive | 80.8% | positive | 4 |
| t062 | neutral | 81.4% | neutral | 3 |
| t026 | positive | 89.5% | positive | 3 |
| t071 | positive | 93.0% | positive | 3 |
| t052 | positive | 93.9% | positive | 3 |
| t102 | neutral | 94.3% | neutral | 6 |
| t094 | neutral | 94.7% | neutral | 5 |
| t111 | negative | 95.3% | negative | 3 |
| t088 | neutral | 95.4% | neutral | 6 |
| t025 | positive | 96.0% | positive | 4 |
| t020 | positive | 96.1% | positive | 5 |
| t021 | positive | 96.2% | positive | 4 |
| t024 | neutral | 96.3% | neutral | 3 |
| t070 | negative | 96.5% | positive | 5 |
| t087 | neutral | 97.0% | neutral | 3 |
| t015 | negative | 97.6% | negative | 3 |
| t045 | positive | 97.7% | positive | 3 |
Pairs that agree more than independent labeling would
| Annotator | With | Shared items | Observed agreement | Expected if independent | Excess |
|---|---|---|---|---|---|
| a1 | a6 | 67 | 80.6% | 74.2% | 0.0636 |
| a4 | a6 | 65 | 67.7% | 62.6% | 0.0509 |
| a2 | a3 | 61 | 63.9% | 61.8% | 0.0215 |
| a4 | a5 | 69 | 49.3% | 47.8% | 0.0149 |
| a3 | a4 | 66 | 60.6% | 59.3% | 0.0128 |
| a2 | a5 | 70 | 52.9% | 51.9% | 0.0100 |
| a1 | a2 | 66 | 68.2% | 67.6% | 0.0058 |
| a1 | a4 | 67 | 61.2% | 61.5% | −0.0029 |
| a5 | a6 | 68 | 55.9% | 57.0% | −0.0111 |
| a1 | a3 | 67 | 68.7% | 70.2% | −0.0156 |
- EM from the majority vote; smoothing 0.01. Estimated accuracy is the expected share of an annotator's labels that match the true class. A low value is a statistical pattern, not a judgment of the person.
Dawid–Skene model, 6 annotators, 120 items, 534 labels; log-likelihood = −442.12
- Mean confidence
- 0.9664
- Matches majority vote
- 96.7%
- Log-likelihood
- −442.12
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Annotators overlap — 100% of items have two or more labels.
- Every class has items — Every class has at least 5 expected items.
- Convergence — EM converged after 107 iterations.
- Annotators label independently — No pair agrees more than 15 points above what independent labeling would give.
Annotators
| Annotator | Labels | Estimated accuracy | Agrees with consensus |
|---|---|---|---|
| a1 | 89 | 85.7% | 85.4% |
| a2 | 89 | 77.7% | 78.7% |
| a3 | 89 | 79.4% | 79.8% |
| a4 | 87 | 67.2% | 67.8% |
| a5 | 92 | 60.5% | 60.9% |
| a6 | 88 | 92.0% | 93.2% |
Labels
| Label | Estimated share | Items (consensus) | Items (majority vote) |
|---|---|---|---|
| positive | 45.6% | 56 | 59 |
| neutral | 29.8% | 35 | 36 |
| negative | 24.6% | 29 | 25 |
Least certain items
| Item | Consensus | Confidence | Majority vote | Labels |
|---|---|---|---|---|
| t059 | positive | 46.7% | positive | 3 |
| t119 | negative | 52.1% | neutral | 4 |
| t053 | neutral | 57.7% | neutral | 4 |
| t098 | positive | 70.6% | positive | 4 |
| t120 | neutral | 71.5% | neutral | 4 |
| t090 | positive | 71.7% | positive | 4 |
| t064 | positive | 76.0% | positive | 4 |
| t067 | neutral | 79.6% | neutral | 3 |
| t001 | positive | 80.8% | positive | 4 |
| t062 | neutral | 81.4% | neutral | 3 |
| t026 | positive | 89.5% | positive | 3 |
| t071 | positive | 93.0% | positive | 3 |
| t052 | positive | 93.9% | positive | 3 |
| t102 | neutral | 94.3% | neutral | 6 |
| t094 | neutral | 94.7% | neutral | 5 |
| t111 | negative | 95.3% | negative | 3 |
| t088 | neutral | 95.4% | neutral | 6 |
| t025 | positive | 96.0% | positive | 4 |
| t020 | positive | 96.1% | positive | 5 |
| t021 | positive | 96.2% | positive | 4 |
| t024 | neutral | 96.3% | neutral | 3 |
| t070 | negative | 96.5% | positive | 5 |
| t087 | neutral | 97.0% | neutral | 3 |
| t015 | negative | 97.6% | negative | 3 |
| t045 | positive | 97.7% | positive | 3 |
Pairs that agree more than independent labeling would
| Annotator | With | Shared items | Observed agreement | Expected if independent | Excess |
|---|---|---|---|---|---|
| a1 | a6 | 67 | 80.6% | 74.2% | 0.0636 |
| a4 | a6 | 65 | 67.7% | 62.6% | 0.0509 |
| a2 | a3 | 61 | 63.9% | 61.8% | 0.0215 |
| a4 | a5 | 69 | 49.3% | 47.8% | 0.0149 |
| a3 | a4 | 66 | 60.6% | 59.3% | 0.0128 |
| a2 | a5 | 70 | 52.9% | 51.9% | 0.0100 |
| a1 | a2 | 66 | 68.2% | 67.6% | 0.0058 |
| a1 | a4 | 67 | 61.2% | 61.5% | −0.0029 |
| a5 | a6 | 68 | 55.9% | 57.0% | −0.0111 |
| a1 | a3 | 67 | 68.7% | 70.2% | −0.0156 |
- EM from the majority vote; smoothing 0.01. Estimated accuracy is the expected share of an annotator's labels that match the true class. A low value is a statistical pattern, not a judgment of the person.
Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.
Worked examples in the app
- Dawid skeneannotations_sim · annotator: annotator · item: item · label: label
- Dawid skene restartsannotations_sim · annotator: annotator · item: item · label: label
- Glad relevanceannotations_sim · annotator: annotator · item: item · label: relevant
- Maceannotations_sim · annotator: annotator · item: item · label: label
- Copied annotatorannotations_copy · annotator: annotator · item: item · label: label
- Degenerate constantannotations_sim · annotator: annotator · item: item · label: label
- Degenerate single levelannotations_sim · annotator: annotator · item: item · label: label
- Degenerate n1annotations_sim · annotator: annotator · item: item · label: label
In the guides
Where it sits in the decision guides
- Labels from several annotators: Dawid–Skene, GLAD, MACE · Statistics Guide · G — Agreement / reliability
What you need
- Itemcategorical · 1 column
- The thing being labeled (a text, image or case id). Each item can have any number of labels.
- Annotatorcategorical · 1 column · 2–500 levels
- Who gave the label (a person, a crowd worker or a model). Annotators need not label every item.
- Labelcategorical / boolean · 1 column · 2–30 levels
- The category the annotator gave the item. GLAD needs exactly two categories.
Choices you make
model
- Modeldefault dawid_skene
All three find a consensus label per item; they differ in how they describe annotator errors.
- Dawid–Skene (a confusion matrix per annotator)(default) — Learns how often each annotator gives each label for each true class; the standard choice when annotators label enough items.
- GLAD (annotator ability × item clarity, two labels) — One ability per annotator and one clarity per item, so hard items count less against an annotator; two categories only.
- MACE (competence, with labels given at random otherwise) — Learns how often each annotator's label reflects the item and which labels they give otherwise; robust to careless annotators.
options
- Smoothingdefault 0.01
Pseudocount added to every count before estimating probabilities, so no error rate is exactly zero. Larger values pull estimates toward even.
- Random restartsdefault 0
Extra fits from random starting points besides the majority vote; the fit with the highest likelihood is kept. Use a few when results look unstable.
- Random seeddefault 1
Fixes the random starting points of the restarts so reruns give identical results, in Python and in R.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
Annotators overlap
Error rates are learned from items several annotators labeled; an annotator who shares no items with others is described by the model alone.
Every class has items
A class with fewer than 5 expected items gives unstable error rates for that class.
Convergence
EM stopped because no item's probabilities moved by more than 1e-10.
Annotators label independently
The models assume annotators err independently given the true class. The check refits the model without each annotator; a pair agreeing more than 15 points above what independent labeling gives, on 20+ shared items, suggests copied labels.
What it reports
- n_items
- How many items were labeled, by how many annotators, with how many labels in total, and how many label categories.
- n_annotators
- How many items were labeled, by how many annotators, with how many labels in total, and how many label categories.
- n_labels
- How many items were labeled, by how many annotators, with how many labels in total, and how many label categories.
- k
- How many items were labeled, by how many annotators, with how many labels in total, and how many label categories.
- loglik
- The log-likelihood of the labels under the fitted model, the EM iterations used and whether EM converged (1) or stopped at the limit (0).
- iterations
- The log-likelihood of the labels under the fitted model, the EM iterations used and whether EM converged (1) or stopped at the limit (0).
- converged
- The log-likelihood of the labels under the fitted model, the EM iterations used and whether EM converged (1) or stopped at the limit (0).
- mean_confidence
- The model's probability that an item's consensus label is its true label. Items below 0.8 are worth a second look.
- share_uncertain
- The model's probability that an item's consensus label is its true label. Items below 0.8 are worth a second look.
- agree_majority
- The share of items where the model's consensus label is the label most annotators gave.
- max_pair_excess
- For each pair of annotators, observed agreement on shared items minus the agreement the model expects. Large excess suggests copied labels.
- model_label
- A model that estimates each item's true label and each annotator's error rates together from labels given by several people.
Per group, level or term: share[<label>], accuracy[<annotator>], agreement[<annotator>], ability[<annotator>], competence[<annotator>]
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-6). Python uses pandas, numpy, codesplash; R uses stats, nanoparquet, codesplashr.
Default traps between the two languages
- Both engines run the same EM (codesplash.stats.annotators ↔ cs_annotator_model): log space, the soft majority vote as the start, MAP pseudocounts, stopping when no posterior moves by more than 1e-10; GLAD's inner step is the same block-coordinate Newton with step halving; restarts draw their starting posteriors from the shared Wichmann–Hill stream, and a later start must beat the best by more than 1e-9 relative, so both engines keep the same start.
- crowd-kit 1.4.2 (Apache-2.0, reference tier) reproduces Dawid–Skene to 1e-6 with a tiny pseudocount. Its GLAD stops its inner optimizer early (it reaches a lower penalized likelihood), and its MACE starts from random points only, so those two are checked by stationarity of the penalized likelihood plus agreement of the consensus labels (tests/crosscheck/hme2_annotators.py).
The exact script CodeSplash ran for example “Dawid skene” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Annotator models (Dawid–Skene, GLAD, MACE)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.dawid_skene 1.0.0 · spec 2155a83122af0e77
# Dataset: annotations_sim (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash.stats import annotators as an # Dawid–Skene, GLAD, MACE (twin of R's cs_annotator_model)
# %% Data
df = pd.read_parquet("tests/parity/fixtures/annotations_sim.parquet", columns=["item", "annotator", "label"])
n_input = len(df)
df["item"] = pd.Categorical(df["item"], categories=["t001", "t002", "t003", "t004", "t005", "t006", "t007", "t008", "t009", "t010", "t011", "t012", "t013", "t014", "t015", "t016", "t017", "t018", "t019", "t020", "t021", "t022", "t023", "t024", "t025", "t026", "t027", "t028", "t029", "t030", "t031", "t032", "t033", "t034", "t035", "t036", "t037", "t038", "t039", "t040", "t041", "t042", "t043", "t044", "t045", "t046", "t047", "t048", "t049", "t050", "t051", "t052", "t053", "t054", "t055", "t056", "t057", "t058", "t059", "t060", "t061", "t062", "t063", "t064", "t065", "t066", "t067", "t068", "t069", "t070", "t071", "t072", "t073", "t074", "t075", "t076", "t077", "t078", "t079", "t080", "t081", "t082", "t083", "t084", "t085", "t086", "t087", "t088", "t089", "t090", "t091", "t092", "t093", "t094", "t095", "t096", "t097", "t098", "t099", "t100", "t101", "t102", "t103", "t104", "t105", "t106", "t107", "t108", "t109", "t110", "t111", "t112", "t113", "t114", "t115", "t116", "t117", "t118", "t119", "t120"]) # stored level order
df["annotator"] = pd.Categorical(df["annotator"], categories=["a1", "a2", "a3", "a4", "a5", "a6"]) # stored level order
df["label"] = pd.Categorical(df["label"], categories=["positive", "neutral", "negative"]) # stored level order
df = df.dropna(subset=["item", "annotator", "label"]) # listwise deletion over the analysis columns
df["item"] = df["item"].cat.remove_unused_categories()
df["annotator"] = df["annotator"].cat.remove_unused_categories()
df["label"] = df["label"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["item", "annotator", "label"]) # infinite values stop the run (registry/errors.yaml)
# %% Codes (one row per label: item, annotator, label)
item_col, annot_col, label_col = "item", "annotator", "label"
items = [str(x) for x in df[item_col].cat.categories]
annots = [str(x) for x in df[annot_col].cat.categories]
labels = [str(x) for x in df[label_col].cat.categories]
n, m, k = len(items), len(annots), len(labels)
model = "dawid_skene"
if n < 2:
cs.cs_error("CS_E_TOO_FEW_GROUPS", column=item_col, min=2, k=n)
if m < 2:
cs.cs_error("CS_E_TOO_FEW_GROUPS", column=annot_col, min=2, k=m)
if k < 2:
cs.cs_error("CS_E_TOO_FEW_GROUPS", column=label_col, min=2, k=k)
if model == "glad" and k != 2:
cs.cs_error("CS_E_GROUP_COUNT", column=label_col, expected=2, k=k)
item = df[item_col].cat.codes.to_numpy(dtype=np.int64)
annot = df[annot_col].cat.codes.to_numpy(dtype=np.int64)
label = df[label_col].cat.codes.to_numpy(dtype=np.int64)
if not np.any(np.bincount(item, minlength=n) >= 2):
cs.cs_error("CS_E_UNDEFINED", what="Annotator error rates", reason="every item has a single label; the models learn from items that two or more annotators labeled")
# %% Fit
smoothing = 0.01
restarts = int(0)
seed = int(1)
fit = an.annotator_model(item, annot, label, n, m, k, model=model, smoothing=smoothing, restarts=restarts, seed=seed)
summ = an.annotator_summary(fit, item, annot, label, n, m, k, smoothing=smoothing)
mv = an.majority_vote(item, label, n, k)
T = fit["T"]
consensus, confidence = summ["consensus"], summ["confidence"]
model_label = {"dawid_skene": "Dawid–Skene", "glad": "GLAD", "mace": "MACE"}[model]
per_item = np.bincount(item, minlength=n)
pairs = sorted(summ["pairs"], key=lambda r: (-r[5], r[0], r[1]))
max_excess = pairs[0][5] if pairs else None
values = {
"n_items": float(n), "n_annotators": float(m), "n_labels": float(len(item)), "k": float(k),
"loglik": float(fit["loglik"]), "iterations": float(fit["iterations"]), "converged": 1.0 if fit["converged"] else 0.0,
"mean_confidence": float(np.mean(confidence)), "share_uncertain": float(np.mean(confidence < 0.8)),
"agree_majority": float(np.mean(consensus == mv)), "max_pair_excess": None if max_excess is None else float(max_excess),
"model_label": model_label,
}
share = T.mean(axis=0)
for c, lab in enumerate(labels):
values[f"share[{lab}]"] = float(share[c])
ann_rows = []
for j, a in enumerate(annots):
values[f"accuracy[{a}]"] = float(summ["accuracy"][j])
values[f"agreement[{a}]"] = float(summ["agreement"][j])
row = {"annotator": a, "labels": int(summ["n_labels"][j]), "accuracy": float(summ["accuracy"][j]),
"agreement": float(summ["agreement"][j])}
if model == "glad":
values[f"ability[{a}]"] = row["ability"] = float(fit["par"]["ability"][j])
if model == "mace":
values[f"competence[{a}]"] = row["competence"] = float(fit["par"]["competence"][j])
ann_rows.append(row)
# %% Assumptions
shared = np.zeros(m, dtype=bool)
for j in range(m):
its = np.unique(item[annot == j])
shared[j] = bool(np.any(np.isin(item[annot != j], its)))
multi = float(np.mean(per_item >= 2))
alone = [annots[j] for j in range(m) if not shared[j]]
support = T.sum(axis=0)
thin = [labels[c] for c in range(k) if support[c] < 5]
flagged = [p for p in pairs if p[2] >= 20 and p[5] > 0.15]
assumptions = [
{"key": "overlap", "label": "Annotators overlap", "status": "warn" if (alone or multi < 0.5) else "pass",
"detail": (f"No shared items for: {', '.join(alone)} — their error rates rest on the model alone. " if alone else "")
+ f"{multi:.0%} of items have two or more labels."},
{"key": "class_support", "label": "Every class has items", "status": "warn" if thin else "pass",
"detail": f"Fewer than 5 expected items in: {', '.join(thin)}." if thin else "Every class has at least 5 expected items."},
{"key": "convergence", "label": "Convergence", "status": "pass" if fit["converged"] else "warn",
"detail": f"EM {'converged' if fit['converged'] else 'stopped before converging'} after {fit['iterations']} iterations."},
{"key": "conditional_independence", "label": "Annotators label independently",
"status": "warn" if flagged else ("pass" if pairs else "info"),
"detail": (f"{annots[flagged[0][0]]} and {annots[flagged[0][1]]} agree on {flagged[0][3]:.0%} of {flagged[0][2]} shared items; independent labeling would give {flagged[0][4]:.0%}. Copied or shared labels make the consensus overconfident."
if flagged else ("No pair agrees more than 15 points above what independent labeling would give." if pairs else "Too few shared items to compare pairs of annotators."))},
]
if not fit["converged"]:
warnings.append(cs.cs_warning("CS_W_NO_CONVERGENCE", what=model_label))
# %% Tables
order = np.lexsort((np.arange(n), confidence))[:25]
item_rows = [{"item": items[i], "consensus": labels[consensus[i]], "confidence": float(confidence[i]),
"majority": labels[mv[i]], "labels": int(per_item[i])} for i in order]
class_rows = [{"label": labels[c], "share": float(share[c]), "consensus": int(np.sum(consensus == c)),
"majority": int(np.sum(mv == c))} for c in range(k)]
pair_rows = [{"a": annots[p[0]], "b": annots[p[1]], "shared": int(p[2]), "observed": float(p[3]), "expected": float(p[4]),
"excess": float(p[5])} for p in pairs[:10]]
ann_cols = [{"key": "annotator", "label": "Annotator", "type": "string"}, {"key": "labels", "label": "Labels", "type": "integer"},
{"key": "accuracy", "label": "Estimated accuracy", "type": "percent"},
{"key": "agreement", "label": "Agrees with consensus", "type": "percent"}]
if model == "glad":
ann_cols.append({"key": "ability", "label": "Ability (α)", "type": "number"})
if model == "mace":
ann_cols.append({"key": "competence", "label": "Competence (θ)", "type": "percent"})
tables = [
{"key": "annotators", "title": "Annotators", "columns": ann_cols, "rows": ann_rows},
{"key": "classes", "title": "Labels", "columns": [
{"key": "label", "label": "Label", "type": "string"}, {"key": "share", "label": "Estimated share", "type": "percent"},
{"key": "consensus", "label": "Items (consensus)", "type": "integer"}, {"key": "majority", "label": "Items (majority vote)", "type": "integer"},
], "rows": class_rows},
{"key": "uncertain", "title": "Least certain items", "columns": [
{"key": "item", "label": "Item", "type": "string"}, {"key": "consensus", "label": "Consensus", "type": "string"},
{"key": "confidence", "label": "Confidence", "type": "percent"}, {"key": "majority", "label": "Majority vote", "type": "string"},
{"key": "labels", "label": "Labels", "type": "integer"},
], "rows": item_rows},
]
if pair_rows:
tables.append({"key": "pairs", "title": "Pairs that agree more than independent labeling would", "columns": [
{"key": "a", "label": "Annotator", "type": "string"}, {"key": "b", "label": "With", "type": "string"},
{"key": "shared", "label": "Shared items", "type": "integer"}, {"key": "observed", "label": "Observed agreement", "type": "percent"},
{"key": "expected", "label": "Expected if independent", "type": "percent"}, {"key": "excess", "label": "Excess", "type": "number"},
], "rows": pair_rows})
# %% Charts
charts = [cs.chart("annotators", "cleveland-dot", "Annotators: estimated accuracy and agreement with the consensus", {
"category": cs.col("Annotator", annots + annots, "categorical", levels=annots),
"value": cs.col("Share", [float(x) for x in summ["accuracy"]] + [float(x) for x in summ["agreement"]], "numeric"),
"group": cs.col("Measure", ["Estimated accuracy"] * m + ["Agrees with consensus"] * m, "categorical",
levels=["Estimated accuracy", "Agrees with consensus"]),
}, controls={"top": min(30, max(3, m)), "sort": "value"})]
if model in ("dawid_skene", "mace"):
if model == "dawid_skene":
cm = fit["par"]["theta"]
else:
th, sp = fit["par"]["competence"], fit["par"]["spam"]
cm = (1.0 - th)[:, None, None] * np.repeat(sp[:, None, :], k, axis=1)
cm[:, np.arange(k), np.arange(k)] += th[:, None]
charts.append(cs.chart("confusion", "annotator-confusion", "How each annotator labels each true class", {
"annotator": cs.col("Annotator", [a for a in annots for _ in range(k * k)], "categorical", levels=annots),
"truth": cs.col("True class", [labels[c] for _ in annots for c in range(k) for _ in range(k)], "categorical", levels=labels),
"given": cs.col("Label given", [labels[l] for _ in annots for _ in range(k) for l in range(k)], "categorical", levels=labels),
"value": cs.col("Probability", [float(cm[j, c, l]) for j in range(m) for c in range(k) for l in range(k)], "numeric"),
}))
charts.append(cs.chart("confidence", "histogram", "Confidence in each item's consensus label", {
"x": cs.col("Confidence", [float(x) for x in confidence], "numeric"),
}, controls={"scale": "count", "kde": False}))
# %% Result
cs.publish({
"method": "agreement.dawid_skene",
"methodVersion": "1.0.0",
"title": f"Annotator model ({model_label})",
"engine": cs.engine_info("numpy", "codesplash"),
"n": int(len(item)),
"summary": f"{model_label} for {len(item)} labels from {m} annotators on {n} items: the consensus matches the majority vote on {values['agree_majority']:.0%} of items, with mean confidence {values['mean_confidence']:.2f}.",
"apa": f"{model_label} model, {m} annotators, {n} items, {len(item)} labels; log-likelihood = {cs.fmt_num(fit['loglik'], 2)}",
"statistics": [{"key": "mean_confidence", "label": "Mean confidence", "value": values["mean_confidence"]},
{"key": "agree_majority", "label": "Matches majority vote", "value": values["agree_majority"], "format": "percent"},
{"key": "loglik", "label": "Log-likelihood", "value": values["loglik"]}],
"tables": tables,
"assumptions": assumptions,
"warnings": warnings,
"notes": [f"EM from the majority vote{f' plus {restarts} random restarts' if restarts else ''}; smoothing {smoothing:g}. Estimated accuracy is the expected share of an annotator's labels that match the true class. A low value is a statistical pattern, not a judgment of the person."],
"charts": charts,
"values": values,
})
The exact script CodeSplash ran for example “Dawid skene” · R version 4.5.1 (2025-06-13)
# Annotator models (Dawid–Skene, GLAD, MACE)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method agreement.dawid_skene 1.0.0 · spec 2155a83122af0e77
# Dataset: annotations_sim (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/annotations_sim.parquet", col_select = c("item", "annotator", "label")))
n_input <- nrow(df)
df[["item"]] <- factor(df[["item"]], levels = c("t001", "t002", "t003", "t004", "t005", "t006", "t007", "t008", "t009", "t010", "t011", "t012", "t013", "t014", "t015", "t016", "t017", "t018", "t019", "t020", "t021", "t022", "t023", "t024", "t025", "t026", "t027", "t028", "t029", "t030", "t031", "t032", "t033", "t034", "t035", "t036", "t037", "t038", "t039", "t040", "t041", "t042", "t043", "t044", "t045", "t046", "t047", "t048", "t049", "t050", "t051", "t052", "t053", "t054", "t055", "t056", "t057", "t058", "t059", "t060", "t061", "t062", "t063", "t064", "t065", "t066", "t067", "t068", "t069", "t070", "t071", "t072", "t073", "t074", "t075", "t076", "t077", "t078", "t079", "t080", "t081", "t082", "t083", "t084", "t085", "t086", "t087", "t088", "t089", "t090", "t091", "t092", "t093", "t094", "t095", "t096", "t097", "t098", "t099", "t100", "t101", "t102", "t103", "t104", "t105", "t106", "t107", "t108", "t109", "t110", "t111", "t112", "t113", "t114", "t115", "t116", "t117", "t118", "t119", "t120")) # stored level order
df[["annotator"]] <- factor(df[["annotator"]], levels = c("a1", "a2", "a3", "a4", "a5", "a6")) # stored level order
df[["label"]] <- factor(df[["label"]], levels = c("positive", "neutral", "negative")) # stored level order
df <- df[stats::complete.cases(df[c("item", "annotator", "label")]), , drop = FALSE] # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("item", "annotator", "label")) # infinite values stop the run (registry/errors.yaml)
# %% Codes (one row per label: item, annotator, label)
item_col <- "item"
annot_col <- "annotator"
label_col <- "label"
items <- levels(df[[item_col]])
annots <- levels(df[[annot_col]])
labels <- levels(df[[label_col]])
n <- length(items)
m <- length(annots)
k <- length(labels)
model <- "dawid_skene"
if (n < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = item_col, min = 2, k = n)
if (m < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = annot_col, min = 2, k = m)
if (k < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = label_col, min = 2, k = k)
if (model == "glad" && k != 2) cs_error("CS_E_GROUP_COUNT", column = label_col, expected = 2, k = k)
item <- as.integer(df[[item_col]])
annot <- as.integer(df[[annot_col]])
label <- as.integer(df[[label_col]])
if (!any(tabulate(item, n) >= 2)) cs_error("CS_E_UNDEFINED", what = "Annotator error rates", reason = "every item has a single label; the models learn from items that two or more annotators labeled")
# %% Fit
smoothing <- 0.01
restarts <- as.integer(0)
seed <- as.integer(1)
fit <- cs_annotator_model(item, annot, label, n, m, k, model = model, smoothing = smoothing, restarts = restarts, seed = seed)
summ <- cs_annotator_summary(fit, item, annot, label, n, m, k, smoothing = smoothing)
mv <- cs_annotator_majority_vote(item, label, n, k)
T <- fit$T
consensus <- summ$consensus
confidence <- summ$confidence
model_label <- c(dawid_skene = "Dawid–Skene", glad = "GLAD", mace = "MACE")[[model]]
per_item <- tabulate(item, n)
pairs <- summ$pairs
if (length(pairs)) {
pm <- do.call(rbind, pairs)
pm <- pm[order(-pm[, 6], pm[, 1], pm[, 2]), , drop = FALSE]
} else pm <- matrix(numeric(0), 0, 6)
max_excess <- if (nrow(pm)) pm[1, 6] else NA_real_
values <- list(
n_items = n, n_annotators = m, n_labels = length(item), k = k,
loglik = fit$loglik, iterations = fit$iterations, converged = if (fit$converged) 1 else 0,
mean_confidence = mean(confidence), share_uncertain = mean(confidence < 0.8),
agree_majority = mean(consensus == mv), max_pair_excess = max_excess,
model_label = model_label
)
share <- colMeans(T)
for (c0 in seq_len(k)) values[[sprintf("share[%s]", labels[c0])]] <- share[c0]
ann_rows <- list()
for (j in seq_len(m)) {
a <- annots[j]
values[[sprintf("accuracy[%s]", a)]] <- summ$accuracy[j]
values[[sprintf("agreement[%s]", a)]] <- summ$agreement[j]
row <- list(annotator = a, labels = as.integer(summ$n_labels[j]), accuracy = summ$accuracy[j], agreement = summ$agreement[j])
if (model == "glad") values[[sprintf("ability[%s]", a)]] <- row$ability <- fit$par$ability[j]
if (model == "mace") values[[sprintf("competence[%s]", a)]] <- row$competence <- fit$par$competence[j]
ann_rows[[j]] <- row
}
# %% Assumptions
shared <- vapply(seq_len(m), function(j) any(item[annot != j] %in% unique(item[annot == j])), logical(1))
multi <- mean(per_item >= 2)
alone <- annots[!shared]
support <- colSums(T)
thin <- labels[support < 5]
flagged <- if (nrow(pm)) pm[pm[, 3] >= 20 & pm[, 6] > 0.15, , drop = FALSE] else pm
pct0 <- function(x) sprintf("%.0f%%", 100 * x)
assumptions <- list(
list(key = "overlap", label = "Annotators overlap", status = if (length(alone) || multi < 0.5) "warn" else "pass",
detail = paste0(if (length(alone)) sprintf("No shared items for: %s — their error rates rest on the model alone. ", paste(alone, collapse = ", ")) else "",
sprintf("%s of items have two or more labels.", pct0(multi)))),
list(key = "class_support", label = "Every class has items", status = if (length(thin)) "warn" else "pass",
detail = if (length(thin)) sprintf("Fewer than 5 expected items in: %s.", paste(thin, collapse = ", ")) else "Every class has at least 5 expected items."),
list(key = "convergence", label = "Convergence", status = if (fit$converged) "pass" else "warn",
detail = sprintf("EM %s after %d iterations.", if (fit$converged) "converged" else "stopped before converging", fit$iterations)),
list(key = "conditional_independence", label = "Annotators label independently",
status = if (nrow(flagged)) "warn" else if (nrow(pm)) "pass" else "info",
detail = if (nrow(flagged)) sprintf("%s and %s agree on %s of %d shared items; independent labeling would give %s. Copied or shared labels make the consensus overconfident.",
annots[flagged[1, 1]], annots[flagged[1, 2]], pct0(flagged[1, 4]), as.integer(flagged[1, 3]), pct0(flagged[1, 5]))
else if (nrow(pm)) "No pair agrees more than 15 points above what independent labeling would give." else "Too few shared items to compare pairs of annotators.")
)
if (!fit$converged) warnings <- c(warnings, cs_warning("CS_W_NO_CONVERGENCE", what = model_label))
# %% Tables
ord <- order(confidence, seq_len(n))[seq_len(min(25, n))]
item_rows <- lapply(ord, function(i) list(item = items[i], consensus = labels[consensus[i]], confidence = confidence[i],
majority = labels[mv[i]], labels = per_item[i]))
class_rows <- lapply(seq_len(k), function(c0) list(label = labels[c0], share = share[c0], consensus = sum(consensus == c0),
majority = sum(mv == c0)))
pair_rows <- lapply(seq_len(min(10, nrow(pm))), function(r) list(a = annots[pm[r, 1]], b = annots[pm[r, 2]], shared = as.integer(pm[r, 3]),
observed = pm[r, 4], expected = pm[r, 5], excess = pm[r, 6]))
ann_cols <- list(list(key = "annotator", label = "Annotator", type = "string"), list(key = "labels", label = "Labels", type = "integer"),
list(key = "accuracy", label = "Estimated accuracy", type = "percent"),
list(key = "agreement", label = "Agrees with consensus", type = "percent"))
if (model == "glad") ann_cols[[length(ann_cols) + 1]] <- list(key = "ability", label = "Ability (α)", type = "number")
if (model == "mace") ann_cols[[length(ann_cols) + 1]] <- list(key = "competence", label = "Competence (θ)", type = "percent")
tables <- list(
list(key = "annotators", title = "Annotators", columns = ann_cols, rows = ann_rows),
list(key = "classes", title = "Labels", columns = list(
list(key = "label", label = "Label", type = "string"), list(key = "share", label = "Estimated share", type = "percent"),
list(key = "consensus", label = "Items (consensus)", type = "integer"), list(key = "majority", label = "Items (majority vote)", type = "integer")
), rows = class_rows),
list(key = "uncertain", title = "Least certain items", columns = list(
list(key = "item", label = "Item", type = "string"), list(key = "consensus", label = "Consensus", type = "string"),
list(key = "confidence", label = "Confidence", type = "percent"), list(key = "majority", label = "Majority vote", type = "string"),
list(key = "labels", label = "Labels", type = "integer")
), rows = item_rows)
)
if (length(pair_rows)) tables[[length(tables) + 1]] <- list(key = "pairs", title = "Pairs that agree more than independent labeling would", columns = list(
list(key = "a", label = "Annotator", type = "string"), list(key = "b", label = "With", type = "string"),
list(key = "shared", label = "Shared items", type = "integer"), list(key = "observed", label = "Observed agreement", type = "percent"),
list(key = "expected", label = "Expected if independent", type = "percent"), list(key = "excess", label = "Excess", type = "number")
), rows = pair_rows)
# %% Charts
charts <- list(cs_chart("annotators", "cleveland-dot", "Annotators: estimated accuracy and agreement with the consensus", list(
category = cs_col("Annotator", c(annots, annots), "categorical", levels = annots),
value = cs_col("Share", c(summ$accuracy, summ$agreement), "numeric"),
group = cs_col("Measure", rep(c("Estimated accuracy", "Agrees with consensus"), each = m), "categorical",
levels = c("Estimated accuracy", "Agrees with consensus"))
), controls = list(top = min(30, max(3, m)), sort = "value")))
if (model %in% c("dawid_skene", "mace")) {
if (model == "dawid_skene") {
cm <- fit$par$theta
} else {
cm <- array(0, dim = c(m, k, k))
for (c0 in seq_len(k)) {
cm[, c0, ] <- (1 - fit$par$competence) * fit$par$spam
cm[, c0, c0] <- cm[, c0, c0] + fit$par$competence
}
}
grid <- expand.grid(l = seq_len(k), c = seq_len(k), j = seq_len(m))
charts[[length(charts) + 1]] <- cs_chart("confusion", "annotator-confusion", "How each annotator labels each true class", list(
annotator = cs_col("Annotator", annots[grid$j], "categorical", levels = annots),
truth = cs_col("True class", labels[grid$c], "categorical", levels = labels),
given = cs_col("Label given", labels[grid$l], "categorical", levels = labels),
value = cs_col("Probability", cm[cbind(grid$j, grid$c, grid$l)], "numeric")
))
}
charts[[length(charts) + 1]] <- cs_chart("confidence", "histogram", "Confidence in each item's consensus label", list(
x = cs_col("Confidence", confidence, "numeric")
), controls = list(scale = "count", kde = FALSE))
# %% Result
cs_publish(list(
method = "agreement.dawid_skene",
methodVersion = "1.0.0",
title = sprintf("Annotator model (%s)", model_label),
engine = cs_engine_info("stats", "codesplashr"),
n = length(item),
summary = sprintf("%s for %d labels from %d annotators on %d items: the consensus matches the majority vote on %s of items, with mean confidence %.2f.",
model_label, length(item), m, n, pct0(values$agree_majority), values$mean_confidence),
apa = sprintf("%s model, %d annotators, %d items, %d labels; log-likelihood = %s", model_label, m, n, length(item), cs_fmt_num(fit$loglik, 2)),
statistics = list(list(key = "mean_confidence", label = "Mean confidence", value = values$mean_confidence),
list(key = "agree_majority", label = "Matches majority vote", value = values$agree_majority, format = "percent"),
list(key = "loglik", label = "Log-likelihood", value = values$loglik)),
tables = tables,
assumptions = assumptions,
warnings = warnings,
notes = list(sprintf("EM from the majority vote%s; smoothing %s. Estimated accuracy is the expected share of an annotator's labels that match the true class. A low value is a statistical pattern, not a judgment of the person.",
if (restarts > 0) sprintf(" plus %d random restarts", restarts) else "", format(smoothing))),
charts = charts,
values = values
))
Sources
- Dawid, A. P., & Skene, A. M. (1979). Maximum likelihood estimation of observer error-rates using the EM algorithm. Journal of the Royal Statistical Society C, 28(1), 20–28.
- Whitehill, J., Ruvolo, P., Wu, T., Bergsma, J., & Movellan, J. (2009). Whose vote should count more: Optimal integration of labels from labelers of unknown expertise. Advances in Neural Information Processing Systems 22.
- Hovy, D., Berg-Kirkpatrick, T., Vaswani, A., & Hovy, E. (2013). Learning whom to trust with MACE. Proceedings of NAACL-HLT 2013, 1120–1130.
From the CodeSplash method registry · agreement.dawid_skene v1.0.0.