# OneVsOneClassifier

### *class* cuml.multiclass.OneVsOneClassifier(estimator, , verbose=False, output_type=None)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/multiclass/multiclass.py#L241)

One-vs-one multiclass classifier using device-resident multiclass
orchestration. The input can be any kind of cuML compatible array, and
the output type follows cuML’s output type configuration rules.

Each pairwise binary problem is constructed on the device and the
resulting votes and confidence values are combined with CuPy, avoiding
unnecessary device-to-host transfers.

For documentation see [scikit-learn’s OneVsOneClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsOneClassifier.html).

* **Parameters:**
  **estimator**

  **verbose**
  : Sets logging level. It must be one of `cuml.common.logger.level_*`.
    See [Verbosity Levels](../../cuml/index.html.md#verbosity-levels) for more info.

  **output_type**
  : Return results and set estimator attributes to the indicated output
    type. If None, the output type set at the module level
    (`cuml.global_settings.output_type`) will be used. See
    [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration) for more info.

### Methods

| [`decision_function`](#cuml.multiclass.OneVsOneClassifier.decision_function)(X)       | Combine pairwise votes with normalized confidence.   |
|-----------------------------------------------------------------------------|------------------------------------------------------|
| [`fit`](#cuml.multiclass.OneVsOneClassifier.fit)(X, y[, sample_weight]) | Fit one binary estimator per class pair on device.   |
| [`predict`](#cuml.multiclass.OneVsOneClassifier.predict)(X)                 | Predict labels from pairwise votes and confidence.   |

### Examples

```pycon
>>> from cuml.linear_model import LogisticRegression
>>> from cuml.multiclass import OneVsOneClassifier
>>> from cuml.datasets.classification import make_classification
```

```pycon
>>> X, y = make_classification(n_samples=10, n_features=6,
...                            n_informative=4, n_classes=3,
...                            random_state=137)
```

```pycon
>>> cls = OneVsOneClassifier(LogisticRegression())
>>> cls.fit(X, y)
OneVsOneClassifier(estimator=LogisticRegression())
>>> cls.predict(X)
array([1, 1, 0, 1, 1, 1, 2, 2, 1, 2])
```

<!-- !! processed by numpydoc !! -->

#### decision_function(X)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/multiclass/multiclass.py#L353)

Combine pairwise votes with normalized confidence.

Only available if `estimator` implements [`decision_function`](#cuml.multiclass.OneVsOneClassifier.decision_function).

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.
* **Returns:**
  **results**
  : Decision function values
    <br/>
    For more information on how to configure cuML’s output type,
    refer to: [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration).

<!-- !! processed by numpydoc !! -->

#### fit(X, y, sample_weight=None) → [OneVsOneClassifier](#cuml.multiclass.OneVsOneClassifier)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/multiclass/multiclass.py#L283)

Fit one binary estimator per class pair on device.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with any dtype.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **sample_weight**
  : The weights for each observation in X. If None, all observations
    are assigned equal weight.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

<!-- !! processed by numpydoc !! -->

#### get_params(deep=True)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/internals/base.py#L191)

Returns a dict of all params owned by this class. If the child class
has appropriately overridden the `_get_param_names` method and does not
need anything other than what is there in this method, then it doesn’t
have to override this method

<!-- !! processed by numpydoc !! -->

#### predict(X)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/multiclass/multiclass.py#L330)

Predict labels from pairwise votes and confidence.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.
* **Returns:**
  **preds**
  : Predicted values
    <br/>
    For more information on how to configure cuML’s output type,
    refer to: [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration).

<!-- !! processed by numpydoc !! -->

#### score(X, y, sample_weight=None, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/internals/mixins.py#L101)

Scoring function for classifier estimators based on mean accuracy.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **sample_weight**
  : The weights for each observation in X. If None, all observations
    are assigned equal weight.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.
* **Returns:**
  **score**
  : Accuracy of self.predict(X) wrt. y (fraction where y == pred_y)

<!-- !! processed by numpydoc !! -->

#### set_params(\*\*params)[[source]](https://github.com/NVIDIA/cuml/blob/1b1be6e7c/python/cuml/cuml/internals/base.py#L200)

Accepts a dict of params and updates the corresponding ones owned by
this class. If the child class has appropriately overridden the
`_get_param_names` method and does not need anything other than what is,
there in this method, then it doesn’t have to override this method

<!-- !! processed by numpydoc !! -->
