qiskit.aqua.components.multiclass_extensions.ErrorCorrectingCode
class ErrorCorrectingCode(code_size=4)
The Error Correcting Code multiclass extension.
Error Correcting Code (ECC) is an ensemble method designed for the multiclass classification problem. As for the other multiclass methods, the task is to decide one label from possible choices.
Class | Code Word | |||||
1 | 0 | 1 | 0 | 1 | 0 | 1 |
2 | 1 | 0 | 0 | 1 | 0 | 0 |
3 | 1 | 1 | 1 | 0 | 0 | 0 |
The table above shows a 6-bit ECC for a 3-class problem. Each class is assigned a unique binary string of length 6. The string is also called a codeword. For example, class 2 has codeword 100100
. During training, one binary classifier is learned for each column. For example, for the first column, ECC builds a binary classifier to separate from . Thus, 6 binary classifiers are trained in this way. To classify a new data point , all 6 binary classifiers are evaluated to obtain a 6-bit string. Finally, we choose the class whose bitstring is closest to ’s output string as the predicted label. This implementation of ECC uses the Euclidean distance.
Parameters
code_size (int
) – Size of error correcting code
__init__
__init__(code_size=4)
Parameters
code_size (int
) – Size of error correcting code
Methods
__init__ ([code_size]) | type code_sizeint |
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