Skip to content

Commit 34fd458

Browse files
MAINT Parameter Validation for metrics.precision_score (#25708)
Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr>
1 parent 3f990bc commit 34fd458

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

sklearn/metrics/_classification.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,23 @@ class after being classified as negative. This is the case when the
19041904
return positive_likelihood_ratio, negative_likelihood_ratio
19051905

19061906

1907+
@validate_params(
1908+
{
1909+
"y_true": ["array-like", "sparse matrix"],
1910+
"y_pred": ["array-like", "sparse matrix"],
1911+
"labels": ["array-like", None],
1912+
"pos_label": [Real, str, "boolean", None],
1913+
"average": [
1914+
StrOptions({"micro", "macro", "samples", "weighted", "binary"}),
1915+
None,
1916+
],
1917+
"sample_weight": ["array-like", None],
1918+
"zero_division": [
1919+
Options(Real, {0, 1}),
1920+
StrOptions({"warn"}),
1921+
],
1922+
}
1923+
)
19071924
def precision_score(
19081925
y_true,
19091926
y_pred,

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def _check_function_param_validation(
137137
"sklearn.metrics.pairwise.additive_chi2_kernel",
138138
"sklearn.metrics.precision_recall_curve",
139139
"sklearn.metrics.precision_recall_fscore_support",
140+
"sklearn.metrics.precision_score",
140141
"sklearn.metrics.r2_score",
141142
"sklearn.metrics.roc_curve",
142143
"sklearn.metrics.zero_one_loss",

0 commit comments

Comments
 (0)