{"record":{"id":"0c92e673aca5d5b5","repo":"roboflow/supervision","slug":"no-edges-defined-for-class-id-class-id","errorCode":null,"errorMessage":"No edges defined for class_id={class_id}.","messagePattern":"No edges defined for class_id=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/key_points/annotators.py","lineNumber":239,"sourceCode":"            ```\n        \"\"\"\n        if len(key_points) == 0:\n            return scene\n\n        for detection_index, xy in enumerate(key_points.xy):\n            if isinstance(self.edges, dict):\n                class_id = (\n                    int(key_points.class_id[detection_index])\n                    if key_points.class_id is not None\n                    else None\n                )\n                if class_id is None:\n                    raise ValueError(\n                        \"edges is a dict but class_id is None; \"\n                        \"KeyPoints must have class_id set.\"\n                    )\n                if class_id not in self.edges:\n                    raise ValueError(f\"No edges defined for class_id={class_id}.\")\n                edges = self.edges[class_id]\n            elif self.edges:\n                edges = self.edges\n            else:\n                _looked_up = SKELETONS_BY_VERTEX_COUNT.get(len(xy))\n                if not _looked_up:\n                    logger.warning(\"No skeleton found with %d vertices\", len(xy))\n                    continue\n                edges = _looked_up\n\n            for edge in edges:\n                idx_a, idx_b = _validate_edge_indices(edge=edge, vertex_count=len(xy))\n                xy_a = xy[idx_a]\n                xy_b = xy[idx_b]\n                if np.allclose(xy_a, 0) or np.allclose(xy_b, 0):\n                    continue\n                if key_points.visible is not None:\n                    if (","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/key_points/annotators.py#L221-L257","documentation":"When an image has both predictions and targets, Precision needs prediction confidence to rank predictions along the PR curve. If predictions.confidence is None at this point, compute() raises. class_id on both sides is validated just before, so this error specifically means the confidence attribute is missing.","triggerScenarios":"prediction Detections built without confidence (manual construction, GT-format arrays reused as predictions, connectors that do not emit scores) combined with non-empty targets, then compute().","commonSituations":"Hand-rolled Detections in unit tests; evaluating tracker outputs that were stripped of confidence; parsing prediction files that omit the score column.","solutions":["Attach confidence: sv.Detections(..., confidence=np.array([...], dtype=np.float32))","If no real scores exist, use np.ones(N) (constant) while noting PR ordering becomes meaningless","Regenerate predictions with a model connector (from_ultralytics etc.) that populates confidence"],"exampleFix":"# before\npreds = sv.Detections(\n    xyxy=np.array([[30.0, 30.0, 100.0, 100.0]]),\n    class_id=np.array([0]),\n)  # no confidence\nprecision.update(predictions=[preds], targets=[targets])\nprecision.compute()  # -> ValueError\n\n# after\npreds = sv.Detections(\n    xyxy=np.array([[30.0, 30.0, 100.0, 100.0]]),\n    class_id=np.array([0]),\n    confidence=np.array([0.9], dtype=np.float32),\n)","handlingStrategy":"validation","validationCode":"for d in predictions_list:\n    assert d.confidence is not None, 'predictions must carry confidence'","typeGuard":"def has_confidence(detections: sv.Detections) -> bool:\n    \"\"\"True when Detections carry per-box confidence scores.\"\"\"\n    return detections.confidence is not None","tryCatchPattern":null,"preventionTips":["Treat confidence as a mandatory field for anything fed as a prediction into PR metrics","Assert required Detections fields once at pipeline entry, not deep inside evaluation"],"tags":["metrics","precision","confidence","input-validation"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}