One-vs-the-rest (OvR) multiclass 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 need
| 200 | |
| 201 | |
| 202 | class OneVsRestClassifier( |
| 203 | MultiOutputMixin, |
| 204 | ClassifierMixin, |
| 205 | MetaEstimatorMixin, |
| 206 | BaseEstimator, |
| 207 | ): |
| 208 | """One-vs-the-rest (OvR) multiclass strategy. |
| 209 | |
| 210 | Also known as one-vs-all, this strategy consists in fitting one classifier |
| 211 | per class. For each classifier, the class is fitted against all the other |
| 212 | classes. In addition to its computational efficiency (only `n_classes` |
| 213 | classifiers are needed), one advantage of this approach is its |
| 214 | interpretability. Since each class is represented by one and one classifier |
| 215 | only, it is possible to gain knowledge about the class by inspecting its |
| 216 | corresponding classifier. This is the most commonly used strategy for |
| 217 | multiclass classification and is a fair default choice. |
| 218 | |
| 219 | OneVsRestClassifier can also be used for multilabel classification. To use |
| 220 | this feature, provide an indicator matrix for the target `y` when calling |
| 221 | `.fit`. In other words, the target labels should be formatted as a 2D |
| 222 | binary (0/1) matrix, where [i, j] == 1 indicates the presence of label j |
| 223 | in sample i. This estimator uses the binary relevance method to perform |
| 224 | multilabel classification, which involves training one binary classifier |
| 225 | independently for each label. |
| 226 | |
| 227 | Read more in the :ref:`User Guide <ovr_classification>`. |
| 228 | |
| 229 | Parameters |
| 230 | ---------- |
| 231 | estimator : estimator object |
| 232 | A regressor or a classifier that implements :term:`fit`. |
| 233 | When a classifier is passed, :term:`decision_function` will be used |
| 234 | in priority and it will fallback to :term:`predict_proba` if it is not |
| 235 | available. |
| 236 | When a regressor is passed, :term:`predict` is used. |
| 237 | |
| 238 | n_jobs : int, default=None |
| 239 | The number of jobs to use for the computation: the `n_classes` |
| 240 | one-vs-rest problems are computed in parallel. |
| 241 | |
| 242 | ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. |
| 243 | ``-1`` means using all processors. See :term:`Glossary <n_jobs>` |
| 244 | for more details. |
| 245 | |
| 246 | .. versionchanged:: 0.20 |
| 247 | `n_jobs` default changed from 1 to None |
| 248 | |
| 249 | verbose : int, default=0 |
| 250 | The verbosity level, if non zero, progress messages are printed. |
| 251 | Below 50, the output is sent to stderr. Otherwise, the output is sent |
| 252 | to stdout. The frequency of the messages increases with the verbosity |
| 253 | level, reporting all iterations at 10. See :class:`joblib.Parallel` for |
| 254 | more details. |
| 255 | |
| 256 | .. versionadded:: 1.1 |
| 257 | |
| 258 | Attributes |
| 259 | ---------- |
searching dependent graphs…