10000 MAINT Parameters validation for sklearn.preprocessing.label_binarize … · Veghit/scikit-learn@6cd7481 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cd7481

Browse files
jiawei-zhang-ajeremiedbb
authored andcommitted
MAINT Parameters validation for sklearn.preprocessing.label_binarize (scikit-learn#26078)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent fc951b9 commit 6cd7481

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sklearn/preprocessing/_label.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ..base import BaseEstimator, TransformerMixin
1919

2020
from ..utils.sparsefuncs import min_max_axis
21+
from ..utils._param_validation import Interval, validate_params
2122
from ..utils import column_or_1d
2223
from ..utils.validation import _num_samples, check_array, check_is_fitted
2324
from ..utils.multiclass import unique_labels
@@ -422,6 +423,15 @@ def _more_tags(self):
422423
return {"X_types": ["1dlabels"]}
423424

424425

426+
@validate_params(
427+
{
428+
"y": ["array-like"],
429+
"classes": ["array-like"],
430+
"neg_label": [Interval(Integral, None, None, closed="neither")],
431+
"pos_label": [Interval(Integral, None, None, closed="neither" A0B2 )],
432+
"sparse_output": ["boolean"],
433+
}
434+
)
425435
def label_binarize(y, *, classes, neg_label=0, pos_label=1, sparse_output=False):
426436
"""Binarize labels in a one-vs-all fashion.
427437

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def _check_function_param_validation(
224224
"sklearn.model_selection.train_test_split",
225225
"sklearn.preprocessing.add_dummy_feature",
226226
"sklearn.preprocessing.binarize",
227+
"sklearn.preprocessing.label_binarize",
227228
"sklearn.preprocessing.maxabs_scale",
228229
"sklearn.preprocessing.scale",
229230
"sklearn.random_projection.johnson_lindenstrauss_min_dim",

0 commit comments

Comments
 (0)
0