{"record":{"id":"674941277cdf64e0","repo":"roboflow/supervision","slug":"predictions-must-contain-class-id-values","errorCode":null,"errorMessage":"Predictions must contain class_id values.","messagePattern":"Predictions must contain class_id values\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/detection.py","lineNumber":257,"sourceCode":"    Cross-class spatial matches are treated as:\n    - false positives for the prediction\n    - false negatives for the target\n\n    Args:\n        predictions: Predicted detections for a single image.\n        targets: Ground-truth detections for a single image.\n        conf_threshold: Confidence threshold; predictions below this are excluded.\n        iou_threshold: IoU threshold; candidate pairs below this are not matched.\n        metric_target: Coordinate representation to use for IoU computation.\n            Use ``MetricTarget.ORIENTED_BOUNDING_BOXES`` for rotated-box datasets.\n\n    Returns:\n        A 3-tuple ``(true_positives, false_positives, false_negatives)`` where\n        each element is a ``Detections`` instance sliced from the input arrays.\n    \"\"\"\n\n    if predictions.class_id is None:\n        raise ValueError(\"Predictions must contain class_id values.\")\n\n    if targets.class_id is None:\n        raise ValueError(\"Targets must contain class_id values.\")\n\n    target_class_ids = targets.class_id\n\n    if predictions.confidence is None:\n        filtered_predictions = predictions\n    else:\n        prediction_confidence = np.asarray(predictions.confidence, dtype=np.float32)\n        filtered_predictions = predictions.select(\n            prediction_confidence >= conf_threshold\n        )\n\n    filtered_prediction_class_ids = filtered_predictions.class_id\n    if filtered_prediction_class_ids is None:\n        raise ValueError(\"Predictions must contain class_id values.\")\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/detection.py#L239-L275","documentation":"Error \"Predictions must contain class_id values.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/detection.py:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure prediction arrays/Detections include class_id values.","Append the class id column to your prediction arrays (e.g. shape (N, 6) with class id included)."],"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-15T17:31:12.345Z"}