Skip to content

Commit 548b8a4

Browse files
authored
[Doc][CI] Render the tutorial within the generated documentation (#102)
1 parent a05cb34 commit 548b8a4

11 files changed

+92
-23
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
- name: Install Hatch
6868
run: |
6969
pip install hatch
70+
- name: Build Docs
71+
run: |
72+
cp examples/*.ipynb docs/
7073
- name: Deploy docs
7174
run: |
7275
git config user.name "GitHub Actions"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ dataset/
5050

5151
# Mkdocs
5252
site/
53+
docs/*.ipynb
54+
docs/ptcfm_processed_dataset.json
55+
docs/saved_data.json

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ model.fit(X_train, y_train)
8080

8181
We have a two parts tutorial:
8282

83-
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);
84-
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)
83+
1. [Using a Quantum Device to extract machine-learning features](https://pasqal-io.github.io/quantum-evolution-kernel/latest/tutorial%201%20-%20Using%20a%20Quantum%20Device%20to%20Extract%20Machine-Learning%20Features);
84+
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/)
8585

8686
See also the [full API documentation](https://pasqal-io.github.io/quantum-evolution-kernel/latest/).
8787

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ The core of the library is focused on the development of a classification algori
77

88
Users setting their first steps into quantum computing will learn how to implement the core algorithm in a few simple steps and run it using the Pasqal Neutral Atom QPU. More experienced users will find this library to provide the right environment to explore new ideas - both in terms of methodologies and data domain - while always interacting with a simple and intuitive QPU interface.
99

10+
## Getting started
11+
12+
We provide several tutorials:
13+
14+
- [tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features](tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features.ipynb)
15+
- [tutorial 2 - Machine-Learning with the Quantum EvolutionKernel](tutorial 2 - Machine-Learning with the Quantum EvolutionKernel.ipynb)
16+
1017

1118
## Getting in touch
1219

docs/tutorials.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features.ipynb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@
2828
"As in any machine learning task, we first need to load and prepare data. QEK can work with many types of graphs, including molecular graphs. For this tutorial, we will use the PTC-FM dataset, which contains such molecular graphs, labeled with their toxicity."
2929
]
3030
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {
35+
"tags": [
36+
"ignore_warnings"
37+
]
38+
},
39+
"outputs": [],
40+
"source": [
41+
"# Ignore warnings for this tutorial.\n",
42+
"import logging\n",
43+
"import os\n",
44+
"import sys\n",
45+
"\n",
46+
"logger = logging.getLogger()\n",
47+
"logger.disabled = True\n",
48+
"\n",
49+
"sys.stderr = open(os.devnull, 'w')"
50+
]
51+
},
3152
{
3253
"cell_type": "code",
3354
"execution_count": null,

examples/tutorial 1a - Using a Quantum Device to Extract Machine-Learning Features - low-level.ipynb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@
2929
"As in any machine learning task, we first need to load and prepare data. QEK can work with many types of graphs, including molecular graphs. For this tutorial, we will use the PTC-FM dataset, which contains such molecular graphs."
3030
]
3131
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {
36+
"tags": [
37+
"ignore_warnings"
38+
]
39+
},
40+
"outputs": [],
41+
"source": [
42+
"# Ignore warnings for this tutorial.\n",
43+
"import logging\n",
44+
"import sys\n",
45+
"\n",
46+
"logger = logging.getLogger()\n",
47+
"logger.disabled = True\n",
48+
"sys.stderr.close()"
49+
]
50+
},
3251
{
3352
"cell_type": "code",
3453
"execution_count": null,

examples/tutorial 1b - Training SVM QEK - low-level - generic dataset.ipynb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@
5353
"\n"
5454
]
5555
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"metadata": {
60+
"tags": [
61+
"ignore_warnings"
62+
]
63+
},
64+
"outputs": [],
65+
"source": [
66+
"# Ignore warnings for this tutorial.\n",
67+
"import logging\n",
68+
"import os\n",
69+
"import sys\n",
70+
"\n",
71+
"logger = logging.getLogger()\n",
72+
"logger.disabled = True\n",
73+
"\n",
74+
"sys.stderr = open(os.devnull, 'w')"
75+
]
76+
},
5677
{
5778
"cell_type": "code",
5879
"execution_count": null,

examples/tutorial 2 - Machine-Learning with the Quantum EvolutionKernel.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050
"id": "05e294f5",
5151
"metadata": {},
5252
"source": [
53-
"We begin by loading a dataset that contains graph-structured data. Each data point is represented as a processed object with features (in this example, the quantum distribution excitation for a molecule) and a target value (in this example, the toxicity of the molecule). We will split the data into training and testing sets for model evaluation.\n",
54-
"\n",
55-
"- Each processed data point has a _state_dict_: This dictionary represents an approximation of the quantum state of the device for this graph after completion of the algorithm. From the state dictionary, we derive as machine-learning feature the _distribution of excitation_. We'll use these in the next step to define our kernel.\n",
56-
" "
53+
"We begin by loading a dataset that contains graph-structured data. Each data point is represented as a processed object with features (in this example, the quantum distribution excitation for a molecule) and a target value (in this example, the toxicity of the molecule). We will split the data into training and testing sets for model evaluation. "
5754
]
5855
},
5956
{
@@ -80,8 +77,8 @@
8077
"from sklearn.model_selection import train_test_split\n",
8178
"\n",
8279
"# Prepare features (X) and targets (y)\n",
83-
"X = [data for data in processed_dataset] \n",
84-
"y = [data.target for data in processed_dataset] \n",
80+
"X = [data for data in processed_dataset] # Quantum distribution excitation.\n",
81+
"y = [data.target for data in processed_dataset] # Toxicity.\n",
8582
"\n",
8683
"# Split data into training and testing sets\n",
8784
"X_train, X_test, y_train, y_test = train_test_split(X, y, stratify = y, test_size=0.2, random_state=42)"

mkdocs.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ nav:
77
- Getting started:
88
- Installation: installation.md
99
- Usage: usage.md
10-
- Tutorials: tutorials.md
10+
- Tutorials:
11+
- "Tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features": "tutorial 1 - Using a Quantum Device to Extract Machine-Learning Features.ipynb"
12+
- "(low-level variant) Tutorial 1a - Using a Quantum Device to Extract Machine-Learning Features": "tutorial 1a - Using a Quantum Device to Extract Machine-Learning Features - low-level.ipynb"
13+
- "Tutorial 2 - Machine-learning with the Quantum Evolution Kernel": "tutorial 2 - Machine-Learning with the Quantum EvolutionKernel.ipynb"
14+
- "(variant) Tutorial 2b - Training SVM QEK": "tutorial 1b - Training SVM QEK - low-level - generic dataset.ipynb"
1115
- Reference: $api/qek.***
1216
- Open-source:
1317
- Licence (MIT-Derived): LICENSE.md
@@ -53,6 +57,12 @@ markdown_extensions:
5357
plugins:
5458
- search
5559
- section-index
60+
- mkdocs-jupyter:
61+
include: ["*.ipynb"]
62+
execute: True
63+
remove_tag_config:
64+
remove_input_tags:
65+
- ignore_warnings
5666
- markdown-exec
5767
- mkapi
5868
- mkdocstrings:

0 commit comments

Comments
 (0)