8000 MAINT Parameters validation for metrics.classification_report (#25868) · scikit-learn/scikit-learn@7be45e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7be45e1

Browse files
author
Théophile Baranger
authored
MAINT Parameters validation for metrics.classification_report (#25868)
1 parent 438697b commit 7be45e1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

sklearn/metrics/_classification.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,21 @@ def balanced_accuracy_score(y_true, y_pred, *, sample_weight=None, adjusted=Fals
23502350
return score
23512351

23522352

2353+
@validate_params(
2354+
{
2355+
"y_true": ["array-like", "sparse matrix"],
2356+
"y_pred": ["array-like", "sparse matrix"],
2357+
"labels": ["array-like", None],
2358+
"target_names": ["array-like", None],
2359+
"sample_weight": ["array-like", None],
2360+
"digits": [Interval(Integral, 0, None, closed="left")],
2361+
"output_dict": ["boolean"],
2362+
"zero_division": [
2363+
Options(Real, {0, 1}),
2364+
StrOptions({"warn"}),
2365+
],
2366+
}
2367+
)
23532368
def classification_report(
23542369
y_true,
23552370
y_pred,
@@ -2376,7 +2391,7 @@ def classification_report(
23762391
labels : array-like of shape (n_labels,), default=None
23772392
Optional list of label indices to include in the report.
23782393
2379-
target_names : list of str of shape (n_labels,), default=None
2394+
target_names : array-like of shape (n_labels,), default=None
23802395
Optional display names matching the labels (same order).
23812396
23822397
sample_weight : array-like of shape (n_samples,), default=None

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def _check_function_param_validation(
151151
"sklearn.metrics.balanced_accuracy_score",
152152
"sklearn.metrics.brier_score_loss",
153153
"sklearn.metrics.class_likelihood_ratios",
154+
"sklearn.metrics.classification_report",
154155
"sklearn.metrics.cluster.contingency_matrix",
155156
"sklearn.metrics.cohen_kappa_score",
156157
"sklearn.metrics.confusion_matrix",

0 commit comments

Comments
 (0)
0