Precision, Recall, and F1 for Rare Events in AI

Vladimir Lomtev•
Precision, Recall, and F1 for Rare Events in AI

To evaluate AI that looks for rare but important requests, count found events, misses, and false alarms separately. Precision shows what share of alerts are correct, while recall shows what share of real events were found. F1 combines these two measures, but it does not account for the cost of errors. High accuracy by itself does not prove that rare events are being detected.

This FAQ is for support managers, analysts, and developers choosing a classifier metric for incoming requests. The questions are tied to one task: separating messages that need urgent handling from the normal flow. The material is based on the official scikit-learn documentation, verified on November 5, 2026. All numbers below are fictional educational examples and arithmetic calculations, not production results. Model training and threshold tuning on real requests were not performed for this article.

Contents

Why can 99% accuracy still mean a useless model?

If only 10 out of 1,000 requests are urgent, an algorithm that is "always normal" will correctly label 990 requests. Its accuracy is 990 / 1000 = 99%, even though it will miss every urgent message. That is a result of the sample makeup, not proof of recognition quality.

Accuracy is the share of all correct answers. It is useful as an overall indicator, but when the target event is rare, you need to look at the errors for that event specifically. In the scikit-learn classification metrics documentation accuracy, the confusion matrix, and per-class scores are described separately.

The practical question for the report is: how many real urgent requests were in the validation set, and how many of them did the model find? If the report shows only the overall percent correct, it does not answer that question. Do not choose a model just because its accuracy is a few points higher: first compare the errors for the important class.

What do TP, FP, FN, and TN mean for support requests?

First define the positive class. Here it is an "urgent request," not a "positive review." Then match the prediction to the human reference label for each request.

Label What happened Example
TP Urgent request found A message about a full service outage is sent to the on-call person
FP Normal request labeled urgent A question about configuration is sent to the urgent queue
FN Urgent request missed A service outage stayed in the normal queue
TN Normal request classified correctly A question about configuration stayed in the normal queue

In terms of precision_score a false alarm increases the denominator of precision. In terms of recall_score a miss increases the denominator of recall. These are different errors and different questions about the process.

Make sure the ground truth and the prediction are joined by the same request ID. If the rows are accidentally reordered, the numbers can still be calculated, but they will no longer describe the classifier's performance. For preparing human labels, a separate guide to annotating requests in Label Studio will be useful.

How do you calculate precision and recall on one example?

Suppose the model marked 20 requests as urgent. Of these, 8 are truly urgent and 12 are normal. In the validation set there are 10 real urgent requests total: the model missed two of them. We get TP = 8, FP = 12, FN = 2.

  • Precision = TP / (TP + FP) = 8 / 20 = 40%.
  • Recall = TP / (TP + FN) = 8 / 10 = 80%.
  • The load on the urgent queue in this example is 20 requests, including 12 false alarms.

Precision answers the queue manager's question: "How much can we trust the alerts?" Recall answers the process owner's question: "How many important cases are we missing?" The denominators are different: for precision, it is all alerts; for recall, it is all real events. Do not simply report "80% accuracy" if it is unclear which metric was calculated.

If the model did not label anyone as urgent, precision has a zero denominator. If there are no urgent requests in the dataset at all, that denominator occurs for recall. scikit-learn provides the zero_division parameter; its behavior is described in the links above. Keep the absolute counts in the report as well: zero found events and no events in the dataset call for different conclusions.

When do you need F1, and what does it not show?

F1 is the harmonic mean of precision and recall. It is convenient for summary comparison when both sides matter and that specific trade-off is desired. By the f1_score definition, F1 = 2TP / (2TP + FP + FN).

In our example, F1 = 16 / (16 + 12 + 2) = 16 / 30, or about 53.3%. A simple average of 40% and 80% would be 60%, so you cannot substitute one formula for the other.

However, F1 does not know whether a missed service outage or an unnecessary alert to the on-call person is more costly for the company. It also does not include TN in the formula. Two solutions with similar F1 can create very different workloads for employees. Show precision, recall, FP, and FN alongside it rather than leaving only one aggregate metric.

For automatic urgency assignment, you can set a minimum acceptable recall and separately limit the number of false alarms. This is an example of problem setup, not a universal standard. The specific thresholds are determined by the process owner based on the consequences of misses and the team's available capacity.

What should you choose: macro, micro, or weighted F1?

With multiple categories, first look at the metrics for each category and its support — the number of reference examples. Then choose an averaging method. The definitions and table format are given in classification_report.

Macro calculates the average of class metrics with equal weight. That way, a rare category does not disappear from the average just because it is small. Weighted uses the number of reference examples in each class as the weight: the more common normal category has a stronger influence on the result. Micro first sums the errors across classes and then calculates the metric.

In standard single-label multiclass classification, when all classes are included, micro F1 is the same as accuracy. Do not carry this over without checking to a multilabel task or to a calculation that uses only selected categories.

If the goal is not to miss rare urgent requests, weighted F1 alone is not enough. Request a separate row for the urgent class, support, and the confusion matrix. Macro helps compare classes equally, but it also does not replace analysis of which class dropped and how many examples support it.

How does the threshold change misses and false alarms?

The threshold converts the model's numeric score into a decision. For example, "treat as urgent if the score is at least 0.7." Here 0.7 is an illustrative value, not a recommended setting. The score is not necessarily a calibrated probability: the number 0.7 by itself does not mean 70% correct decisions.

With scores held constant, lowering the threshold expands the set of positive predictions and does not reduce recall. False alarms may increase. Precision does not have to change strictly monotonically: it depends on which objects are added to the positive set. The official guide to classification threshold tuning separates score training from decision-making based on those scores.

Suggested workflow: save the scores and ground-truth labels on a validation set, compare several thresholds using TP, FP, and FN, choose an acceptable operating mode, and evaluate it once on a separate test set. Do not tune the threshold on the test set and then use that same set as independent proof of quality.

If the model outputs only a text category, this kind of tuning requires a meaningful numeric signal. Asking an LLM to provide a “confidence from 0 to 1” does not by itself make that signal suitable for threshold selection. Do not automatically transfer the workflow of a probabilistic classifier to a language model’s arbitrary self-assessment.

Does average precision replace the chosen operating threshold?

No. Average precision, or AP, summarizes precision-recall performance across different thresholds. It is a ranking metric on a specific labeled dataset. The production application still has to decide which requests go into the urgent queue.

In average_precision_score AP is defined as a weighted sum of precision, where the weight is the increment in recall. The documentation separately notes how this calculation differs from the area obtained by trapezoidal interpolation. So in your report, name the specific metric and function, not just the vague term “PR AUC.”

For a manager, two layers are useful: a ranking-quality metric and the consequences of the chosen threshold. A high AP does not tell you how many false alarms the on-call staff will get under the current settings. When comparing reports across different periods, take into account changes in the share of urgent requests and the composition of the incoming flow: the same metric name does not automatically make the datasets comparable.

What data should I request to recalculate the report?

For metrics at a fixed decision point, you only need an ID, the ground-truth label, and the predicted label. For threshold analysis, you also need a numeric score for the target class specifically. It is useful to save the request date, model version, and the rules for classifying items as urgent.

Request one row per evaluation unit. If the unit is a ticket, ten messages inside it should not quietly turn into ten independent tickets. Duplicates and repeated responses to the same event change the weights of the observations. The chosen grouping rule must be applied consistently across the solutions being compared.

Do not replace the future production flow with a artificially balanced dataset without explanation. Such a dataset may help study a rare class, but the false-alarm rate in the real flow will depend on its composition. Keep the diagnostic sample separate from the sample that represents expected production use.

Classifier evaluation is only part of operations. In the article on monitoring LLMs and AI agents the adjacent issues of quality and technical errors are covered. Here, the result is a clear category-based calculation and a justified metric choice, not a promise that the whole system is ready.

How does Vladimir Lomtev's AI studio help with classification?

Vladimir Lomtev's AI studio handles data preparation, AI solution development, integration, and testing. For a request-routing process, you can discuss preparing ground-truth labels, integrating the classifier with the queue, and comparing options on an agreed-upon sample.

The first step is to choose one request stream, describe the current routing method, data sources, and constraints. The success criterion should be defined in terms of an acceptable number of missed urgent requests and staff workload. Exact values are determined from the company's data; this material does not promise a predefined level of quality or savings. Discuss the task.

Bottom line: which metric do you need for rare events?

For a rare but important class, start with its support, TP, FP, and FN. Precision shows how reliable the positive predictions are, recall shows coverage, and F1 is one way to combine them. With multiple categories, keep the metrics for each one. Choose the threshold based on the consequences of errors on validation data, and perform the final evaluation separately. This kind of report makes it possible to discuss concrete losses and workload instead of one pretty percentage.

Request an audit

Share your contact details and we will follow up.

← All articles

Comments (0)

Loading comments…

Leave a comment
No registration required

Book a strategy call
for agentic operations

Tell us which workflow you want to improve. We will map feasibility, risks, and the fastest MVP path.

By submitting, you agree to our privacy policy

Contacts

Global Operations

Serving U.S. clients remotely
with private cloud and on-prem options

Strategy calls by request

We respond after reviewing your workflow context.

info@agentsunrise.pro

For partnership inquiries

Have a proposal?

Write to us in messengers

© 2026 AgentSunrise