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.

OneAgainstRest

class OneAgainstRest

GitHub

Bases: qiskit.aqua.components.multiclass_extensions.multiclass_extension.MulticlassExtension

The One Against Rest multiclass extension.

For an nn-class problem, the one-against-rest method constructs nn SVM classifiers, with the ii-th classifier separating class ii from all the remaining classes, i{1,2,,n}\forall i \in \{1, 2, \ldots, n\}. When the nn 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.


Methods

predict

OneAgainstRest.predict(x)

Applying multiple estimators for prediction.

Parameters

x (numpy.ndarray) – NxD array

Returns

predicted labels, Nx1 array

Return type

numpy.ndarray

set_estimator

OneAgainstRest.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

OneAgainstRest.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

OneAgainstRest.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

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