8000 DOC Adds example to OneVsRestClassifier (#15201) · crankycoder/scikit-learn@818500b · GitHub
[go: up one dir, main page]

Skip to content

Commit 818500b

Browse files
veerlosarrth
authored andcommitted
DOC Adds example to OneVsRestClassifier (scikit-learn#15201)
1 parent 1edecd6 commit 818500b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sklearn/multiclass.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,22 @@ class OneVsRestClassifier(MultiOutputMixin, ClassifierMixin,
181181
multilabel_ : boolean
182182
Whether a OneVsRestClassifier is a multilabel classifier.
183183
184+
>>> import numpy as np
185+
>>> from sklearn.multiclass import OneVsRestClassifier
186+
>>> from sklearn.svm import SVC
187+
>>> X = np.array([
188+
... [10, 10],
189+
... [8, 10],
190+
... [-5, 5.5],
191+
... [-5.4, 5.5],
192+
... [-20, -20],
193+
... [-15, -20]
194+
... ])
195+
>>> y = np.array([0, 0, 1, 1, 2, 2])
196+
>>> clf = OneVsRestClassifier(SVC()).fit(X, y)
197+
>>> clf.predict([[-19, -20], [9, 9], [-5, 5]])
198+
array([2, 0, 1])
199+
184200
"""
185201
def __init__(self, estimator, n_jobs=None):
186202
self.estimator = estimator

0 commit comments

Comments
 (0)
0