Skip to content

Commit 3599033

Browse files
[Docs] Update notebook with mention of IntegratedQEK. (#114)
* Update notebook with mention of IntegratedQEK. * Fix missing import. * Invert cell order to avoid failing test. * Apply feedback.
1 parent c819a79 commit 3599033

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,47 @@
137137
"$$\n",
138138
"\n",
139139
"\n",
140-
"where $\\mu$ is an hyperparameter of our kernel and $JS$ is the Jensen-Shannon divergence.\n",
141-
" "
140+
"where $\\mu$ is an hyperparameter of our kernel and $JS$ is the Jensen-Shannon divergence. For processing raw graph data, the IntegratedQEK is recommended; however, it requires an extractor to be provided as an argument."
141+
]
142+
},
143+
{
144+
"cell_type": "code",
145+
"execution_count": null,
146+
"id": "05964cf6-d96d-42ee-9b1e-707110d55917",
147+
"metadata": {},
148+
"outputs": [],
149+
"source": [
150+
"import qek.data.extractors as qek_extractors\n",
151+
"import qek.data.graphs as qek_graphs\n",
152+
"from qek.kernel import IntegratedQEK as QEK\n",
153+
"from pathlib import Path\n",
154+
"\n",
155+
"# First, we need to intantiate the compiler for the type of data.\n",
156+
"compiler = qek_graphs.PTCFMCompiler()\n",
157+
"\n",
158+
"# Then, instantiate the Qutip Extractor.\n",
159+
"extractor = qek_extractors.QutipExtractor(\n",
160+
" # Once computing is complete, data will be saved in this file.\n",
161+
" path=Path(\"saved_data.json\"),\n",
162+
" compiler=compiler\n",
163+
")\n",
164+
"\n",
165+
"# Finally, initialize the Integrated Quantum Evolution Kernel with both the extractor and the parameter mu.\n",
166+
"kernel = QEK(mu=0.5, extractor=extractor)"
167+
]
168+
},
169+
{
170+
"cell_type": "markdown",
171+
"id": "fae79440-b962-40fa-8274-ebffa48ccfb1",
172+
"metadata": {},
173+
"source": [
174+
" In this case and since data has already been pre-processed, we will use the `FastQEK` kernel instead that speeds-up the computation and allows for computing matrix similarities."
142175
]
143176
},
144177
{
145178
"cell_type": "code",
146179
"execution_count": null,
147-
"id": "55f264f6-18f5-4009-930a-12cce4a2cb87",
180+
"id": "000780dc-cb6a-4d70-bfe4-c86bbf281278",
148181
"metadata": {},
149182
"outputs": [],
150183
"source": [
@@ -629,7 +662,7 @@
629662
"name": "python",
630663
"nbconvert_exporter": "python",
631664
"pygments_lexer": "ipython3",
632-
"version": "3.12.3"
665+
"version": "3.12.7"
633666
}
634667
},
635668
"nbformat": 4,

0 commit comments

Comments
 (0)