Using two independent annotation exports, first match the tickets by ID. Then calculate the agreement rate, Cohen’s kappa, and the label matrix. The matrix shows which categories diverge and which tickets should be sent for review. With 95 matches out of 100 checked tickets, kappa can be as low as 0.26. This combination is possible if both specialists almost always choose the same dominant category.
This checklist is for a support manager or analyst preparing a gold standard for an AI classifier. Input: two tables with one nominal label per ticket from each specialist. Output: a coverage summary, a matches table, and a list of specific IDs for the instruction editor. Prepared by the AI studio of Vladimir Lomtev. If you still need to collect the exports, start by configuring the annotation project. Label Studio guide.
- 1. Reconcile the full ticket list
- 2. Check the label set
- 3. Build the matrix and calculate kappa
- 4. Reproduce the calculation with two CSV files
- 5. List category pairs and review examples
- 6. Repeat the measurement after revising the rule
1. Reconcile the full ticket list
Take the planned list ticket_id and both exports with the columns ticket_id,label. Use the same instruction version and the same message set for each ID. If one specialist saw the full conversation and the other only the first message, the discrepancy may be due to different context.
Store IDs as strings. For example, 0042 and 42 can be different keys. Match records by key and separately check the number of missing values in each export. A duplicate ID for one specialist requires figuring out which record belongs to the pilot. Otherwise, the merge may multiply tickets and change the denominator.
Also check IDs that are outside the planned list. Identical exports may both miss the same ticket. Without the planned list, the result applies only to the shared IDs in the two files, and the completeness of the original batch remains unknown.
Done when the size of the planned batch, the number of pairs with two labels, and the lists of missing, extra, and duplicate IDs are known. The example below assumes a complete pair of exports and stops if there are ID mismatches between them. Reconcile with the planned list before running the example.
2. Check the label set
Fix one dictionary, for example delivery for delivery and return for returns. If the codes in the two systems differ, agree on an explicit mapping. Case changes or an extra space may be corrected by a predefined rule. Merging two categories changes the task and requires recalculating on the original pairs with a description of that change.
An empty cell means there is no label. If the instructions allow the answer “Insufficient data,” assign it a separate code and use it as a full category. Then you can see, for example, that one specialist regularly applies this label where the other guesses the ticket type.
Done when every pair has two known codes, and the remaining batch and reasons for incompleteness are shown separately. For tickets with multiple simultaneous labels, this one-class-per-person calculation does not apply. A review of the methods and assumptions was published in Computational Linguistics. Artstein and Poesio, Inter-Coder Agreement for Computational Linguistics.
3. Build the matrix and calculate kappa
Use labels from specialist A for rows and labels from specialist B for columns. Matches are on the diagonal; off-diagonal cells show different decisions on the same tickets. The direction matters for review. The cell “A: delivery, B: return” refers to different tickets than the reverse cell. Reading rows and columns this way matches the order of arguments in the matrix calculation. scikit-learn documentation for confusion_matrix.
A fictional batch of 100 tickets produces the following matrix.
| Specialist A ↓ / specialist B → | Delivery | Return | Total |
|---|---|---|---|
| Delivery | 94 | 3 | 97 |
| Return | 2 | 1 | 3 |
| Total | 96 | 4 | 100 |
Observed agreement rate p_o = (94 + 1) / 100 = 0.95. Expected rate p_e = 0.97 × 0.96 + 0.03 × 0.04 = 0.9324. The second number is the calculated agreement rate under independent label assignment while preserving each specialist’s label frequencies. Unweighted Cohen’s kappa is (p_o − p_e) / (1 − p_e), about 0.260 in this example. When p_e = 1 the denominator is zero. Show that kappa is undefined and keep the original frequencies. scikit-learn documentation for cohen_kappa_score.
Done when the sum of the cells equals the number of pairs, the diagonal sum matches the numerator of the simple agreement rate, and the report shows both metrics and the frequencies for both specialists. A kappa of about 0.26 on its own does not indicate which decision is correct.
4. Reproduce the calculation with two CSV files
Save the code as agreement.py, place the files a.csv and b.csv next to it, and run python agreement.py from this folder. Python 3 is required. The example reads a CSV with commas and the header ticket_id,label and UTF-8 encoding, allows BOM, and accepts the two categories from the example. For your classifier, replace LABELS with a standardized dictionary. CSV exported from a spreadsheet editor with a semicolon delimiter should be exported in the specified format or the delimiter should be configured explicitly in DictReader. Python documentation for the csv module.
The code version from the article was run on November 18, 2026, in Python 3.14.3 on synthetic CSV files. For the matrix above, it returned 100 pairs, an agreement rate of 0.9500, and a kappa of 0.2604. We also checked a row swap in the second export, a duplicate, a missing ID, an unknown label, and the case where both chose one category for the entire batch. Real customer requests, staff work, and the quality of the AI classifier were not checked in this run.
import csv
from collections import Counter
LABELS = ("delivery", "return")
def read_labels(path):
labels_by_id = {}
with open(path, encoding="utf-8-sig", newline="") as file:
rows = csv.DictReader(file)
if rows.fieldnames != ["ticket_id", "label"]:
raise ValueError(f"{path}: ticket_id,label header required")
for row in rows:
ticket = row["ticket_id"]
label = row["label"]
if not ticket or None in row or label not in LABELS:
raise ValueError(f"{path}: invalid row {rows.line_num}")
if ticket in labels_by_id:
raise ValueError(f"{path}: duplicate ID {ticket}")
labels_by_id[ticket] = label
return labels_by_id
a = read_labels("a.csv")
b = read_labels("b.csv")
if not a or a.keys() != b.keys():
raise ValueError("Need non-empty exports with matching IDs")
pairs = Counter((a[ticket], b[ticket]) for ticket in a)
counts_a = Counter(a.values())
counts_b = Counter(b.values())
n = len(a)
matches = sum(pairs[label, label] for label in LABELS)
expected_count = sum(counts_a[label] * counts_b[label] for label in LABELS)
denominator = n * n - expected_count
print(f"Pairs: {n}, agreement rate: {matches / n:.4f}")
if denominator:
kappa = (matches * n - expected_count) / denominator
print(f"Cohen's kappa: {kappa:.4f}")
else:
print("Cohen's kappa is undefined")
print("Columns B:", *LABELS)
for left in LABELS:
print("Row A:", left, *(pairs[left, right] for right in LABELS))
for ticket in sorted(a):
if a[ticket] != b[ticket]:
print(ticket, a[ticket], b[ticket])
Done when you have two matrix rows for your files in the order LABELS and a list of IDs off the diagonal. If you add categories, the number of rows will equal the length of LABELS. It is better to store the output next to the exports with the same access restriction: an ID can link the result to an internal ticket.
5. List the category pairs and review the examples
Of the five disagreements in the training batch, three go from “Delivery” for A to “Return” for B, and two go the other way. Only one request was classified as a return by both. Of the four requests that B marked as returns, A assigned the same label to one. This describes agreement on the selected subset. You can call the remaining cases A’s errors only after expert review.
For the editor’s instructions, a short note for the disputed case is enough. Keep both original labels, even if a third field with the final label appears after discussion.
| Field | Example to review |
|---|---|
| ID and excerpt | T-095, “The courier delivered the wrong item, I want to return it” |
| Independent labels | A — delivery, B — return |
| Question for the instructions | Does the reason for the request take priority, or the explicitly requested action? |
| Suggested solution | If the main label defines the route, put an explicit return request into the returns queue. A delivery failure should be stored in a separate reason field, if one is provided. |
Ask the queue owner to confirm which team actually handles such a request. After that, add an example with an explicit request and a neighboring example without it: “The courier delivered the wrong item, when will the correct one be delivered?”. Under the proposed rule, the second text will follow the delivery or replacement route according to your workflow. Different operational routes matter more than the outward similarity of the wording.
Done when for each selected disagreement, there is a reason and a decision. For example, the rule changed, the context did not reach one person, or the needed category is missing from the reference dictionary.
6. Repeat the measurement after revising the rule
Give two specialists a new independent sample that includes routine requests and examples around the refined boundary. Decide in advance which error matters most to reduce. In the return example, that means disputed routes for requests where the customer explicitly asks to return the item. Keep the number of such cases and the direction of the disagreements in the report.
If you intentionally assembled more returns for the check than typically appear in the live queue, note that. Changing the batch composition changes label frequencies and the expected agreement. For that reason, comparing overall kappas from two samples with different compositions is hard to interpret as a change in instruction quality. For comparison, fix the sampling method and show volumes by category. For a rare label with no observations, agreement for that label remains unknown.
Done when the new sample shows how the refined rule is applied, and the final labels assigned after review are stored separately from the original independent responses. If the dispute disappears only after joint discussion, that result describes the final gold standard. Repeat independent agreement is measured on new pairs.
How the studio helps prepare data for the classifier
Vladimir Lomtev's AI Studio helps prepare data and integrate AI classification into the workflow. In this kind of task, you can align the category scheme with the queue owner, link labeling exports by ID, and configure transfer of approved labels into the dataset for classifier validation. To get started, you need one request queue, a working label dictionary, a pair of exports, and an example of a disputed route. Discuss the task.
What to keep after validation
Save the planned ID list, the original labels from both specialists, the matching rules, the frequency matrix, and the list of disagreements. Add the instruction version and the decision on the disputed category pair. With that package, an analyst can recalculate kappa, and the queue owner can see which rule needs to be clarified before the next round of labeling.



