{"record":{"id":"21946a569a9410eb","repo":"roboflow/supervision","slug":"targets-must-contain-class-id-values","errorCode":null,"errorMessage":"Targets must contain class_id values.","messagePattern":"Targets must contain class_id values\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/detection.py","lineNumber":260,"sourceCode":"\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\n    prediction_count = len(filtered_predictions)\n    target_count = len(targets)\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/detection.py#L242-L278","documentation":"Error \"Targets must contain class_id values.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/detection.py:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure target arrays/Detections include class_id values.","Append the class id column to your target arrays before evaluation."],"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"}