qiskit-documentation/docs/api/qiskit/0.26/qiskit.aqua.components.mult...

97 lines
6.0 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: OneAgainstRest (v0.26)
description: API reference for qiskit.aqua.components.multiclass_extensions.OneAgainstRest in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.aqua.components.multiclass_extensions.OneAgainstRest
---
<span id="qiskit-aqua-components-multiclass-extensions-oneagainstrest" />
# qiskit.aqua.components.multiclass\_extensions.OneAgainstRest
<Class id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/components/multiclass_extensions/one_against_rest.py" signature="OneAgainstRest" modifiers="class">
The One Against Rest multiclass extension.
For an $n$-class problem, the **one-against-rest** method constructs $n$ SVM classifiers, with the $i$-th classifier separating class $i$ from all the remaining classes, $\forall i \in \{1, 2, \ldots, n\}$. When the $n$ classifiers are combined to make the final decision, the classifier that generates the highest value from its decision function is selected as the winner and the corresponding class label is returned.
### \_\_init\_\_
<Function id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest.__init__" signature="__init__()">
Initialize self. See help(type(self)) for accurate signature.
</Function>
## Methods
| | |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.aqua.components.multiclass_extensions.OneAgainstRest.__init__ "qiskit.aqua.components.multiclass_extensions.OneAgainstRest.__init__")() | Initialize self. |
| [`predict`](#qiskit.aqua.components.multiclass_extensions.OneAgainstRest.predict "qiskit.aqua.components.multiclass_extensions.OneAgainstRest.predict")(x) | Applying multiple estimators for prediction. |
| [`set_estimator`](#qiskit.aqua.components.multiclass_extensions.OneAgainstRest.set_estimator "qiskit.aqua.components.multiclass_extensions.OneAgainstRest.set_estimator")(estimator\_cls\[, params]) | Called internally to set `Estimator` and parameters :type estimator\_cls: `Callable`\[\[`List`], `Estimator`] :param estimator\_cls: An `Estimator` class :type params: `Optional`\[`List`] :param params: Parameters for the estimator |
| [`test`](#qiskit.aqua.components.multiclass_extensions.OneAgainstRest.test "qiskit.aqua.components.multiclass_extensions.OneAgainstRest.test")(x, y) | Testing multiple estimators each for distinguishing a pair of classes. |
| [`train`](#qiskit.aqua.components.multiclass_extensions.OneAgainstRest.train "qiskit.aqua.components.multiclass_extensions.OneAgainstRest.train")(x, y) | Training multiple estimators each for distinguishing a pair of classes. |
### predict
<Function id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest.predict" signature="predict(x)">
Applying multiple estimators for prediction.
**Parameters**
**x** (*numpy.ndarray*) NxD array
**Returns**
predicted labels, Nx1 array
**Return type**
numpy.ndarray
</Function>
### set\_estimator
<Function id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest.set_estimator" signature="set_estimator(estimator_cls, params=None)">
Called internally to set `Estimator` and parameters :type estimator\_cls: `Callable`\[\[`List`], `Estimator`] :param estimator\_cls: An `Estimator` class :type params: `Optional`\[`List`] :param params: Parameters for the estimator
**Return type**
`None`
</Function>
### test
<Function id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest.test" signature="test(x, y)">
Testing multiple estimators each for distinguishing a pair of classes.
**Parameters**
* **x** (*numpy.ndarray*) input points
* **y** (*numpy.ndarray*) input labels
**Returns**
accuracy
**Return type**
float
</Function>
### train
<Function id="qiskit.aqua.components.multiclass_extensions.OneAgainstRest.train" signature="train(x, y)">
Training multiple estimators each for distinguishing a pair of classes.
**Parameters**
* **x** (*numpy.ndarray*) input points
* **y** (*numpy.ndarray*) input labels
**Raises**
**Exception** given all data points are assigned to the same class, the prediction would be boring
</Function>
</Class>