roboflow/supervision · error · ValueError
Confusion matrix must have shape (..., 3), got {confusion_ma
Error message
Confusion matrix must have shape (..., 3), got {confusion_matrix.shape} What it means
Error "Confusion matrix must have shape (..., 3), got {confusion_matrix.shape}" thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/recall.py:520
result: npt.NDArray[np.float64] = confusion_matrix
return result
@staticmethod
def _compute_recall(
confusion_matrix: npt.NDArray[np.float64],
) -> npt.NDArray[np.float64]:
"""
Broadcastable function, computing the recall from the confusion matrix.
Args:
confusion_matrix: shape (N, ..., 3), where the last dimension
contains the true positives, false positives, and false negatives.
Returns:
shape (N, ...), containing the recall for each element.
"""
if not confusion_matrix.shape[-1] == 3:
raise ValueError(
f"Confusion matrix must have shape (..., 3), got "
f"{confusion_matrix.shape}"
)
true_positives = confusion_matrix[..., 0]
false_negatives = confusion_matrix[..., 2]
denominator = true_positives + false_negatives
recall = np.divide(
true_positives,
denominator,
out=np.zeros_like(true_positives),
where=denominator != 0,
)
result_recall: npt.NDArray[np.float64] = recall
return result_recall
def _detections_content(View on GitHub (pinned to 7f254d9784)
Solutions
- Provide a confusion matrix whose last dimension is 3 (true positives, false positives, false negatives per cell).
- Do not construct the matrix manually; use the metric's own computation methods to build it.
When it happens
Trigger: Thrown at src/supervision/metrics/recall.py:520 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/e1e42eb32fb90cfb.
Report an issue: GitHub.