Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyRiemann-qiskit v0.1.0 #189

Merged
merged 15 commits into from
Oct 4, 2023
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN apt-get -y install --fix-missing git-core
RUN apt-get -y install build-essential

RUN pip install urllib3==1.26.12
RUN pip install "numpy<1.24"
RUN pip install qiskit-terra==0.25.1
RUN python setup.py develop
RUN pip install .[docs]
RUN pip install .[tests]
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ package on your local machine using the `setup.py` script:
python setup.py develop
```

Or directly 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:

```
Expand Down Expand Up @@ -163,24 +173,24 @@ They are pushed to the docker registry on each release.

## Contributor Guidelines

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

- [Raise an issue](https://github.com/pyRiemann/pyRiemann-qiskit/issues/new) on the
repository. Issues can be either a bug report or an enhancement proposal. Note that it
is necessary to register on GitHub before. There is no special template which is
expected but, if you raise a defect please provide as much details as possible.
is necessary to register on GitHub before. There is no special template that is expected
but, if you raise a defect please provide as many details as possible.

- [Raise a pull request](https://github.com/pyRiemann/pyRiemann-qiskit/compare). Fork the
repository and work on your own branch. Then raise a pull request with your branch
against master. As much as possible, we ask you to:
- avoid merging master into your branch. Always prefer git rebase.
- always provide full documentation of public method.
- always provide full documentation of public methods.

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

- The core functionalies are based on `Python`,
- The core functionalities are based on `Python`,
[pyRiemann](https://github.com/pyRiemann/pyRiemann),
[Qiskit ML](https://github.com/Qiskit/qiskit-machine-learning) and follow the best
practice from [scikit-learn](https://scikit-learn.org/stable/index.html). We use
Expand Down Expand Up @@ -209,9 +219,9 @@ automation.
pytest tests/test_classification.py
```

Workflows are automatically triggered when you push a commit. However, the worflow for
Workflows are automatically triggered when you push a commit. However, the workflow for
example execution is only triggered when you modify one of the examples or the
documentation as the execution take a lot of time. You can enable
documentation as the execution takes a lot of time. You can enable
[Github Actions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)
in your fork to see the result of the CI pipeline. Results are also indicated at the end
of your pull request when raised. However note, that workflows in the pull request need
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pyRiemann-qiskit: Qiskit wrapper for pyRiemann
<div class="row">
<a href="auto_examples/ERP/plot_classify_EEG_quantum_svm.html">
<div class="col-md-3 thumbnail">
<img src="_images/sphx_glr_plot_classify_EEG_quantum_thumb.png">
<img src="_images/sphx_glr_plot_classify_EEG_quantum_svm_thumb.png">
</div>
</a>
<a href="auto_examples/ERP/plot_classify_P300_bi.html">
Expand Down
2 changes: 1 addition & 1 deletion examples/ERP/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Classification of ERP
---------------------

Event related potential classification with quantum algorithm and Riemannian geometry.
Event related potential classification with quantum algorithms and Riemannian geometry.
3 changes: 2 additions & 1 deletion examples/ERP/classify_P300_bi_quantum_mdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Classification of P300 datasets from MOABB using Quantum MDM
====================================================================

The mean and the distance in MDM algorithm are formualted as
The mean and the distance in MDM algorithm are formulated as
optimization problems. These optimization problems are translated
to Qiskit using Docplex and additional glue code. These optimizations
are enabled when we use convex mean or convex distance. This is set
Expand All @@ -13,6 +13,7 @@

If you want to use GPU, you need to use qiskit-aer-gpu that will replace
qiskit-aer. It is only available on Linux.

pip install qiskit-aer-gpu

pip install moabb==0.5.0
Expand Down
4 changes: 4 additions & 0 deletions examples/MI/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Classification of MI
---------------------

Motor imagery classification with quantum algorithms and Riemannian geometry.
4 changes: 4 additions & 0 deletions examples/other_datasets/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Classification on other datasets
--------------------------------

Contains examples with other datasets, like the titanic dataset.
3 changes: 2 additions & 1 deletion examples/toys_dataset/plot_quantum_art_vqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
# In this example we will display weights variability of the parameter inside
# the variational quantum circuit which is used by VQC.
#
# The idea is simple :
# The idea is simple:
#
# - We initialize a VQC with different number of parameters and number of samples.
# - We train the VQC a couple of times and we store the fitted weights.
# - We compute variability of the weight and display it in a fashionable way.
Expand Down
2 changes: 1 addition & 1 deletion pyriemann_qiskit/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.4'
__version__ = '0.1.0'
19 changes: 9 additions & 10 deletions pyriemann_qiskit/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class QuanticSVM(QuanticClassifierBase):
-----
.. versionadded:: 0.0.1
.. versionchanged:: 0.0.2
Qiskit's Pegasos implementation [4, 5]_.
Qiskit's Pegasos implementation [4]_, [5]_.
.. versionchanged:: 0.1.0
Fix: copy estimator not keeping base class parameters.

Expand Down Expand Up @@ -408,14 +408,14 @@ class QuanticVQC(QuanticClassifierBase):
----------
optimizer : Optimizer (default:SPSA)
The classical optimizer to use.
See [3] for details.
See [3]_ for details.
gen_var_form : Callable[int, QuantumCircuit | VariationalForm] \
(default: Callable[int, TwoLocal])
Function generating a variational form instance.
quantum : bool (default: True)
- If true will run on local or remote backend
(depending on q_account_token value).
- If false, will perform classical computing instead
(depending on q_account_token value).
- If false, will perform classical computing instead.
q_account_token : string (default:None)
If quantum==True and q_account_token provided,
the classification task will be running on a IBM quantum backend.
Expand Down Expand Up @@ -552,11 +552,10 @@ class QuanticMDM(QuanticClassifierBase):

"""Quantum-enhanced MDM

# This class is a convex implementation of the MDM [1]_,
# that can runs with quantum optimization.
# Only log-euclidian distance between trial and class prototypes
# is supported at the moment, but any type of metric
# can be used for centroid estimation.
This class is a convex implementation of the MDM [1]_,
that can runs with quantum optimization.
Only log-euclidian distance between trial and class prototypes is supported
at the moment, but any type of metric can be used for centroid estimation.

Notes
-----
Expand All @@ -577,7 +576,7 @@ class QuanticMDM(QuanticClassifierBase):
quantum : bool (default: True)
Only applies if `metric` contains a convex distance or mean.
- If true will run on local or remote backend
(depending on q_account_token value).
(depending on q_account_token value).
- If false, will perform classical computing instead
q_account_token : string (default:None)
If quantum==True and q_account_token provided,
Expand Down
2 changes: 1 addition & 1 deletion pyriemann_qiskit/utils/hyper_params_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def gen_two_local(reps=3, rotation_blocks=["ry", "rz"], entanglement_blocks="cz"

def get_spsa(max_trials=40, c=(None, None, None, None, 4.0)):
"""Return an instance of SPSA.
SPSA [1, 2]_ is an algorithmic method for optimizing systems
SPSA [1]_, [2]_ is an algorithmic method for optimizing systems
with multiple unknown parameters.
For more details, see [3]_ and [4]_.

Expand Down