{"record":{"id":"e2bc158201925217","repo":"roboflow/supervision","slug":"number-of-predictions-len-predictions-andtarg","errorCode":null,"errorMessage":"Number of predictions ({len(predictions)}) andtargets ({len(targets)}) must be equal.","messagePattern":"Number of predictions \\((.+?)\\) andtargets \\((.+?)\\) must be equal\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/detection.py","lineNumber":190,"sourceCode":"            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(\n            f\"Number of predictions ({len(predictions)}) and\"\n            f\"targets ({len(targets)}) must be equal.\"\n        )\n    if len(predictions) > 0:\n        if not isinstance(predictions[0], np.ndarray) or not isinstance(\n            targets[0], np.ndarray\n        ):\n            raise ValueError(\n                \"Predictions and targets must be lists of numpy arrays. \"\n                f\"Got {type(predictions[0])} and {type(targets[0])} instead.\"\n            )\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        )","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/detection.py#L172-L208","documentation":"Error \"Number of predictions ({len(predictions)}) andtargets ({len(targets)}) must be equal.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/detection.py:190 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass equally long lists of predictions and targets, one entry per image.","Pair each image's predictions with its corresponding target before calling the metric."],"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"}