Home

Awesome

<img src=https://github.com/Qiskit/ecosystem/blob/main/badges/pyRiemann-qiskit.svg>

pyRiemann-qiskit

Literature on quantum computing suggests it may offer an advantage compared with classical computing in terms of computational time and outcomes, such as for pattern recognition or when using limited training sets [1, 2].

A ubiquitous library on quantum computing is Qiskit [3]. Qiskit is an IBM library distributed under Apache 2.0 which provides both quantum algorithms and backends. A backend can be either your local machine or a remote machine, which one can emulate or be a quantum machine. Qiskit abstraction over the type of machine you want to use, makes designing quantum algorithms seamless.

Qiskit implements a quantum version of support vector-like classifiers, known as quantum-enhanced support vector classifiers (QSVCs) and variational quantum classifiers (VQCs) [4]. These classifiers likely offer an advantage over classical SVM in situations where the classification task is complex. Task complexity is raised by the encoding of the data into a quantum state, the number of available data, and the quality of the data. An initial study is available in [5], and it can be downloaded from here. Although there is no study on this topic at the time of writing, this could be an interesting research direction to investigate BCI illiteracy.

pyRiemann-qiskit implements a wrapper around QSVC and VQC, to use quantum classification with Riemannian geometry. A use case would be to use vectorized covariance matrices in the tangent space as an input for these classifiers, enabling a possible sandbox for researchers and engineers in the field.

pyRiemann-qiskit also introduces a quantum version of the famous MDM algorithm. There is a dedicated example on quantum-MDM here.

The remaining of this readme details some of the quantum drawbacks and will guide you through installation. Full documentation, including API description, is available at https://pyriemann-qiskit.readthedocs.io/. The repository also includes a wiki where you can find additional information.

Quantum drawbacks

References

[1] A. Blance and M. Spannowsky, ‘Quantum machine learning for particle physics using a variational quantum classifier’, J. High Energ. Phys., vol. 2021, no. 2, p. 212, Feb. 2021, https://doi.org/10.1007/JHEP02(2021)212

[2] P. Rebentrost, M. Mohseni, and S. Lloyd, ‘Quantum Support Vector Machine for Big Data Classification’, Phys. Rev. Lett., vol. 113, no. 13, p. 130503, Sep. 2014, https://doi.org/10.1103/PhysRevLett.113.130503

[3] H. Abraham et al., Qiskit: An Open-source Framework for Quantum Computing. Zenodo, 2019, https://doi.org/10.5281/zenodo.2562110.

[4] V. Havlíček et al., ‘Supervised learning with quantum-enhanced feature spaces’, Nature, vol. 567, no. 7747, pp. 209–212, Mar. 2019, https://doi.org/10.1038/s41586-019-0980-2

[5] G. Cattan, A. Andreev, First steps to the classification of ERPs using quantum computation, NTB Berlin 2022 - International Forum on Neural Engineering & Brain Technologies, May 2022, Berlin, Germany, https://hal.archives-ouvertes.fr/hal-03672246/

How to cite?

Anton Andreev, Grégoire Cattan, Sylvain Chevallier, and Quentin Barthélemy. ‘pyRiemann-qiskit: A Sandbox for Quantum Classification Experiments with Riemannian Geometry’. Research Ideas and Outcomes 9 (20 March 2023). https://doi.org/10.3897/rio.9.e101006.

This library is part of the Qiskit Ecosystem

Installation

We recommend the use of Anaconda to manage python environements.

pyRiemann-qiskit currently supports Windows, Mac and Linux OS with Python 3.9 - 3.11.

You can install pyRiemann-qiskit release from PyPI:

pip install pyriemann-qiskit

The development version can be installed by cloning this repository and installing the package on your local machine using the setup.py script. We recommand to do it using pip:

pip install .

Note that the steps above need to be re-executed in your local environment after any changes inside your local copy of the pyriemann_qiskit folder, including pulling from remote.

To check the installation, open a python shell and type:

import pyriemann_qiskit

To enable Qiskit GPU optimization (for Linux) when using quantum simulation, run:

pip install .[optim_linux]

To use symbolic quantum simulation, run:

pip install .[optim]

Which will enable qiskit-symb integration.

Note, Qiskit only provide binaries for Linux. For other platforms, or if you want to enable specific NVIDIA optimization for quantum, you need to build the binary yourself.

To run a specific example on your local machine, you should install first dependencies for the documentation:

pip install .[docs]

Then you can run the python example of your choice like:

python examples\ERP\classify_P300_bi.py

Installation with docker

We also offer the possibility to set up the dev environment within docker. To this end, we recommand to use vscode with the Remote Containers extension from Microsoft.

Once the installation is successful, just open the project in vscode and enter F1. In the search bar that opens, type Rebuild and Reopen Container.

Wait for the container to build, and open a python shell within the container. Then ensure everything went smoothly by typing:

import pyriemann_qiskit

Alternatively, you can from the console (Windows or Linux) build the docker image from our Dockerfile. Go to the root folder of pyRiemann-qiskit and type:

docker build -t pyrq .

Next use docker run --detach pyrq to enter the pyRiemann-qiskit image.

If you wish, you can also download docker images directly from github docker registry: https://github.com/pyRiemann/pyRiemann-qiskit/pkgs/container/pyriemann-qiskit

They are pushed to the docker registry on each release.

Contributor Guidelines

Everyone is welcome to contribute to this repository. There are two types of contributions:

Code contribution (pull request) can be either on core functionalities, documentation or automation.

Troubleshooting

See our dedicated wiki page.