|
1 | 1 | # "Quantum Evolution Kernel" |
2 | 2 | ## Installation |
3 | | -Installation guidelines |
| 3 | +### Using `hatch`, `uv` or any pyproject-compatible Python manager |
| 4 | + |
| 5 | +Edit file `pyproject.toml` to add the line |
| 6 | + |
| 7 | +```toml |
| 8 | + "quantum-evolution-kernel" |
| 9 | +``` |
| 10 | + |
| 11 | +to the list of `dependencies`. |
| 12 | + |
| 13 | +### Using `pip` or `pipx` |
| 14 | +To install the `pipy` package using `pip` or `pipx` |
| 15 | + |
| 16 | +1. Create a `venv` if that's not done yet |
| 17 | + |
| 18 | +```sh |
| 19 | +$ python -m venv venv |
| 20 | + |
| 21 | +``` |
| 22 | + |
| 23 | +2. Enter the venv |
| 24 | + |
| 25 | +```sh |
| 26 | +$ . venv/bin/activate |
| 27 | +``` |
| 28 | + |
| 29 | +3. Install the package |
| 30 | + |
| 31 | +```sh |
| 32 | +$ pip install quantum-evolution-kernel |
| 33 | +# or |
| 34 | +$ pipx install quantum-evolution-kernel |
| 35 | +``` |
4 | 36 |
|
5 | 37 | ## Usage |
6 | | -Usage guidelines |
| 38 | + |
| 39 | +```python |
| 40 | +# Load a dataset |
| 41 | +import torch_geometric.datasets as pyg_dataset |
| 42 | +og_ptcfm = pyg_dataset.TUDataset(root="dataset", name="PTC_FM") |
| 43 | + |
| 44 | +# Setup a quantum feature extractor for this dataset. |
| 45 | +# In this example, we'll use QutipExtractor, to emulate a Quantum Device on our machine. |
| 46 | +import qek.data.graphs as qek_graphs |
| 47 | +import qek.data.extractors as qek_extractors |
| 48 | +extractor = qek_extractors.QutipExtractor(compiler=qek_graphs.PTCFMCompiler()) |
| 49 | + |
| 50 | +# Add the graphs, compile them and look at the results. |
| 51 | +extractor.add_graphs(graphs=og_ptcfm) |
| 52 | +extractor.compile() |
| 53 | +processed_dataset = extractor.run().processed_data |
| 54 | + |
| 55 | +# Prepare a machine learning pipeline with Scikit Learn. |
| 56 | +from sklearn.model_selection import train_test_split |
| 57 | +from sklearn.svm import SVC |
| 58 | + |
| 59 | +X = [data for data in processed_dataset] # Features |
| 60 | +y = [data.target for data in processed_dataset] # Targets |
| 61 | +X_train, X_test, y_train, y_test = train_test_split(X, y, stratify = y, test_size=0.2, random_state=42) |
| 62 | + |
| 63 | +# Train a kernel |
| 64 | +from qek.kernel import QuantumEvolutionKernel as QEK |
| 65 | +kernel = QEK(mu=0.5) |
| 66 | +model = SVC(kernel=kernel, random_state=42) |
| 67 | +model.fit(X_train, y_train) |
| 68 | +``` |
7 | 69 |
|
8 | 70 | ## Documentation |
9 | | -Documentation guidelines |
| 71 | + |
| 72 | +::: qek |
| 73 | + |
| 74 | +## Tutorials |
| 75 | + |
| 76 | +We have a two parts tutorial: |
| 77 | + |
| 78 | +1. [Using a Quantum Device to extract machine-learning features](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%201%20-%20Using%20a%20Quantum%20Device%20to%20Extract%20Machine-Learning%20Features.ipynb); |
| 79 | +2. [Machine Learning with the Quantum Evolution Kernel](https://github.com/pasqal-io/quantum-evolution-kernel/blob/main/examples/tutorial%202%20-%20Machine-Learning%20with%20the%20Quantum%20EvolutionKernel.ipynb) |
| 80 | + |
| 81 | +## Getting in touch |
| 82 | + |
| 83 | +- [Pasqal Community Portal](https://community.pasqal.com/) (forums, chat, tutorials, examples, code library). |
| 84 | +- [GitHub Repository](https://github.com/pasqal-io/quantum-evolution-kernel) (source code, issue tracker). |
| 85 | +- [Professional Support](https://www.pasqal.com/contact-us/) (if you need tech support, custom licenses, a variant of this library optimized for your workload, your own QPU, remote access to a QPU, ...) |
10 | 86 |
|
11 | 87 | ## Contribute |
12 | | -Contribution guidelines |
| 88 | + |
| 89 | +The GitHub repository is open for contributions! |
| 90 | + |
| 91 | +Don't forget to read the [Contributor License Agreement](). |
0 commit comments