Sub topic 3
Checking Your AI Feedback Analysis
Assume you know basic Python, JSON, precision, recall, and averages. This chapter covers how to test analysis, control risks, scale processing, and turn results into decisions.
Checking your analysis against human labels
Create a representative sample of reviews and label it yourself, or ask trained reviewers to label it. This sample is the ground truth for comparison. Include short, long, positive, negative, mixed, and unclear reviews.
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))Precision measures how often a predicted label is correct. Recall measures how many items of a real class the model found. Cohen’s kappa measures agreement while allowing for agreement by chance.
| Metric | Useful question |
|---|---|
| Precision | Can we trust items assigned this label? |
| Recall | Did the analysis find most items with this label? |
| Kappa | Do humans and the model agree beyond chance? |
Inspect disagreements. They may show unclear label definitions, sarcasm, missing context, or systematic model errors.
Privacy, bias, fake reviews, and hallucination
Redact names, email addresses, phone numbers, and order identifiers before sending text to an external service. Limit access to raw reviews and define how long they are retained.
Feedback is rarely representative. Customers with very strong experiences may respond more often, and some channels may overrepresent particular regions or user groups. Track the source and sample size for every result.
Fake or coordinated reviews can distort trends. Look for repeated wording, unusual timing, duplicate accounts, and sudden rating changes. Treat these signals as reasons for review, not automatic proof.
A hallucination is an invented statement that is not supported by the source. Require summaries to include review identifiers or exact evidence quotes, then check those claims before publishing.
Scaling up: batching, caching, and cost
Process reviews in batches, cache results using a hash of the cleaned text and prompt version, and retry temporary API failures with a limit. Store the model name, prompt version, timestamp, and cost estimate with each result. Use cheaper methods for filtering and reserve an LLM for ambiguous or high-value cases.
From analysis to decisions
Report counts, rates, time trends, and uncertainty together. Prioritise issues by frequency, customer impact, confidence, and cost to fix. Separate observations from recommendations. Assign each action an owner, deadline, and success measure.
Exercise
The model reports that delivery is the main negative theme. What should you check before changing operations?
Show answer
Check the human-labelled sample, source mix, duplicate or fake reviews, time trend, supporting review evidence, and the expected business impact.