diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 9b23b1789aeb4..412e68b82eaab 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -72,7 +72,6 @@ "KernelPCA", "KernelRidge", "LabelBinarizer", - "LabelEncoder", "LabelPropagation", "LabelSpreading", "Lars", diff --git a/sklearn/preprocessing/_label.py b/sklearn/preprocessing/_label.py index 224eeda00d124..d460dd3c3f9ab 100644 --- a/sklearn/preprocessing/_label.py +++ b/sklearn/preprocessing/_label.py @@ -49,6 +49,12 @@ class LabelEncoder(TransformerMixin, BaseEstimator): classes_ : ndarray of shape (n_classes,) Holds the label for each class. + See Also + -------- + OrdinalEncoder : Encode categorical features using an ordinal encoding + scheme. + OneHotEncoder : Encode categorical features as a one-hot numeric array. + Examples -------- `LabelEncoder` can be used to normalize labels. @@ -76,12 +82,6 @@ class LabelEncoder(TransformerMixin, BaseEstimator): array([2, 2, 1]...) >>> list(le.inverse_transform([2, 2, 1])) ['tokyo', 'tokyo', 'paris'] - - See Also - -------- - OrdinalEncoder : Encode categorical features using an ordinal encoding - scheme. - OneHotEncoder : Encode categorical features as a one-hot numeric array. """ def fit(self, y): @@ -95,6 +95,7 @@ def fit(self, y): Returns ------- self : returns an instance of self. + Fitted label encoder. """ y = column_or_1d(y, warn=True) self.classes_ = _unique(y) @@ -111,6 +112,7 @@ def fit_transform(self, y): Returns ------- y : array-like of shape (n_samples,) + Encoded labels. """ y = column_or_1d(y, warn=True) self.classes_, y = _unique(y, return_inverse=True) @@ -127,6 +129,7 @@ def transform(self, y): Returns ------- y : array-like of shape (n_samples,) + Labels as normalized encodings. """ check_is_fitted(self) y = column_or_1d(y, warn=True) @@ -147,6 +150,7 @@ def inverse_transform(self, y): Returns ------- y : ndarray of shape (n_samples,) + Original encoding. """ check_is_fitted(self) y = column_or_1d(y, warn=True)