Skip to content

Commit 304a5e8

Browse files
authored
DOC Ensures that LabelBinarizer passes numpydoc validation (scikit-learn#20990)
1 parent 8bf222a commit 304a5e8

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"IterativeImputer",
1919
"KBinsDiscretizer",
2020
"KNNImputer",
21-
"LabelBinarizer",
2221
"LabelPropagation",
2322
"LabelSpreading",
2423
"LocalOutlierFactor",

sklearn/preprocessing/_label.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ class LabelBinarizer(TransformerMixin, BaseEstimator):
188188
189189
Parameters
190190
----------
191-
192191
neg_label : int, default=0
193192
Value with which negative labels must be encoded.
194193
@@ -201,7 +200,6 @@ class LabelBinarizer(TransformerMixin, BaseEstimator):
201200
202201
Attributes
203202
----------
204-
205203
classes_ : ndarray of shape (n_classes,)
206204
Holds the label for each class.
207205
@@ -215,6 +213,13 @@ class LabelBinarizer(TransformerMixin, BaseEstimator):
215213
True if the input data to transform is given as a sparse matrix, False
216214
otherwise.
217215
216+
See Also
217+
--------
218+
label_binarize : Function to perform the transform operation of
219+
LabelBinarizer with fixed classes.
220+
OneHotEncoder : Encode categorical features using a one-hot aka one-of-K
221+
scheme.
222+
218223
Examples
219224
--------
220225
>>> from sklearn import preprocessing
@@ -248,13 +253,6 @@ class LabelBinarizer(TransformerMixin, BaseEstimator):
248253
[0, 1, 0],
249254
[0, 0, 1],
250255
[0, 1, 0]])
251-
252-
See Also
253-
--------
254-
label_binarize : Function to perform the transform operation of
255-
LabelBinarizer with fixed classes.
256-
OneHotEncoder : Encode categorical features using a one-hot aka one-of-K
257-
scheme.
258256
"""
259257

260258
def __init__(self, *, neg_label=0, pos_label=1, sparse_output=False):
@@ -288,7 +286,8 @@ def fit(self, y):
288286
289287
Returns
290288
-------
291-
self : returns an instance of self.
289+
self : object
290+
Returns the instance itself.
292291
"""
293292
self.y_type_ = type_of_target(y)
294293
if "multioutput" in self.y_type_:
@@ -303,8 +302,7 @@ def fit(self, y):
303302
return self
304303

305304
def fit_transform(self, y):
306-
"""Fit label binarizer and transform multi-class labels to binary
307-
labels.
305+
"""Fit label binarizer/transform multi-class labels to binary labels.
308306
309307
The output of transform is sometimes referred to as
310308
the 1-of-K coding scheme.

0 commit comments

Comments
 (0)