MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / OneVsOneClassifier

Class OneVsOneClassifier

sklearn/multiclass.py:678–1040  ·  view source on GitHub ↗

One-vs-one multiclass strategy. This strategy consists in fitting one classifier per class pair. At prediction time, the class which received the most votes is selected. Since it requires to fit `n_classes * (n_classes - 1) / 2` classifiers, this method is usually slower than one-vs

Source from the content-addressed store, hash-verified

676
677
678class OneVsOneClassifier(MetaEstimatorMixin, ClassifierMixin, BaseEstimator):
679 """One-vs-one multiclass strategy.
680
681 This strategy consists in fitting one classifier per class pair.
682 At prediction time, the class which received the most votes is selected.
683 Since it requires to fit `n_classes * (n_classes - 1) / 2` classifiers,
684 this method is usually slower than one-vs-the-rest, due to its
685 O(n_classes^2) complexity. However, this method may be advantageous for
686 algorithms such as kernel algorithms which don't scale well with
687 `n_samples`. This is because each individual learning problem only involves
688 a small subset of the data whereas, with one-vs-the-rest, the complete
689 dataset is used `n_classes` times.
690
691 Read more in the :ref:`User Guide <ovo_classification>`.
692
693 Parameters
694 ----------
695 estimator : estimator object
696 A regressor or a classifier that implements :term:`fit`.
697 When a classifier is passed, :term:`decision_function` will be used
698 in priority and it will fallback to :term:`predict_proba` if it is not
699 available.
700 When a regressor is passed, :term:`predict` is used.
701
702 n_jobs : int, default=None
703 The number of jobs to use for the computation: the `n_classes * (
704 n_classes - 1) / 2` OVO problems are computed in parallel.
705
706 ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
707 ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
708 for more details.
709
710 Attributes
711 ----------
712 estimators_ : list of ``n_classes * (n_classes - 1) / 2`` estimators
713 Estimators used for predictions.
714
715 classes_ : numpy array of shape [n_classes]
716 Array containing labels.
717
718 n_classes_ : int
719 Number of classes.
720
721 pairwise_indices_ : list, length = ``len(estimators_)``, or ``None``
722 Indices of samples used when training the estimators.
723 ``None`` when ``estimator``&#x27;s `pairwise` tag is False.
724
725 n_features_in_ : int
726 Number of features seen during :term:`fit`.
727
728 .. versionadded:: 0.24
729
730 feature_names_in_ : ndarray of shape (`n_features_in_`,)
731 Names of features seen during :term:`fit`. Defined only when `X`
732 has feature names that are all strings.
733
734 .. versionadded:: 1.0
735

Callers 15

fitMethod · 0.90
test_ovr_ovo_regressorFunction · 0.90
test_ovo_exceptionsFunction · 0.90
test_ovo_fit_on_listFunction · 0.90
test_ovo_fit_predictFunction · 0.90
test_ovo_gridsearchFunction · 0.90
test_ovo_tiesFunction · 0.90
test_ovo_ties2Function · 0.90
test_ovo_string_yFunction · 0.90

Calls 1

HasMethodsClass · 0.90

Tested by 15

test_ovr_ovo_regressorFunction · 0.72
test_ovo_exceptionsFunction · 0.72
test_ovo_fit_on_listFunction · 0.72
test_ovo_fit_predictFunction · 0.72
test_ovo_gridsearchFunction · 0.72
test_ovo_tiesFunction · 0.72
test_ovo_ties2Function · 0.72
test_ovo_string_yFunction · 0.72
test_ovo_one_classFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…