roboflow/supervision · error · ValueError
ConfusionMatrix can only be calculated for Detections with c
Error message
ConfusionMatrix can only be calculated for Detections with confidence
What it means
Error "ConfusionMatrix can only be calculated for Detections with confidence" thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/detection.py:172
raise ValueError(
f"Expected {ORIENTED_BOX_COORDINATES} to contain "
f"{len(detections) * 8} elements "
f"(N={len(detections)} detections x 8 coordinates), "
f"but got {obb_arr.size}. "
"Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4]."
)
box_data = obb_arr.reshape(-1, 8)
else:
box_data = np.asarray(detections.xyxy, dtype=np.float32)
arrays_to_concat = [
box_data,
np.expand_dims(detections.class_id.astype(np.float32), 1),
]
if with_confidence:
if detections.confidence is None:
raise ValueError(
"ConfusionMatrix can only be calculated for Detections with confidence"
)
arrays_to_concat.append(np.expand_dims(detections.confidence, 1))
result: npt.NDArray[np.float32] = np.concatenate(arrays_to_concat, axis=1)
return result
def _validate_input_tensors(
predictions: list[npt.NDArray[np.float32]],
targets: list[npt.NDArray[np.float32]],
metric_target: MetricTarget = MetricTarget.BOXES,
) -> None:
"""
Checks for shape consistency of input tensors.
"""
if len(predictions) != len(targets):
raise ValueError(View on GitHub (pinned to 7f254d9784)
Solutions
- Set confidence on the prediction Detections before computing the confusion matrix.
- If scores are unavailable, provide a placeholder confidence array.
When it happens
Trigger: Thrown at src/supervision/metrics/detection.py:172 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/2d5f213f1f9417a4.
Report an issue: GitHub.