Skip to content

[MRG] Fix docstrings to Numpy format for LabelBinarizer #15440 #15460

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

Closed
wants to merge 8 commits into from

Conversation

paoloturati
Copy link
Contributor

@paoloturati paoloturati commented Nov 2, 2019

Reference Issues/PRs

Contribution to fix part of #15440

What does this implement/fix? Explain your changes.

Ensuring LabelBinarizer methods pass NumPy docstring validation

@TomDLT
Copy link
Member

TomDLT commented Nov 2, 2019

Please mention the issue you are addressing, in this case #15440 I guess.
This is easier for reviewers to understand why you did your pull-request.

I just noted that you mentioned the issue, but you wrote it inside comments brackets <!-- comments -->, so it was not displayed. I edited your message.

sklearn/base.py Outdated
Fits transformer to X and y with optional parameters fit_params
and returns a transformed version of X.
"""
Fit to data, then transform it. Fits transformer to X and y with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better rendered if you have a short title first (Fit to data, then transform it), then an empty line, then a more detailed description.

represents multilabel classification. Sparse matrix can be
CSR, CSC, COO, DOK, or LIL.
y : array or sparse matrix of shape [n_samples,] or
[n_samples, n_classes]. Target values. The 2-d matrix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it will be rendered correctly on the website.
I need to wait for the doc build to complete to check it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need a break line

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of changes

sklearn/base.py Outdated
@@ -172,7 +172,7 @@ def get_params(self, deep=True):

Parameters
----------
deep : bool, default=True
deep : bool, optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should keep default=True

sklearn/base.py Outdated
@@ -435,20 +435,21 @@ class ClusterMixin:
_estimator_type = "clusterer"

def fit_predict(self, X, y=None):
"""Performs clustering on X and returns cluster labels.
"""
Performs clustering on X and returns cluster labels.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Performs clustering on X and returns cluster labels.
Perform clustering on X and returns cluster labels.

sklearn/base.py Outdated
@@ -435,20 +435,21 @@ class ClusterMixin:
_estimator_type = "clusterer"

def fit_predict(self, X, y=None):
"""Performs clustering on X and returns cluster labels.
"""
Performs clustering on X and returns cluster labels.

Parameters
----------
X : ndarray, shape (n_samples, n_features)
Input data.

y : Ignored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
y : Ignored
y : None


sklearn.preprocessing.OneHotEncoder : Encode categorical features
as a one-hot numeric array.
['tokyo', 'tokyo', 'paris'].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail. You should not a full stop. This is part of the examples

@@ -244,14 +247,15 @@ def fit_transform(self, y):

Returns
-------
y : array-like of shape [n_samples]
y : array-like of shape [n_samples].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
y : array-like of shape [n_samples].
y : array-like of shape (n_samples,)

@@ -561,14 +575,19 @@ def label_binarize(y, classes, neg_label=0, pos_label=1, sparse_output=False):
pos_label : int (default: 1)
Value with which positive labels must be encoded.

sparse_output : boolean (default: False),
sparse_output : bool (default: False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sparse_output : bool (default: False),
sparse_output : bool, default=False

--------
LabelBinarizer : class used to wrap the functionality of label_binarize and
allow for fitting to classes independently of the transform operation
[1]]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[1]]).
[1]])

Part of the example

@@ -798,7 +815,7 @@ class MultiLabelBinarizer(TransformerMixin, BaseEstimator):
Indicates an ordering for the class labels.
All entries should be unique (cannot contain duplicate classes).

sparse_output : boolean (default: False),
sparse_output : bool (default: False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sparse_output : bool (default: False),
sparse_output : bool, default=False

--------
sklearn.preprocessing.OneHotEncoder : encode categorical features
using a one-hot aka one-of-K scheme.
array(['comedy', 'sci-fi', 'thriller'], dtype=object).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
array(['comedy', 'sci-fi', 'thriller'], dtype=object).
array(['comedy', 'sci-fi', 'thriller'], dtype=object)

Part of the example

@@ -966,7 +988,7 @@ def _transform(self, y, class_mapping):
Returns
-------
y_indicator : sparse CSR matrix, shape (n_samples, n_classes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
y_indicator : sparse CSR matrix, shape (n_samples, n_classes)
y_indicator : sparse matrix of shape (n_samples, n_classes)

Base automatically changed from master to main January 22, 2021 10:51
@cmarmo
Copy link
Contributor

cmarmo commented Nov 5, 2021

Referencing here #21350 as this PR addressed it.

@jeremiedbb
Copy link
Member

done as part of #20308. Thanks @paoloturati

@jeremiedbb jeremiedbb closed this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants