Sub topic 9
Checking your analysis against human labels
This chapter assumes you can read basic Python, know what precision and recall mean, and have a set of model labels from an earlier step, such as sentiment scores or LLM-extracted themes. You will compare those labels with labels written by people, and decide whether the analysis is good enough to trust.
Why you need a human-labelled sample
A model can return confident, well-formatted labels that are wrong. The only way to find out is to compare its output with a trusted reference. For customer feedback, the reference is a sample of reviews that people have labelled using your taxonomy.
Keep the sample small enough to label by hand and large enough to be useful. A few hundred reviews is a common starting point. Draw it at random, then check that it contains enough reviews from rare classes. If only 3% of reviews are about support, a random sample of 200 contains about six of them, which is too few to measure anything.
Label guidelines matter as much as the sample. Write down what each label means, with one or two examples. Without that, two people will label the same review differently, and you will not know whether the model or the guidelines are at fault.
The evaluation loop
Per-class metrics and chance-corrected agreement
Overall accuracy hides problems. If 80% of reviews are positive, a model that always says "positive" scores 80% accuracy and tells you nothing. Per-class precision and recall show where the model fails.
- Precision for a class: of the reviews the model put in this class, how many were right.
- Recall for a class: of the reviews humans put in this class, how many the model found.
Cohen's kappa measures agreement between two labellers after removing the agreement expected by chance. A value of 1 means perfect agreement, and 0 means no better than chance.
from sklearn.metrics import classification_report, cohen_kappa_score
human = ["positive", "negative", "negative", "neutral", "positive", "negative"]
model = ["positive", "negative", "neutral", "neutral", "positive", "positive"]
print(classification_report(human, model, zero_division=0))
print("Cohen's kappa:", cohen_kappa_score(human, model))The zero_division=0 argument stops scikit-learn from raising a warning when a class has no predictions. Here the model mislabelled two negative reviews, one as neutral and one as positive. Negative recall is therefore 1 out of 3 correct labels missed twice, which is 0.33. Read the report for the classes you care about most, not only the averages.
Common rough guides read kappa below 0.4 as weak, 0.4 to 0.6 as moderate, 0.6 to 0.8 as substantial, and above 0.8 as strong. Treat these as conventions, not rules. Pick a threshold based on what a wrong label costs you.
Human agreement sets the ceiling
Have two people label at least part of the sample, and compute kappa between them. If humans agree at 0.6, you should not expect the model to reach 0.9 against either person. Low human agreement usually means the labels are vague, for example "mixed" versus "neutral". Fix the guidelines first.
Multi-label themes
Themes from the LLM extraction step are lists, since one review can mention delivery and pricing. Evaluate each theme as its own yes/no question. For each theme, compute precision and recall of "this theme is present". This avoids counting a partly correct list as wholly wrong.
Common errors
- Evaluating on reviews you used to tune the prompt. Keep a separate test set and do not look at it while editing the prompt.
- Reporting accuracy alone on skewed classes.
- Trusting a tiny class. With six examples, one change moves recall by about 17 points. Report counts next to the metrics.
- Letting the model see human labels, or letting annotators see model labels, before they label. This inflates agreement.
- Forgetting drift. Re-check a fresh sample when the product, the model version or the review source changes.
Exercise
A model labels 100 reviews. Humans label 90 as positive and 10 as negative. The model labels every review positive. What are its accuracy, and its recall and precision for the negative class?
Show answer
Accuracy is 90%. Negative recall is 0, because it finds none of the 10 negative reviews. Negative precision is undefined (zero predictions), and scikit-learn reports it as 0 when zero_division=0. Accuracy looks good but the model is useless for finding complaints.
Exercise
Two annotators reach a kappa of 0.45 on your labels, and the model reaches 0.42 against one of them. Should you spend time improving the prompt?
Show answer
Not yet. The model is close to the human-to-human level, so the labels themselves are the limit. Clarify the guidelines, relabel, and measure again before changing the prompt.