8.18.2. sklearn.multiclass.OneVsRestClassifier¶
- class sklearn.multiclass.OneVsRestClassifier(estimator)¶
One-vs-the-rest (OvR) multiclass/multilabel strategy
Also known as one-vs-all, this strategy consists in fitting one classifier per class. For each classifier, the class is fitted against all the other classes. In addition to its computational efficiency (only n_classes classifiers are needed), one advantage of this approach is its interpretability. Since each class is represented by one and one classifier only, it is possible to gain knowledge about the class by inspecting its corresponding classifier. This is the most commonly used strategy for multiclass classification and is a fair default choice.
This strategy can also be used for multilabel learning, where a classifier is used to predict multiple labels for instance, by fitting on a sequence of sequences of labels (e.g., a list of tuples) rather than a single target vector. For multilabel learning, the number of classes must be at least three, since otherwise OvR reduces to binary classification.
Parameters : estimator : estimator object
An estimator object implementing fit and one of decision_function or predict_proba.
Attributes