Define the rare category you need to detect

A classifier can handle most requests correctly while barely detecting a rare category. Your test data should therefore answer two questions: how much work the system creates in everyday use, and which rare cases it misses. Prepare two separate sets for these purposes.

Our illustrative example is a print shop that routes complaints about defective completed print runs to a designated employee. The ‘defect’ category requires a described fault in products already made. Changes to an approved design, pricing questions, and requests for additional copies belong to ‘other’. Write this rule before selecting messages.

Give each example a row containing the request text, expected category, labeling rationale, source, and order identifier. Leave separate fields for the classifier’s response and the reviewer’s comment. The preparation should produce verifiable records rather than a list of conveniently chosen sentences.

Collect an everyday sample and a diagnostic set

Hugging Face’s documentation recommends making test data resemble production conditions. For our example, take 500 consecutive new requests from a period chosen in advance. Avoid searching for the word ‘defect’ or selecting only messages the classifier has already identified as problematic.

Build the second set specifically for diagnosis: for example, 40 confirmed defect reports and 40 other requests that could be confused with them. These quantities illustrate a plan; they are not required test sizes. Record how you found the messages, since keyword searches can also leave gaps.

The first set helps assess behavior on the selected everyday stream. The second provides more material for investigating the rare category. Keep them separate and avoid reporting a combined percentage: deliberately increasing the proportion of defects changes what the result means.

Review labels and record independence

Ask two people to label messages independently without seeing model responses. An illustrative message, ‘The bottom line is cut off on the finished posters’, meets the defect definition. The described fault is sufficient; the writer’s emotional tone and use of the word ‘complaint’ are irrelevant.

‘There is a problem with my order’ cannot be labeled under the agreed rule. Mark it as disputed during annotation and examine it separately. If unresolved cases are excluded from calculations, report their number and the reasons. Otherwise, the report conceals a difficult portion of the request stream.

Correspondence about one order should not become dozens of supposedly independent tests. Select one request per order or explicitly evaluate whole orders. Keep material used to adjust instructions separate from final evaluation, following Hugging Face’s guidance on data separation. Once labels are agreed, preserve a frozen version of both sets.

Count missed cases and unnecessary assignments

For each set, sort responses into four outcomes: correctly detected defects, missed defects, ordinary requests incorrectly labeled as defects, and correctly identified ordinary requests. This is a confusion matrix: Microsoft’s documentation describes it as a comparison of actual and predicted categories. Every record must enter exactly one outcome.

Recall measures the proportion of actual defect cases detected. Category precision measures the proportion of requests assigned to that category that truly belong there. Google’s course provides these definitions. Category precision and overall accuracy have different denominators, so keep their names and calculations distinct.

The following figures are hypothetical, illustrating a calculation rather than a model test. Of 500 requests, four concern defects. The classifier detects two and incorrectly routes another eight ordinary requests to the defect category. It gets 490 out of 500 answers right: 98% accuracy. However, recall is 2 out of 4, or 50%, and category precision is 2 out of 10, or 20%.

Keep percentages tied to their test sets

The diagnostic set deliberately contains a higher proportion of defects. The definition of category precision implies that its value depends on the composition of the evaluated stream. A good percentage on a collection rich in defects therefore cannot be presented as the expected proportion of correct assignments in everyday use. This follows from the metric’s definition.

Use the collection primarily to investigate causes of errors. Group missed cases by meaningful features: trimming faults, incorrect colors, or missing copies. For each feature, show the number of messages tested and missed. If every failure concerns missing quantities, you have a specific instruction issue to address.

Recall should not be transferred automatically either: deliberately collected cases may be easier or harder than everyday requests. After a revision, repeat diagnosis and then evaluate a fresh, untouched sample of the working stream. Previously investigated errors help verify a fix but cannot replace fresh evaluation.

Verify the report and state its limits

Before deciding how to use the classifier, ask a colleague to reconstruct the metrics from individual rows. The four outcomes must total the size of their respective set, and actual defect counts must match the reference labels. If a denominator is zero, report ‘not calculated’ and explain why instead of substituting a convenient percentage.

Create a result record containing the rule version, model and settings, sampling period, both set sizes, disputed records, four outcomes, and the responsible person’s decision. Define acceptable missed-case counts and workload from unnecessary assignments for the specific process beforehand. In our example, missing two of four defects supports retaining human review and collecting more data.

Four positive cases are insufficient for confidence about stability: one additional error would noticeably change the percentage. Synthetic examples can test understanding of a rule but cannot estimate operational error frequencies. Even a good evaluation remains limited by its period, request channel, and labeling quality. Revisit the sets when those conditions change.

Sources