roboflow/supervision · error · ValueError
Recall metric requires `class_id` and `confidence` on predic
Error message
Recall metric requires `class_id` and `confidence` on predictions.
What it means
Error "Recall metric requires `class_id` and `confidence` on predictions." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/recall.py:207
if size_category != ObjectSizeCategory.ANY:
if len(predictions) > 0:
prediction_size_mask = (
get_detection_size_category(predictions, self._metric_target)
== size_category.value
)
if len(targets) > 0:
target_size_mask = (
get_detection_size_category(targets, self._metric_target)
== size_category.value
)
if len(targets) == 0 and len(predictions) > 0:
# Only predictions are present (e.g. a background image). They produce
# no false negatives, so no recall value changes, but the classes still
# have to be tracked or `matched_classes` silently disagrees with
# Precision and F1Score for the same input.
if predictions.class_id is None or predictions.confidence is None:
raise ValueError(
"Recall metric requires `class_id` and `confidence` "
"on predictions."
)
prediction_class_ids = np.asarray(predictions.class_id, dtype=np.int32)[
prediction_size_mask
]
prediction_confidence = np.asarray(
predictions.confidence, dtype=np.float32
)[prediction_size_mask]
if len(prediction_class_ids) == 0:
continue
stats.append(
(
np.zeros(
(len(prediction_class_ids), iou_thresholds.size),
dtype=np.bool_,
),
np.zeros(View on GitHub (pinned to 7f254d9784)
Solutions
- Ensure prediction Detections have both class_id and confidence set before computing Recall.
- Populate class_id and confidence from your model outputs when constructing Detections.
When it happens
Trigger: Thrown at src/supervision/metrics/recall.py:207 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/c7adae0ffd0ce892.
Report an issue: GitHub.