Corresponding author: Grégoire H. Cattan (
Academic editor: Editorial Secretary
Quantum computing is a promising technology for machine learning, in terms of computational costs and outcomes. In this work, we intend to provide a framework that facilitates the use of quantum machine learning in the domain of braincomputer interfaces – where biomedical signals, such as brain waves, are processed.
To this end, we integrated
Quantum computing has its roots in the socalled doubleslit experiment conducted by Thomas Young in 1802. In this experiment, a small entity, such as a photon or an electron, is directed towards two parallel slits and the resulting interference pattern is observed. The observation shows that the entity behaves as a wave, which suggests that it passes through both slits simultaneously. From a computational perspective, this waveparticle duality means that a single bit of information can be encoded as a quantum bit, which is a superposition of two different states. This unique characteristic of quantum computing offers a significant advantage over classical computing in terms of computational time and outcomes, such as for pattern recognition or when using limited training sets (
A ubiquitous library for quantum computing is
Qiskit implements quantum versions of two support vectorlike classifiers, named quantumenhanced support vector classifier (QSVC) and variational quantum classifier (VQC,
This research received no specific grant from any funding agency in the public, commercial or notforprofit sectors.
Homepage:
Wiki:
Download page:
Bug database:
Type: Git
Browse URI:
Other
pyRiemannqiskit facilitates the creation and parameterisation of a quantum backend and is fully compliant with scikitlearn’s transformers, estimators and classifiers, so it becomes easy to integrate quantum classification into existing pipelines. It also supports
pyRiemannqiskit also includes examples to guide practitioners, as well as a complete test suite. We will briefly describe below the functionalities provided by the software.
The software supports QSVC and VQC classifiers. The first concern regarding quantum classifiers is the encoding of classical data into quantum states. This operation is known as feature mapping. To obtain an advantage over classical computing, feature mapping must implement quantum circuits which are difficult to emulate on a classical computer. Feature mapping is common in VQCs and QSVCs. Both are SVMlike classifiers in the sense that they generate a separating hyperplane. The difference between them is that VQCs uses a variational quantum circuit (also known as a variational form) for this task, whereas QSVCs uses a quantumenhanced kernel with a conventional SVM. The software also supports the Pegasos implementation of QSVC, which offers a speedup compared to QSVC (
Table
By default, the backend will be a local quantum simulator. However, it is possible to register on
However, note that, at the time of writing, the number of qubits (and, therefore, the feature dimension) is limited to:
36 on a local quantum simulator;
5000 on a remote quantum simulator;
5–7 on a real free quantum computer;
127 on exploratory quantum computers (not available for public use).
The MDM algorithm (
pyRiemannqiskit supports
in training: computing the barycenter of the covariance matrices, i.e. a matrix is used as a point in the manifold and thus an average – called a class prototype – of all these points can be calculated;
in classification: finding the minimum distance between a trial and a class prototype can also be defined as a quadratic optimisation problem (
To calculate the class prototype, we need to select a
The complexity of the QAOA optimiser rises as a function of the size of the covariance matrices and the upperbound coefficient. The size of the covariance matrices depends on the number of input channels in the input time epoch, as well as the dimension reduction method that is used. The upperbound coefficient also has an impact on the final size of the covariance matrices. The upperbound coefficient is simply the maximal value that can possibly take a coefficient in a matrix. If all coefficients inside a matrix are integers ranging from 0 to 3, then each of them can be represented by only 2 bits (00, 01, 10, 11). In this case, each integer coefficient inside the matrix can be replaced by two binary coefficients and, thus, the size of the resulting matrices will be "only" twice as large. As the mean matrix to optimise has the exact same size as the input covariance matrices, it means that there will be two times more variables to optimise inside the mean matrix. Therefore, this implies a higher number of qubits to hold the variables inside the matrix. As QAOA is computationally expensive, we also provide a wrapper over the classical optimiser Cobyla that allows for easier testing.
Table
If the MDM classifier is supplied with the "convex" metric, it will automatically use the fro_mean_convex method for computing the mean – the class prototype. The default optimiser for the fro_mean_convex method is the Cobyla optimiser.
The number of qubits is limited (especially on real hardware) and this puts a limit on the length of the feature vectors that can be used with quantum programming. In
The code snippet below (Table
For convenience, the library provides the
pyRiemannqiskit is a sandbox for experimenting with quantum computing in conjunction with RG. It unifies within the same library a quantum computational library and RG tools to ultimately allow for the creation of better BrainComputer Interfaces (BCI). RG tools are proved to perform very well on the classification of EEG ERP signals (
In summary, we seek to encourage the use of quantum computing together with RG for concrete (BCI) applications, opening new and interesting research paths. For example, it would be interesting to investigate BCI illiteracy, a situation in which classical classifiers usually fail to generalise well using EEG data.
Future work directions on the software include the direct classification of covariance matrices and multiclass classification.
The MDM algorithm consists of finding the minimum distance between a trial and a class prototype before labelling the trial with the class that is the closest to the trial. It is a decision optimisation problem that can be solved using Qiskit’s QAOA, under the conditions that: 1) it is provided in the form of a convex model and, 2) it is quadratic, unconstrained and contains only binary variables.
For instance, MDM, based on the LogEuclidian metric, has the following expression (
with
Note that the equation above is a quadratic optimisation problem. However, weights in the
Besides, the equation must be solved for each new trial that needs to be classified. The complexity of determining the correct weights to minimise the equation varies as a function of the number of classes and the upper bound coefficient which is used for the IntegerToBinary method (the higher the coefficient, the higher the complexity). While potentially slower, this quantumoptimised version of the MDM algorithm
At the time of writing, pyRiemannqiskit only supports binary classification of covariance matrices (i.e. presence or absence of an ERP). Further work envisions the implementation of multiclass classifiers.
Instantiation of VQC and QSVC classifiers in pyRiemannqiskit.

Convex distance optimisation with frobenius mean in pyRiemannqiskit.
Example of quantum classification pipeline with pyRiemannqiskit.
