Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.aqua.components.multiclass_extensions.AllPairs

class AllPairs

GitHub

The All-Pairs multiclass extension.

In the all-pairs reduction, one trains k(k1)/2k(k−1)/2 binary classifiers for a kk-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(k1)/2k(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.

__init__

__init__()

Initialize self. See help(type(self)) for accurate signature.


Methods

__init__()Initialize self.
predict(x)Applying multiple estimators for prediction.
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(x, y)Testing multiple estimators each for distinguishing a pair of classes.
train(x, y)Training multiple estimators each for distinguishing a pair of classes.

predict

predict(x)

Applying multiple estimators for prediction.

Parameters

x (numpy.ndarray) – NxD array

Returns

predicted labels, Nx1 array

Return type

numpy.ndarray

set_estimator

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

test

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

train

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.

Was this page helpful?
Report a bug or request content on GitHub.