{"record":{"id":"e1e42eb32fb90cfb","repo":"roboflow/supervision","slug":"confusion-matrix-must-have-shape-3-got-co-e1e42e","errorCode":null,"errorMessage":"Confusion matrix must have shape (..., 3), got {confusion_matrix.shape}","messagePattern":"Confusion matrix must have shape \\(\\.\\.\\., 3\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/recall.py","lineNumber":520,"sourceCode":"        result: npt.NDArray[np.float64] = confusion_matrix\n        return result\n\n    @staticmethod\n    def _compute_recall(\n        confusion_matrix: npt.NDArray[np.float64],\n    ) -> npt.NDArray[np.float64]:\n        \"\"\"\n        Broadcastable function, computing the recall from the confusion matrix.\n\n        Args:\n            confusion_matrix: shape (N, ..., 3), where the last dimension\n                contains the true positives, false positives, and false negatives.\n\n        Returns:\n            shape (N, ...), containing the recall for each element.\n        \"\"\"\n        if not confusion_matrix.shape[-1] == 3:\n            raise ValueError(\n                f\"Confusion matrix must have shape (..., 3), got \"\n                f\"{confusion_matrix.shape}\"\n            )\n        true_positives = confusion_matrix[..., 0]\n        false_negatives = confusion_matrix[..., 2]\n\n        denominator = true_positives + false_negatives\n        recall = np.divide(\n            true_positives,\n            denominator,\n            out=np.zeros_like(true_positives),\n            where=denominator != 0,\n        )\n\n        result_recall: npt.NDArray[np.float64] = recall\n        return result_recall\n\n    def _detections_content(","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/recall.py#L502-L538","documentation":"Error \"Confusion matrix must have shape (..., 3), got {confusion_matrix.shape}\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/recall.py:520 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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"}