{"record":{"id":"e5a9e2f74cce5786","repo":"roboflow/supervision","slug":"the-number-of-predictions-len-predictions-and-e5a9e2","errorCode":null,"errorMessage":"The number of predictions ({len(predictions)}) and targets ({len(targets)}) during the update must be the same.","messagePattern":"The number of predictions \\((.+?)\\) and targets \\((.+?)\\) during the update must be the same\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/precision.py","lineNumber":118,"sourceCode":"        targets: Detections | list[Detections],\n    ) -> Precision:\n        \"\"\"\n        Add new predictions and targets to the metric, but do not compute the result.\n\n        Args:\n            predictions: The predicted detections.\n            targets: The target detections.\n\n        Returns:\n            The updated metric instance.\n        \"\"\"\n        if not isinstance(predictions, list):\n            predictions = [predictions]\n        if not isinstance(targets, list):\n            targets = [targets]\n\n        if len(predictions) != len(targets):\n            raise ValueError(\n                f\"The number of predictions ({len(predictions)}) and\"\n                f\" targets ({len(targets)}) during the update must be the same.\"\n            )\n\n        self._predictions_list.extend(predictions)\n        self._targets_list.extend(targets)\n\n        return self\n\n    def compute(self) -> PrecisionResult:\n        \"\"\"\n        Calculate the precision metric based on the stored predictions and ground-truth\n        data, at different IoU thresholds.\n\n        Returns:\n            The precision metric result.\n        \"\"\"\n        result = self._compute(self._predictions_list, self._targets_list)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/precision.py#L100-L136","documentation":"Error \"The number of predictions ({len(predictions)}) and targets ({len(targets)}) during the update must be the same.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/precision.py:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the same number of prediction and target Detections (one per image) to update().","Align predictions and targets by image before calling update."],"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"}