From 0a8b70a931e0a979de3f7302b54048401da1f593 Mon Sep 17 00:00:00 2001 From: Juan Martin Loyola Date: Tue, 12 Oct 2021 16:48:33 -0300 Subject: [PATCH 1/3] Remove MultiLabelBinarizer from DOCSTRING_IGNORE_LIST --- maint_tools/test_docstrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index bb73b3ad3e22f..28f7ee30725a5 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -13,7 +13,6 @@ "LabelPropagation", "LabelSpreading", "LocallyLinearEmbedding", - "MultiLabelBinarizer", "MultiTaskElasticNet", "MultiTaskElasticNetCV", "MultiTaskLasso", From 35a96d81c5991b73c6575791ab07023bccb48887 Mon Sep 17 00:00:00 2001 From: Juan Martin Loyola Date: Tue, 12 Oct 2021 16:48:52 -0300 Subject: [PATCH 2/3] Fix numpydocs from MultiLabelBinarizer --- sklearn/preprocessing/_label.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sklearn/preprocessing/_label.py b/sklearn/preprocessing/_label.py index 2886f1b7f9ecf..18df846ec15fe 100644 --- a/sklearn/preprocessing/_label.py +++ b/sklearn/preprocessing/_label.py @@ -692,6 +692,11 @@ class MultiLabelBinarizer(TransformerMixin, BaseEstimator): Otherwise it corresponds to the sorted set of classes found when fitting. + See Also + -------- + OneHotEncoder : Encode categorical features using a one-hot aka one-of-K + scheme. + Examples -------- >>> from sklearn.preprocessing import MultiLabelBinarizer @@ -724,11 +729,6 @@ class MultiLabelBinarizer(TransformerMixin, BaseEstimator): MultiLabelBinarizer() >>> mlb.classes_ array(['comedy', 'sci-fi', 'thriller'], dtype=object) - - See Also - -------- - OneHotEncoder : Encode categorical features using a one-hot aka one-of-K - scheme. """ def __init__(self, *, classes=None, sparse_output=False): @@ -747,7 +747,8 @@ def fit(self, y): Returns ------- - self : returns this MultiLabelBinarizer instance + self : object + Returns this MultiLabelBinarizer instance. """ self._cached_dict = None if self.classes is None: From 93a503b360ddcdb79c240745d96c965fb7f81fb1 Mon Sep 17 00:00:00 2001 From: Juan Martin Loyola Date: Tue, 12 Oct 2021 16:54:19 -0300 Subject: [PATCH 3/3] Change docstrings to maintain consistency --- sklearn/preprocessing/_label.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sklearn/preprocessing/_label.py b/sklearn/preprocessing/_label.py index 18df846ec15fe..4410988513f39 100644 --- a/sklearn/preprocessing/_label.py +++ b/sklearn/preprocessing/_label.py @@ -748,7 +748,7 @@ def fit(self, y): Returns ------- self : object - Returns this MultiLabelBinarizer instance. + Fitted estimator. """ self._cached_dict = None if self.classes is None: @@ -779,7 +779,7 @@ def fit_transform(self, y): Returns ------- y_indicator : {ndarray, sparse matrix} of shape (n_samples, n_classes) - A matrix such that `y_indicator[i, j] = 1` i.f.f. `classes_[j]` + A matrix such that `y_indicator[i, j] = 1` iff `classes_[j]` is in `y[i]`, and 0 otherwise. Sparse matrix will be of CSR format. """ @@ -847,6 +847,10 @@ def _transform(self, y, class_mapping): Parameters ---------- y : iterable of iterables + A set of labels (any orderable and hashable object) for each + sample. If the `classes` parameter is set, `y` will not be + iterated. + class_mapping : Mapping Maps from label to column index in label indicator matrix.