Skip to content

DOC Ensures LabelEncoder passes numpydoc validation #20456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"KernelPCA",
"KernelRidge",
"LabelBinarizer",
"LabelEncoder",
"LabelPropagation",
"LabelSpreading",
"Lars",
Expand Down
16 changes: 10 additions & 6 deletions sklearn/preprocessing/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down