Skip to content

Commit

Permalink
fix: correct qsvc notebook again
Browse files Browse the repository at this point in the history
  • Loading branch information
akatief committed Apr 13, 2022
1 parent f4d3c83 commit 55903b8
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions examples/qsvc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,24 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 8,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting matplotlib\r\n",
" Using cached matplotlib-3.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)\r\n",
"Collecting kiwisolver>=1.0.1\r\n",
" Using cached kiwisolver-1.4.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.6 MB)\r\n",
"Requirement already satisfied: numpy>=1.17 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (1.21.5)\r\n",
"Collecting cycler>=0.10\r\n",
" Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)\r\n",
"Collecting pillow>=6.2.0\r\n",
" Using cached Pillow-9.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)\r\n",
"Collecting fonttools>=4.22.0\r\n",
" Using cached fonttools-4.32.0-py3-none-any.whl (900 kB)\r\n",
"Requirement already satisfied: packaging>=20.0 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (21.3)\r\n",
"Requirement already satisfied: matplotlib in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (3.5.1)\r\n",
"Requirement already satisfied: cycler>=0.10 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (0.11.0)\r\n",
"Requirement already satisfied: python-dateutil>=2.7 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (2.8.2)\r\n",
"Requirement already satisfied: packaging>=20.0 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (21.3)\r\n",
"Requirement already satisfied: pillow>=6.2.0 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (9.1.0)\r\n",
"Requirement already satisfied: numpy>=1.17 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (1.21.5)\r\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (1.4.2)\r\n",
"Requirement already satisfied: fonttools>=4.22.0 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (4.32.0)\r\n",
"Requirement already satisfied: pyparsing>=2.2.1 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from matplotlib) (3.0.8)\r\n",
"Requirement already satisfied: six>=1.5 in /home/akatief/PycharmProjects/qlearnkit/.venv/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\r\n",
"Installing collected packages: pillow, kiwisolver, fonttools, cycler, matplotlib\r\n",
"Successfully installed cycler-0.11.0 fonttools-4.32.0 kiwisolver-1.4.2 matplotlib-3.5.1 pillow-9.1.0\r\n"
"\u001B[33mWARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.\r\n",
"You should consider upgrading via the '/home/akatief/PycharmProjects/qlearnkit/.venv/bin/python -m pip install --upgrade pip' command.\u001B[0m\r\n"
]
}
],
Expand All @@ -78,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 9,
"outputs": [],
"source": [
"import numpy as np\n",
Expand Down Expand Up @@ -112,7 +107,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 10,
"outputs": [],
"source": [
"# import some data to play with\n",
Expand Down Expand Up @@ -144,7 +139,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 11,
"outputs": [],
"source": [
"seed = 42\n",
Expand Down Expand Up @@ -176,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 12,
"outputs": [],
"source": [
"svc = SVC(kernel='linear')\n",
Expand All @@ -203,7 +198,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 13,
"outputs": [],
"source": [
"svc.fit(X,y)\n",
Expand Down Expand Up @@ -271,7 +266,7 @@
"name": "#%%\n"
}
},
"execution_count": 28,
"execution_count": 14,
"outputs": [
{
"data": {
Expand All @@ -286,11 +281,7 @@
{
"cell_type": "markdown",
"source": [
"Notice how the quantum boundary is nonlinear. This is a consequence of the Pauli feature map we used. Different settings and different feature maps give different results.\n",
"\n",
"In case you want to try with a different backend simulator you could also use Aer or QASM.\n",
"\n",
"Be aware that it's gonna be way slower because of qiskit simulators.\n"
"Notice how the quantum boundary is nonlinear. This is a consequence of the Pauli feature map we used. Different settings and different feature maps give different results. The choice of simulator also plays a role in how the final boundary looks like. In this example QASM - a noisy backend - was used. In case you want to try with a different backend simulator you could also use QASM (a complete list is available on the Qiskit documentation).\n"
],
"metadata": {
"collapsed": false,
Expand Down

0 comments on commit 55903b8

Please sign in to comment.