# qiskit.aqua.components.multiclass_extensions.ErrorCorrectingCode¶

class ErrorCorrectingCode(code_size=4)[Quellcode]

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 $$k > 2$$ possible choices.

 Class Code Word $$f_0$$ $$f_1$$ $$f_2$$ $$f_3$$ $$f_4$$ $$f_5$$ 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 $$\{2, 3\}$$ from $$\{1\}$$. Thus, 6 binary classifiers are trained in this way. To classify a new data point $$\mathbf{x}$$, all 6 binary classifiers are evaluated to obtain a 6-bit string. Finally, we choose the class whose bitstring is closest to $$\mathbf{x}$$’s output string as the predicted label. This implementation of ECC uses the Euclidean distance.

Parameter

code_size (int) – Size of error correcting code

__init__(code_size=4)[Quellcode]
Parameter

code_size (int) – Size of error correcting code

Methods

 __init__([code_size]) type code_size int 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(x)[Quellcode]

Applying multiple estimators for prediction.

Parameter

x (numpy.ndarray) – NxD array

Rückgabe

predicted labels, Nx1 array

Rückgabetyp

numpy.ndarray

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

Rückgabetyp

None

test(x, y)[Quellcode]

Testing multiple estimators each for distinguishing a pair of classes.

Parameter
• x (numpy.ndarray) – input points

• y (numpy.ndarray) – input labels

Rückgabe

accuracy

Rückgabetyp

float

train(x, y)[Quellcode]

Training multiple estimators each for distinguishing a pair of classes.

Parameter
• x (numpy.ndarray) – input points

• y (numpy.ndarray) – input labels