{"record":{"id":"4d2ca336bf2a512f","repo":"keras-team/keras","slug":"invalid-auc-curve-value-key-expected-values","errorCode":null,"errorMessage":"Invalid AUC curve value: \"{key}\". Expected values are [\"PR\", \"ROC\", \"PRGAIN\"]","messagePattern":"Invalid AUC curve value: \"(.+?)\"\\. Expected values are \\[\"PR\", \"ROC\", \"PRGAIN\"\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/metrics/metrics_utils.py","lineNumber":58,"sourceCode":"\n\nclass AUCCurve(Enum):\n    \"\"\"Type of AUC Curve (ROC or PR).\"\"\"\n\n    ROC = \"ROC\"\n    PR = \"PR\"\n    PRGAIN = \"PRGAIN\"\n\n    @staticmethod\n    def from_str(key):\n        if key in (\"pr\", \"PR\"):\n            return AUCCurve.PR\n        elif key in (\"roc\", \"ROC\"):\n            return AUCCurve.ROC\n        elif key in (\"prgain\", \"PRGAIN\"):\n            return AUCCurve.PRGAIN\n        else:\n            raise ValueError(\n                f'Invalid AUC curve value: \"{key}\". '\n                'Expected values are [\"PR\", \"ROC\", \"PRGAIN\"]'\n            )\n\n\nclass AUCSummationMethod(Enum):\n    \"\"\"Type of AUC summation method.\n\n    https://en.wikipedia.org/wiki/Riemann_sum)\n\n    Contains the following values:\n    * 'interpolation': Applies mid-point summation scheme for `ROC` curve. For\n      `PR` curve, interpolates (true/false) positives but not the ratio that is\n      precision (see Davis & Goadrich 2006 for details).\n    * 'minoring': Applies left summation for increasing intervals and right\n      summation for decreasing intervals.\n    * 'majoring': Applies right summation for increasing intervals and left\n      summation for decreasing intervals.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/metrics/metrics_utils.py#L40-L76","documentation":"AUC accepts its curve parameter as an AUCCurve enum or a case-insensitive string. AUCCurve.from_str() recognizes only the keys roc/ROC, pr/PR and prgain/PRGAIN, and raises this ValueError for anything else. Names like 'precision-recall' or 'ROCC' are rejected.","triggerScenarios":"Calling keras.metrics.AUC(curve='precision-recall') or AUC(curve='sketch-roc') - any string other than the roc/pr/prgain variants.","commonSituations":"Assuming scikit-learn style naming ('precision', 'roc_auc_score') transfers to Keras; typo'd values coming from config files.","solutions":["Use exactly 'ROC', 'PR', or 'PRGAIN' (case-insensitive).","For a precision-recall AUC pass curve='PR'; for gain curves pass 'PRGAIN'.","Or pass the enum directly: keras.metrics.AUC(curve=AUCCurve.PR) (the string form is preferred)."],"exampleFix":"# before\nauc = keras.metrics.AUC(curve='precision-recall')\n\n# after\nauc = keras.metrics.AUC(curve='PR')","handlingStrategy":"validation","validationCode":"VALID_CURVES = {'roc', 'pr', 'prgain'}\ndef check_curve(c):\n    if isinstance(c, str) and c.lower() not in VALID_CURVES:\n        raise ValueError(f'curve must be one of {sorted(VALID_CURVES)}')\n    return c","typeGuard":"def is_valid_auc_curve(c) -> bool:\n    return not isinstance(c, str) or c.lower() in {'roc', 'pr', 'prgain'}","tryCatchPattern":null,"preventionTips":["Whitelist AUC curve strings from configs before passing them to AUC."],"tags":["keras","metrics","auc","enum","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}