diff --git a/sklearn/metrics/_classification.py b/sklearn/metrics/_classification.py index f7d002ac23743..ac488ac3af772 100644 --- a/sklearn/metrics/_classification.py +++ b/sklearn/metrics/_classification.py @@ -1904,6 +1904,23 @@ class after being classified as negative. This is the case when the return positive_likelihood_ratio, negative_likelihood_ratio +@validate_params( + { + "y_true": ["array-like", "sparse matrix"], + "y_pred": ["array-like", "sparse matrix"], + "labels": ["array-like", None], + "pos_label": [Real, str, "boolean", None], + "average": [ + StrOptions({"micro", "macro", "samples", "weighted", "binary"}), + None, + ], + "sample_weight": ["array-like", None], + "zero_division": [ + Options(Real, {0, 1}), + StrOptions({"warn"}), + ], + } +) def precision_score( y_true, y_pred, diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index 4e13bb46ef645..665fc8c7af98b 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -135,6 +135,7 @@ def _check_function_param_validation( "sklearn.metrics.mutual_info_score", "sklearn.metrics.pairwise.additive_chi2_kernel", "sklearn.metrics.precision_recall_fscore_support", + "sklearn.metrics.precision_score", "sklearn.metrics.r2_score", "sklearn.metrics.roc_curve", "sklearn.metrics.zero_one_loss",