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.

ErrorCorrectingCode

class ErrorCorrectingCode(code_size=4)

GitHub

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

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

ClassCode Word
f0f_0f1f_1f2f_2f3f_3f4f_4f5f_5
1010101
2100100
3111000

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

Parameters

code_size (int) – Size of error correcting code


Methods

predict

ErrorCorrectingCode.predict(x)

Applying multiple estimators for prediction.

Parameters

x (numpy.ndarray) – NxD array

Returns

predicted labels, Nx1 array

Return type

numpy.ndarray

set_estimator

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

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

ErrorCorrectingCode.train(x, y)

Training multiple estimators each for distinguishing a pair of classes.

Parameters

  • x (numpy.ndarray) – input points
  • y (numpy.ndarray) – input labels
Was this page helpful?
Report a bug or request content on GitHub.