8000 DOC add an example in docstring of OneVsOneClassifier (#16700) · InterferencePattern/scikit-learn@420faf7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 420faf7

Browse files
j0rd1smitadrinjalali
authored andcommitted
DOC add an example in docstring of OneVsOneClassifier (scikit-learn#16700)
1 parent 97bfd13 commit 420faf7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sklearn/multiclass.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,20 @@ class OneVsOneClassifier(MetaEstimatorMixin, ClassifierMixin, BaseEstimator):
523523
pairwise_indices_ : list, length = ``len(estimators_)``, or ``None``
524524
Indices of samples used when training the estimators.
525525
``None`` when ``estimator`` does not have ``_pairwise`` attribute.
526+
527+
Examples
528+
--------
529+
>>> from sklearn.datasets import load_iris
530+
>>> from sklearn.model_selection import train_test_split
531+
>>> from sklearn.multiclass import OneVsOneClassifier
532+
>>> from sklearn.svm import LinearSVC
533+
>>> X, y = load_iris(return_X_y=True)
534+
>>> X_train, X_test, y_train, y_test = train_test_split(
535+
... X, y, test_size=0.33, shuffle=True, random_state=0)
536+
>>> clf = OneVsOneClassifier(
537+
... LinearSVC(random_state=0)).fit(X_train, y_train)
538+
>>> clf.predict(X_test[:10])
539+
array([2, 1, 0, 2, 0, 2, 0, 1, 1, 1])
526540
"""
527541
@_deprecate_positional_args
528542
def __init__(self, estimator, *, n_jobs=None):

0 commit comments

Comments
 (0)
0