-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[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
Conversation
labelBin: fixed docstring
|
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y : Ignored | |
y : None |
sklearn/preprocessing/_label.py
Outdated
|
||
sklearn.preprocessing.OneHotEncoder : Encode categorical features | ||
as a one-hot numeric array. | ||
['tokyo', 'tokyo', 'paris']. |
There was a problem hiding this comment.
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
sklearn/preprocessing/_label.py
Outdated
@@ -244,14 +247,15 @@ def fit_transform(self, y): | |||
|
|||
Returns | |||
------- | |||
y : array-like of shape [n_samples] | |||
y : array-like of shape [n_samples]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y : array-like of shape [n_samples]. | |
y : array-like of shape (n_samples,) |
sklearn/preprocessing/_label.py
Outdated
@@ -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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sparse_output : bool (default: False), | |
sparse_output : bool, default=False |
sklearn/preprocessing/_label.py
Outdated
-------- | ||
LabelBinarizer : class used to wrap the functionality of label_binarize and | ||
allow for fitting to classes independently of the transform operation | ||
[1]]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sparse_output : bool (default: False), | |
sparse_output : bool, default=False |
sklearn/preprocessing/_label.py
Outdated
-------- | ||
sklearn.preprocessing.OneHotEncoder : encode categorical features | ||
using a one-hot aka one-of-K scheme. | ||
array(['comedy', 'sci-fi', 'thriller'], dtype=object). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array(['comedy', 'sci-fi', 'thriller'], dtype=object). | |
array(['comedy', 'sci-fi', 'thriller'], dtype=object) |
Part of the example
sklearn/preprocessing/_label.py
Outdated
@@ -966,7 +988,7 @@ def _transform(self, y, class_mapping): | |||
Returns | |||
------- | |||
y_indicator : sparse CSR matrix, shape (n_samples, n_classes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y_indicator : sparse CSR matrix, shape (n_samples, n_classes) | |
y_indicator : sparse matrix of shape (n_samples, n_classes) |
Referencing here #21350 as this PR addressed it. |
done as part of #20308. Thanks @paoloturati |
Reference Issues/PRs
Contribution to fix part of #15440
What does this implement/fix? Explain your changes.
Ensuring LabelBinarizer methods pass NumPy docstring validation