{"record":{"id":"83262ac90ddefc06","repo":"keras-team/keras","slug":"invalid-beta-argument-value-it-should-be-0-r","errorCode":null,"errorMessage":"Invalid `beta` argument value. It should be > 0. Received: beta={beta}","messagePattern":"Invalid `beta` argument value\\. It should be > 0\\. Received: beta=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/metrics/f_score_metrics.py","lineNumber":92,"sourceCode":"        super().__init__(name=name, dtype=dtype)\n        # Metric should be maximized during optimization.\n        self._direction = \"up\"\n\n        if average not in (None, \"micro\", \"macro\", \"weighted\"):\n            raise ValueError(\n                \"Invalid `average` argument value. Expected one of: \"\n                \"{None, 'micro', 'macro', 'weighted'}. \"\n                f\"Received: average={average}\"\n            )\n\n        if not isinstance(beta, float):\n            raise ValueError(\n                \"Invalid `beta` argument value. \"\n                \"It should be a Python float. \"\n                f\"Received: beta={beta} of type '{type(beta)}'\"\n            )\n        if beta <= 0.0:\n            raise ValueError(\n                \"Invalid `beta` argument value. \"\n                \"It should be > 0. \"\n                f\"Received: beta={beta}\"\n            )\n\n        if threshold is not None:\n            if not isinstance(threshold, float):\n                raise ValueError(\n                    \"Invalid `threshold` argument value. \"\n                    \"It should be a Python float. \"\n                    f\"Received: threshold={threshold} \"\n                    f\"of type '{type(threshold)}'\"\n                )\n            if threshold > 1.0 or threshold <= 0.0:\n                raise ValueError(\n                    \"Invalid `threshold` argument value. \"\n                    \"It should verify 0 < threshold <= 1. \"\n                    f\"Received: threshold={threshold}\"","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/metrics/f_score_metrics.py#L74-L110","documentation":"Raised by FBetaScore's __init__ when beta is a float but <= 0.0. beta weights recall against precision via beta^2, so it must be strictly positive.","triggerScenarios":"keras.metrics.FBetaScore(beta=0.0); beta=-1.0; beta computed as 0.0 by a misconfigured expression.","commonSituations":"Sweeps including 0 as boundary; sign errors; misunderstanding that beta=0 is not a valid precision-only mode.","solutions":["Use a positive float: beta=0.5 favors precision, beta=2.0 favors recall.","For precision-only behavior use keras.metrics.Precision.","Validate sweep ranges to beta > 0."],"exampleFix":"# before\nm = keras.metrics.FBetaScore(beta=0.0)\n\n# after\nm = keras.metrics.FBetaScore(beta=0.5)  # or use keras.metrics.Precision()","handlingStrategy":"validation","validationCode":"if not (beta > 0.0):\n    raise ValueError(f'beta must be > 0, got {beta}')","typeGuard":"def is_positive_float(v) -> bool:\n    return isinstance(v, float) and v > 0.0","tryCatchPattern":null,"preventionTips":["Exclude 0 and negatives from beta sweeps.","Use keras.metrics.Precision for precision-only emphasis."],"tags":["keras","metrics","fbeta","range-validation"],"backgroundTag":"invalid-argument-range","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}