8000 DOC Ensures that OneVsRestClassifier passes numpydoc validation (#21014) · scikit-learn/scikit-learn@35862e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35862e9

Browse files
bharatr21glemaitre
andauthored
DOC Ensures that OneVsRestClassifier passes numpydoc validation (#21014)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent e19d235 commit 35862e9

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"NearestCentroid",
3232
"NeighborhoodComponentsAnalysis",
3333
"Normalizer",
34-
"OneVsRestClassifier",
3534
"OrdinalEncoder",
3635
"OrthogonalMatchingPursuit",
3736
"OrthogonalMatchingPursuitCV",

sklearn/multiclass.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ class OneVsRestClassifier(
275275
276276
.. versionadded:: 1.0
277277
278+
See Also
279+
--------
280+
MultiOutputClassifier : Alternate way of extending an estimator for
281+
multilabel classification.
282+
sklearn.preprocessing.MultiLabelBinarizer : Transform iterable of iterables
283+
to binary indicator matrix.
284+
278285
Examples
279286
--------
280287
>>> import numpy as np
@@ -292,13 +299,6 @@ class OneVsRestClassifier(
292299
>>> clf = OneVsRestClassifier(SVC()).fit(X, y)
293300
>>> clf.predict([[-19, -20], [9, 9], [-5, 5]])
294301
array([2, 0, 1])
295-
296-
See Also
297-
--------
298-
sklearn.multioutput.MultiOutputClassifier : Alternate way of extending an
299-
estimator for multilabel classification.
300-
sklearn.preprocessing.MultiLabelBinarizer : Transform iterable of iterables
301-
to binary indicator matrix.
302302
"""
303303

304304
def __init__(self, estimator, *, n_jobs=None):
@@ -319,7 +319,8 @@ def fit(self, X, y):
319319
320320
Returns
321321
-------
322-
self
322+
self : object
323+
Instance of fitted estimator.
323324
"""
324325
# A sparse LabelBinarizer, with sparse_output=True, has been shown to
325326
# outperform or match a dense label binarizer in all cases and has also
@@ -355,7 +356,7 @@ def fit(self, X, y):
355356

356357
@available_if(_estimators_has("partial_fit"))
357358
def partial_fit(self, X, y, classes=None):
358-
"""Partially fit underlying estimators
359+
"""Partially fit underlying estimators.
359360
360361
Should be used when memory is inefficient to train all data.
361362
Chunks of data can be passed in several iteration.
@@ -378,7 +379,8 @@ def partial_fit(self, X, y, classes=None):
378379
379380
Returns
380381
-------
381-
self
382+
self : object
383+
Instance of partially fitted estimator.
382384
"""
383385
if _check_partial_fit_first_call(self, classes):
384386
if not hasattr(self.estimator, "partial_fit"):
@@ -477,6 +479,7 @@ def predict_proba(self, X):
477479
Parameters
478480
----------
479481
X : array-like of shape (n_samples, n_features)
482+
Input data.
480483
481484
Returns
482485
-------
@@ -501,18 +504,22 @@ def predict_proba(self, X):
501504

502505
@available_if(_estimators_has("decision_function"))
503506
def decision_function(self, X):
504-
"""Returns the distance of each sample from the decision boundary for
505-
each class. This can only be used with estimators which implement the
506-
decision_function method.
507+
"""Decision function for the OneVsRestClassifier.
508+
509+
Return the distance of each sample from the decision boundary for each
510+
class. This can only be used with estimators which implement the
511+
`decision_function` method.
507512
508513
Parameters
509514
----------
510515
X : array-like of shape (n_samples, n_features)
516+
Input data.
511517
512518
Returns
513519
-------
514520
T : array-like of shape (n_samples, n_classes) or (n_samples,) for \
515521
binary classification.
522+
Result of calling `decision_function` on the final estimator.
516523
517524
.. versionchanged:: 0.19
518525
output shape changed to ``(n_samples,)`` to conform to
@@ -527,11 +534,12 @@ def decision_function(self, X):
527534

528535
@property
529536
def multilabel_(self):
530-
"""Whether this is a multilabel classifier"""
537+
"""Whether this is a multilabel classifier."""
531538
return self.label_binarizer_.y_type_.startswith("multilabel")
532539

533540
@property
534541
def n_classes_(self):
542+
"""Number of classes."""
535543
return len(self.classes_)
536544

537545
# TODO: Remove coef_ attribute in 1.1

0 commit comments

Comments
 (0)
0