83 lines
2.7 KiB
Plaintext
83 lines
2.7 KiB
Plaintext
---
|
||
title: AllPairs
|
||
description: API reference for qiskit.aqua.components.multiclass_extensions.AllPairs
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.aqua.components.multiclass_extensions.AllPairs
|
||
---
|
||
|
||
# AllPairs
|
||
|
||
<Class id="qiskit.aqua.components.multiclass_extensions.AllPairs" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/components/multiclass_extensions/all_pairs.py" signature="AllPairs" modifiers="class">
|
||
Bases: `qiskit.aqua.components.multiclass_extensions.multiclass_extension.MulticlassExtension`
|
||
|
||
The All-Pairs multiclass extension.
|
||
|
||
In the **all-pairs** reduction, one trains $k(k−1)/2$ binary classifiers for a $k$-way multiclass problem; each receives the samples of a pair of classes from the original training set, and must learn to distinguish these two classes. At prediction time, a **weighted voting scheme** is used: all $k(k−1)/2$ classifiers are applied to an unseen sample, and each class gets assigned the sum of all the scores obtained by the various classifiers. The combined classifier returns as a result the class getting the highest value.
|
||
|
||
## Methods
|
||
|
||
### predict
|
||
|
||
<Function id="qiskit.aqua.components.multiclass_extensions.AllPairs.predict" signature="AllPairs.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.AllPairs.set_estimator" signature="AllPairs.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.AllPairs.test" signature="AllPairs.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.AllPairs.train" signature="AllPairs.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**
|
||
|
||
**ValueError** – can not be fit when only one class is present.
|
||
</Function>
|
||
</Class>
|
||
|