qiskit.aqua.components.multiclass_extensions.OneAgainstRest
class OneAgainstRest
The One Against Rest multiclass extension.
For an -class problem, the one-against-rest method constructs SVM classifiers, with the -th classifier separating class from all the remaining classes, . When the 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__
__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
Exception – given all data points are assigned to the same class, the prediction would be boring