{"record":{"id":"2d5f213f1f9417a4","repo":"roboflow/supervision","slug":"confusionmatrix-can-only-be-calculated-for-detecti-2d5f21","errorCode":null,"errorMessage":"ConfusionMatrix can only be calculated for Detections with confidence","messagePattern":"ConfusionMatrix can only be calculated for Detections with confidence","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/detection.py","lineNumber":172,"sourceCode":"                raise ValueError(\n                    f\"Expected {ORIENTED_BOX_COORDINATES} to contain \"\n                    f\"{len(detections) * 8} elements \"\n                    f\"(N={len(detections)} detections x 8 coordinates), \"\n                    f\"but got {obb_arr.size}. \"\n                    \"Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4].\"\n                )\n            box_data = obb_arr.reshape(-1, 8)\n    else:\n        box_data = np.asarray(detections.xyxy, dtype=np.float32)\n\n    arrays_to_concat = [\n        box_data,\n        np.expand_dims(detections.class_id.astype(np.float32), 1),\n    ]\n\n    if with_confidence:\n        if detections.confidence is None:\n            raise ValueError(\n                \"ConfusionMatrix can only be calculated for Detections with confidence\"\n            )\n        arrays_to_concat.append(np.expand_dims(detections.confidence, 1))\n\n    result: npt.NDArray[np.float32] = np.concatenate(arrays_to_concat, axis=1)\n    return result\n\n\ndef _validate_input_tensors(\n    predictions: list[npt.NDArray[np.float32]],\n    targets: list[npt.NDArray[np.float32]],\n    metric_target: MetricTarget = MetricTarget.BOXES,\n) -> None:\n    \"\"\"\n    Checks for shape consistency of input tensors.\n    \"\"\"\n    if len(predictions) != len(targets):\n        raise ValueError(","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/detection.py#L154-L190","documentation":"Error \"ConfusionMatrix can only be calculated for Detections with confidence\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/detection.py:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set confidence on the prediction Detections before computing the confusion matrix.","If scores are unavailable, provide a placeholder confidence array."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}