class sklearn.multiclass.OneVsRestClassifier(estimator, n_jobs=None)
[source]
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 2-d matrix in which cell [i, j] is 1 if sample i has label j and 0 otherwise.
In the multilabel learning literature, OvR is also known as the binary relevance method.
Read more in the User Guide.
Parameters: |
|
---|---|
Attributes: |
|
decision_function (X) | Returns the distance of each sample from the decision boundary for each class. |
fit (X, y) | Fit underlying estimators. |
get_params ([deep]) | Get parameters for this estimator. |
partial_fit (X, y[, classes]) | Partially fit underlying estimators |
predict (X) | Predict multi-class targets using underlying estimators. |
predict_proba (X) | Probability estimates. |
score (X, y[, sample_weight]) | Returns the mean accuracy on the given test data and labels. |
set_params (**params) | Set the parameters of this estimator. |
__init__(estimator, n_jobs=None)
[source]
decision_function(X)
[source]
Returns the distance of each sample from the decision boundary for each class. This can only be used with estimators which implement the decision_function method.
Parameters: |
|
---|---|
Returns: |
|
fit(X, y)
[source]
Fit underlying estimators.
Parameters: |
|
---|---|
Returns: |
|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
multilabel_
Whether this is a multilabel classifier
partial_fit(X, y, classes=None)
[source]
Partially fit underlying estimators
Should be used when memory is inefficient to train all data. Chunks of data can be passed in several iteration.
Parameters: |
|
---|---|
Returns: |
|
predict(X)
[source]
Predict multi-class targets using underlying estimators.
Parameters: |
|
---|---|
Returns: |
|
predict_proba(X)
[source]
Probability estimates.
The returned estimates for all classes are ordered by label of classes.
Note that in the multilabel case, each sample can have any number of labels. This returns the marginal probability that the given sample has the label in question. For example, it is entirely consistent that two labels both have a 90% probability of applying to a given sample.
In the single label multiclass case, the rows of the returned matrix sum to 1.
Parameters: |
|
---|---|
Returns: |
|
score(X, y, sample_weight=None)
[source]
Returns the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
sklearn.multiclass.OneVsRestClassifier
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html