@@ -275,6 +275,13 @@ class OneVsRestClassifier(
275
275
276
276
.. versionadded:: 1.0
277
277
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
+
278
285
Examples
279
286
--------
280
287
>>> import numpy as np
@@ -292,13 +299,6 @@ class OneVsRestClassifier(
292
299
>>> clf = OneVsRestClassifier(SVC()).fit(X, y)
293
300
>>> clf.predict([[-19, -20], [9, 9], [-5, 5]])
294
301
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.
302
302
"""
303
303
304
304
def __init__ (self , estimator , * , n_jobs = None ):
@@ -319,7 +319,8 @@ def fit(self, X, y):
319
319
320
320
Returns
321
321
-------
322
- self
322
+ self : object
323
+ Instance of fitted estimator.
323
324
"""
324
325
# A sparse LabelBinarizer, with sparse_output=True, has been shown to
325
326
# outperform or match a dense label binarizer in all cases and has also
@@ -355,7 +356,7 @@ def fit(self, X, y):
355
356
356
357
@available_if (_estimators_has ("partial_fit" ))
357
358
def partial_fit (self , X , y , classes = None ):
358
- """Partially fit underlying estimators
359
+ """Partially fit underlying estimators.
359
360
360
361
Should be used when memory is inefficient to train all data.
361
362
Chunks of data can be passed in several iteration.
@@ -378,7 +379,8 @@ def partial_fit(self, X, y, classes=None):
378
379
379
380
Returns
380
381
-------
381
- self
382
+ self : object
383
+ Instance of partially fitted estimator.
382
384
"""
383
385
if _check_partial_fit_first_call (self , classes ):
384
386
if not hasattr (self .estimator , "partial_fit" ):
@@ -477,6 +479,7 @@ def predict_proba(self, X):
477
479
Parameters
478
480
----------
479
481
X : array-like of shape (n_samples, n_features)
482
+ Input data.
480
483
481
484
Returns
482
485
-------
@@ -501,18 +504,22 @@ def predict_proba(self, X):
501
504
502
505
@available_if (_estimators_has ("decision_function" ))
503
506
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.
507
512
508
513
Parameters
509
514
----------
510
515
X : array-like of shape (n_samples, n_features)
516
+ Input data.
511
517
512
518
Returns
513
519
-------
514
520
T : array-like of shape (n_samples, n_classes) or (n_samples,) for \
515
521
binary classification.
522
+ Result of calling `decision_function` on the final estimator.
516
523
517
524
.. versionchanged:: 0.19
518
525
output shape changed to ``(n_samples,)`` to conform to
@@ -527,11 +534,12 @@ def decision_function(self, X):
527
534
528
535
@property
529
536
def multilabel_ (self ):
530
- """Whether this is a multilabel classifier"""
537
+ """Whether this is a multilabel classifier. """
531
538
return self .label_binarizer_ .y_type_ .startswith ("multilabel" )
532
539
533
540
@property
534
541
def n_classes_ (self ):
542
+ """Number of classes."""
535
543
return len (self .classes_ )
536
544
537
545
# TODO: Remove coef_ attribute in 1.1
0 commit comments