{"record":{"id":"529f1037c78b7bbb","repo":"roboflow/supervision","slug":"predictions-must-have-shape-m-expected-pred-col","errorCode":null,"errorMessage":"Predictions must have shape (M, {expected_pred_cols}). Got {predictions.shape} instead.","messagePattern":"Predictions must have shape \\(M, (.+?)\\)\\. Got (.+?) instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/detection.py","lineNumber":909,"sourceCode":"                Detections with lower iou will be classified as `FP`.\n            metric_target: The type of detection data to use.\n                Determines IoU function (`box_iou_batch` vs\n                `oriented_box_iou_batch`) and coordinate column count.\n                `MetricTarget.MASKS` is not supported.\n\n        Returns:\n            Confusion matrix based on a single image.\n        \"\"\"\n        _assert_supported_target(metric_target)\n\n        expected_pred_cols = (\n            10 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 6\n        )\n        expected_target_cols = (\n            9 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 5\n        )\n        if predictions.ndim != 2 or predictions.shape[1] != expected_pred_cols:\n            raise ValueError(\n                f\"Predictions must have shape (M, {expected_pred_cols}). \"\n                f\"Got {predictions.shape} instead.\"\n            )\n        if targets.ndim != 2 or targets.shape[1] != expected_target_cols:\n            raise ValueError(\n                f\"Targets must have shape (N, {expected_target_cols}). \"\n                f\"Got {targets.shape} instead.\"\n            )\n\n        result_matrix: npt.NDArray[np.int32] = np.zeros(\n            (num_classes + 1, num_classes + 1), dtype=np.int32\n        )\n\n        # Filter predictions by confidence threshold\n        coords_dim = 8 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 4\n        class_id_idx = coords_dim\n        conf_idx = coords_dim + 1\n","sourceCodeStart":891,"sourceCodeEnd":927,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/detection.py#L891-L927","documentation":"Error \"Predictions must have shape (M, {expected_pred_cols}). Got {predictions.shape} instead.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/detection.py:909 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reshape the predictions array to (M, expected_pred_cols) before calling.","Check for accidental transposition or extra dimensions in the predictions 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"}