Quantum Circuit Learning
In this tutorial, we show how to apply qadence
for solving a basic quantum
machine learning application: fitting a simple function with the
quantum circuit learning (QCL) algorithm.
Quantum circuit learning 1 is a supervised quantum machine learning algorithm that uses parametrized quantum neural networks to learn the behavior of an arbitrary mathematical function starting from some training data extracted from it. We choose the function
For this tutorial, we show how to fit the \(sin(x)\) function in the domain \([-1, 1]\).
Let's start with defining training and test data.
from typing import Callable
import torch
# make sure all tensors are kept on the same device
# only available from PyTorch 2.0
device = "cuda" if torch.cuda.is_available() else "cpu"
torch.set_default_device(device)
# notice that the domain does not include 1 and -1
# this avoids a singularity in the rotation angles when
# when encoding the domain points into the quantum circuit
# with a non-linear transformation (see below)
def qcl_training_data(
domain: tuple = (-0.99, 0.99), n_points: int = 100
) -> tuple[torch.Tensor, torch.Tensor]:
start, end = domain
x_rand, _ = torch.sort(torch.DoubleTensor(n_points).uniform_(start, end))
y_rand = torch.sin(x_rand)
return x_rand, y_rand
test_frac = 0.25
x, y = qcl_training_data()
n_test = int(len(x) * test_frac)
x_train, y_train = x[0:n_test-len(x)], y[0:n_test-len(x)]
x_test, y_test = x[n_test-len(x):], y[n_test-len(x):]
Train the QCL model
Qadence provides the QNN
convenience constructor to build a quantum neural network.
The QNN
class needs a circuit and a list of observables; both the number of feature parameters and the number
of observables in the list must be equal to the number of desired outputs of the quantum neural network.
As observable, we use the total qubit magnetization leveraging a convenience constructor provided by qadence
:
import sympy
import qadence as qd
from qadence.operations import RX
n_qubits = 8
# create a simple feature map with a non-linear parameter transformation
feature_param = qd.FeatureParameter("phi")
feature_map = qd.kron(RX(i, feature_param) for i in range(n_qubits))
featre_map = qd.tag(feature_map, "feature_map")
# create a digital-analog variational ansatz using Qadence convenience constructors
ansatz = qd.hea(n_qubits, depth=n_qubits, strategy=qd.Strategy.SDAQC)
ansatz = qd.tag(ansatz, "ansatz")
# total magnetization observable
observable = qd.hamiltonian_factory(n_qubits, detuning = qd.Z)
circuit = qd.QuantumCircuit(n_qubits, feature_map, ansatz)
model = qd.QNN(circuit, [observable])
expval = model(values=torch.rand(10))
print(expval)
The QCL algorithm uses the output of the quantum neural network as a tunable function approximator. We can use standard PyTorch code for training the QNN using a mean-square error loss, the Adam optimizer and also train on the GPU if any is available:
# train the model
n_epochs = 200
lr = 0.5
input_values = {"phi": x_train}
mse_loss = torch.nn.MSELoss() # standard PyTorch loss function
optimizer = torch.optim.Adam(model.parameters(), lr=lr) # standard PyTorch Adam optimizer
print(f"Initial loss: {mse_loss(model(input_values), y_train)}")
y_pred_initial = model({"phi": x_test})
running_loss = 0.0
for i in range(n_epochs):
optimizer.zero_grad()
loss = mse_loss(model(input_values), y_train)
loss.backward()
optimizer.step()
if (i+1) % 20 == 0:
print(f"Epoch {i+1} - Loss: {loss.item()}")
Initial loss: 0.04038257974270301
Epoch 20 - Loss: 0.060943553558947074
Epoch 40 - Loss: 0.02019946267299006
Epoch 60 - Loss: 0.03476874387797955
Epoch 80 - Loss: 0.10615164456464049
Epoch 100 - Loss: 1.2905890122975225
Epoch 120 - Loss: 0.21929946455255525
Epoch 140 - Loss: 0.013236293097701446
Epoch 160 - Loss: 0.016120784698980737
Epoch 180 - Loss: 0.023339611950154646
Epoch 200 - Loss: 0.03365795073769631
The quantum model is now trained on the training data points. Let's see how well it fits the function on the test set.
import matplotlib.pyplot as plt
y_pred = model({"phi": x_test})
# convert all the results to numpy arrays for plotting
x_train_np = x_train.cpu().detach().numpy().flatten()
y_train_np = y_train.cpu().detach().numpy().flatten()
x_test_np = x_test.cpu().detach().numpy().flatten()
y_pred_initial_np = y_pred_initial.cpu().detach().numpy().flatten()
y_pred_np = y_pred.cpu().detach().numpy().flatten()
fig, _ = plt.subplots()
plt.scatter(x_train_np, y_train_np, label="Training points", marker="o", color="orange")
plt.plot(x_test_np, y_pred_initial_np, label="Initial prediction", color="green", alpha=0.5)
plt.plot(x_test_np, y_pred_np, label="Final prediction")
plt.legend()
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="460.8pt" height="345.6pt" viewBox="0 0 460.8 345.6" xmlns="http://www.w3.org/2000/svg" version="1.1">
<metadata>
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<cc:Work>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:date>2023-10-10T21:44:47.358040</dc:date>
<dc:format>image/svg+xml</dc:format>
<dc:creator>
<cc:Agent>
<dc:title>Matplotlib v3.7.3, https://matplotlib.org/</dc:title>
</cc:Agent>
</dc:creator>
</cc:Work>
</rdf:RDF>
</metadata>
<defs>
<style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
</defs>
<g id="figure_1">
<g id="patch_1">
<path d="M 0 345.6
L 460.8 345.6
L 460.8 0
L 0 0
z
" style="fill: #ffffff"/>
</g>
<g id="axes_1">
<g id="patch_2">
<path d="M 57.6 307.584
L 414.72 307.584
L 414.72 41.472
L 57.6 41.472
z
" style="fill: #ffffff"/>
</g>
<g id="PathCollection_1">
<defs>
<path id="m35c160629b" d="M 0 3
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
C 2.683901 1.55874 3 0.795609 3 0
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
C 1.55874 -2.683901 0.795609 -3 0 -3
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
C -2.683901 -1.55874 -3 -0.795609 -3 0
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
C -1.55874 2.683901 -0.795609 3 0 3
z
" style="stroke: #ffa500"/>
</defs>
<g clip-path="url(#pfe8f3a97c8)">
<use xlink:href="#m35c160629b" x="73.832727" y="295.488" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="76.444293" y="293.46174" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="77.352048" y="292.746775" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="79.814458" y="290.779886" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="82.435471" y="288.642635" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="83.265341" y="287.95663" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="90.615669" y="281.688473" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="93.06401" y="279.525283" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="98.764986" y="274.346284" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="101.018411" y="272.245422" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="105.613865" y="267.868926" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="106.948085" y="266.575484" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="107.069051" y="266.457713" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="109.734667" y="263.841569" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="113.198769" y="260.382642" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="113.216208" y="260.365062" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="122.252911" y="251.036985" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="126.117629" y="246.918586" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="127.336906" y="245.60379" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="134.760075" y="237.444078" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="140.203184" y="231.298293" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="142.205778" y="229.004064" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="144.965472" y="225.814227" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="154.920388" y="214.048717" style="fill: #ffa500; stroke: #ffa500"/>
<use xlink:href="#m35c160629b" x="156.004477" y="212.744153" style="fill: #ffa500; stroke: #ffa500"/>
</g>
</g>
<g id="matplotlib.axis_1">
<g id="xtick_1">
<g id="line2d_1">
<defs>
<path id="md481e8b3d1" d="M 0 0
L 0 3.5
" style="stroke: #000000; stroke-width: 0.8"/>
</defs>
<g>
<use xlink:href="#md481e8b3d1" x="68.5969" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_1">
<!-- −1.00 -->
<g transform="translate(53.274243 322.182437) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-2212" d="M 678 2272
L 4684 2272
L 4684 1741
L 678 1741
L 678 2272
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-31" d="M 794 531
L 1825 531
L 1825 4091
L 703 3866
L 703 4441
L 1819 4666
L 2450 4666
L 2450 531
L 3481 531
L 3481 0
L 794 0
L 794 531
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-2e" d="M 684 794
L 1344 794
L 1344 0
L 684 0
L 684 794
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-30" d="M 2034 4250
Q 1547 4250 1301 3770
Q 1056 3291 1056 2328
Q 1056 1369 1301 889
Q 1547 409 2034 409
Q 2525 409 2770 889
Q 3016 1369 3016 2328
Q 3016 3291 2770 3770
Q 2525 4250 2034 4250
z
M 2034 4750
Q 2819 4750 3233 4129
Q 3647 3509 3647 2328
Q 3647 1150 3233 529
Q 2819 -91 2034 -91
Q 1250 -91 836 529
Q 422 1150 422 2328
Q 422 3509 836 4129
Q 1250 4750 2034 4750
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-31" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-30" x="179.199219"/>
<use xlink:href="#DejaVuSans-30" x="242.822266"/>
</g>
</g>
</g>
<g id="xtick_2">
<g id="line2d_2">
<g>
<use xlink:href="#md481e8b3d1" x="110.04231" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_2">
<!-- −0.75 -->
<g transform="translate(94.719654 322.182437) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-37" d="M 525 4666
L 3525 4666
L 3525 4397
L 1831 0
L 1172 0
L 2766 4134
L 525 4134
L 525 4666
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-35" d="M 691 4666
L 3169 4666
L 3169 4134
L 1269 4134
L 1269 2991
Q 1406 3038 1543 3061
Q 1681 3084 1819 3084
Q 2600 3084 3056 2656
Q 3513 2228 3513 1497
Q 3513 744 3044 326
Q 2575 -91 1722 -91
Q 1428 -91 1123 -41
Q 819 9 494 109
L 494 744
Q 775 591 1075 516
Q 1375 441 1709 441
Q 2250 441 2565 725
Q 2881 1009 2881 1497
Q 2881 1984 2565 2268
Q 2250 2553 1709 2553
Q 1456 2553 1204 2497
Q 953 2441 691 2322
L 691 4666
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-37" x="179.199219"/>
<use xlink:href="#DejaVuSans-35" x="242.822266"/>
</g>
</g>
</g>
<g id="xtick_3">
<g id="line2d_3">
<g>
<use xlink:href="#md481e8b3d1" x="151.48772" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_3">
<!-- −0.50 -->
<g transform="translate(136.165064 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-35" x="179.199219"/>
<use xlink:href="#DejaVuSans-30" x="242.822266"/>
</g>
</g>
</g>
<g id="xtick_4">
<g id="line2d_4">
<g>
<use xlink:href="#md481e8b3d1" x="192.93313" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_4">
<!-- −0.25 -->
<g transform="translate(177.610474 322.182437) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-32" d="M 1228 531
L 3431 531
L 3431 0
L 469 0
L 469 531
Q 828 903 1448 1529
Q 2069 2156 2228 2338
Q 2531 2678 2651 2914
Q 2772 3150 2772 3378
Q 2772 3750 2511 3984
Q 2250 4219 1831 4219
Q 1534 4219 1204 4116
Q 875 4013 500 3803
L 500 4441
Q 881 4594 1212 4672
Q 1544 4750 1819 4750
Q 2544 4750 2975 4387
Q 3406 4025 3406 3419
Q 3406 3131 3298 2873
Q 3191 2616 2906 2266
Q 2828 2175 2409 1742
Q 1991 1309 1228 531
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-32" x="179.199219"/>
<use xlink:href="#DejaVuSans-35" x="242.822266"/>
</g>
</g>
</g>
<g id="xtick_5">
<g id="line2d_5">
<g>
<use xlink:href="#md481e8b3d1" x="234.37854" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_5">
<!-- 0.00 -->
<g transform="translate(223.245728 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-30" x="95.410156"/>
<use xlink:href="#DejaVuSans-30" x="159.033203"/>
</g>
</g>
</g>
<g id="xtick_6">
<g id="line2d_6">
<g>
<use xlink:href="#md481e8b3d1" x="275.823951" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_6">
<!-- 0.25 -->
<g transform="translate(264.691138 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-32" x="95.410156"/>
<use xlink:href="#DejaVuSans-35" x="159.033203"/>
</g>
</g>
</g>
<g id="xtick_7">
<g id="line2d_7">
<g>
<use xlink:href="#md481e8b3d1" x="317.269361" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_7">
<!-- 0.50 -->
<g transform="translate(306.136548 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-35" x="95.410156"/>
<use xlink:href="#DejaVuSans-30" x="159.033203"/>
</g>
</g>
</g>
<g id="xtick_8">
<g id="line2d_8">
<g>
<use xlink:href="#md481e8b3d1" x="358.714771" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_8">
<!-- 0.75 -->
<g transform="translate(347.581959 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-37" x="95.410156"/>
<use xlink:href="#DejaVuSans-35" x="159.033203"/>
</g>
</g>
</g>
<g id="xtick_9">
<g id="line2d_9">
<g>
<use xlink:href="#md481e8b3d1" x="400.160181" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_9">
<!-- 1.00 -->
<g transform="translate(389.027369 322.182437) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-31"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-30" x="95.410156"/>
<use xlink:href="#DejaVuSans-30" x="159.033203"/>
</g>
</g>
</g>
</g>
<g id="matplotlib.axis_2">
<g id="ytick_1">
<g id="line2d_10">
<defs>
<path id="m4c24411f41" d="M 0 0
L -3.5 0
" style="stroke: #000000; stroke-width: 0.8"/>
</defs>
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="290.103413" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_10">
<!-- −0.8 -->
<g transform="translate(26.317187 293.902632) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-38" d="M 2034 2216
Q 1584 2216 1326 1975
Q 1069 1734 1069 1313
Q 1069 891 1326 650
Q 1584 409 2034 409
Q 2484 409 2743 651
Q 3003 894 3003 1313
Q 3003 1734 2745 1975
Q 2488 2216 2034 2216
z
M 1403 2484
Q 997 2584 770 2862
Q 544 3141 544 3541
Q 544 4100 942 4425
Q 1341 4750 2034 4750
Q 2731 4750 3128 4425
Q 3525 4100 3525 3541
Q 3525 3141 3298 2862
Q 3072 2584 2669 2484
Q 3125 2378 3379 2068
Q 3634 1759 3634 1313
Q 3634 634 3220 271
Q 2806 -91 2034 -91
Q 1263 -91 848 271
Q 434 634 434 1313
Q 434 1759 690 2068
Q 947 2378 1403 2484
z
M 1172 3481
Q 1172 3119 1398 2916
Q 1625 2713 2034 2713
Q 2441 2713 2670 2916
Q 2900 3119 2900 3481
Q 2900 3844 2670 4047
Q 2441 4250 2034 4250
Q 1625 4250 1398 4047
Q 1172 3844 1172 3481
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-38" x="179.199219"/>
</g>
</g>
</g>
<g id="ytick_2">
<g id="line2d_11">
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="245.213142" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_11">
<!-- −0.6 -->
<g transform="translate(26.317187 249.012361) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-36" d="M 2113 2584
Q 1688 2584 1439 2293
Q 1191 2003 1191 1497
Q 1191 994 1439 701
Q 1688 409 2113 409
Q 2538 409 2786 701
Q 3034 994 3034 1497
Q 3034 2003 2786 2293
Q 2538 2584 2113 2584
z
M 3366 4563
L 3366 3988
Q 3128 4100 2886 4159
Q 2644 4219 2406 4219
Q 1781 4219 1451 3797
Q 1122 3375 1075 2522
Q 1259 2794 1537 2939
Q 1816 3084 2150 3084
Q 2853 3084 3261 2657
Q 3669 2231 3669 1497
Q 3669 778 3244 343
Q 2819 -91 2113 -91
Q 1303 -91 875 529
Q 447 1150 447 2328
Q 447 3434 972 4092
Q 1497 4750 2381 4750
Q 2619 4750 2861 4703
Q 3103 4656 3366 4563
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-36" x="179.199219"/>
</g>
</g>
</g>
<g id="ytick_3">
<g id="line2d_12">
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="200.322871" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_12">
<!-- −0.4 -->
<g transform="translate(26.317187 204.12209) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-34" d="M 2419 4116
L 825 1625
L 2419 1625
L 2419 4116
z
M 2253 4666
L 3047 4666
L 3047 1625
L 3713 1625
L 3713 1100
L 3047 1100
L 3047 0
L 2419 0
L 2419 1100
L 313 1100
L 313 1709
L 2253 4666
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-34" x="179.199219"/>
</g>
</g>
</g>
<g id="ytick_4">
<g id="line2d_13">
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="155.4326" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_13">
<!-- −0.2 -->
<g transform="translate(26.317187 159.231819) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-2212"/>
<use xlink:href="#DejaVuSans-30" x="83.789062"/>
<use xlink:href="#DejaVuSans-2e" x="147.412109"/>
<use xlink:href="#DejaVuSans-32" x="179.199219"/>
</g>
</g>
</g>
<g id="ytick_5">
<g id="line2d_14">
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="110.542329" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_14">
<!-- 0.0 -->
<g transform="translate(34.696875 114.341548) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-30" x="95.410156"/>
</g>
</g>
</g>
<g id="ytick_6">
<g id="line2d_15">
<g>
<use xlink:href="#m4c24411f41" x="57.6" y="65.652058" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_15">
<!-- 0.2 -->
<g transform="translate(34.696875 69.451276) scale(0.1 -0.1)">
<use xlink:href="#DejaVuSans-30"/>
<use xlink:href="#DejaVuSans-2e" x="63.623047"/>
<use xlink:href="#DejaVuSans-32" x="95.410156"/>
</g>
</g>
</g>
</g>
<g id="line2d_16">
<path d="M 158.047058 209.764067
L 158.493768 209.893067
L 160.4537 210.523696
L 161.436968 210.87927
L 163.889049 211.877548
L 166.177749 212.9488
L 169.417748 214.684091
L 172.511588 216.564192
L 174.1609 217.64866
L 177.310134 219.863348
L 182.184882 223.611639
L 183.930028 225.031056
L 190.358524 230.499142
L 194.588991 234.204109
L 195.64228 235.127741
L 196.774266 236.117926
L 203.865259 242.160351
L 205.468552 243.462405
L 211.993095 248.36824
L 212.404886 248.652384
L 212.491588 248.711772
L 219.081978 252.729806
L 221.588951 253.969095
L 223.58233 254.826684
L 228.349846 256.381673
L 232.744962 257.147784
L 240.395848 256.829799
L 245.634281 255.345848
L 247.047044 254.766666
L 247.768722 254.441484
L 250.259463 253.167472
L 255.122316 250.010559
L 256.261009 249.145795
L 260.935617 245.113576
L 263.971829 242.094777
L 269.2018 236.206921
L 271.190088 233.755509
L 272.08308 232.618693
L 272.173162 232.502814
L 284.193732 215.306067
L 290.620786 204.994747
L 301.292886 186.881893
L 302.642674 184.542419
L 303.360979 183.295349
L 304.182592 181.867572
L 307.359815 176.339514
L 308.051757 175.135565
L 310.776023 170.401789
L 312.400552 167.587309
L 313.34046 165.96299
L 315.392325 162.429917
L 316.993331 159.68773
L 319.454874 155.501377
L 322.029611 151.167324
L 327.131099 142.740338
L 328.300456 140.842243
L 335.46288 129.522471
L 346.819169 112.75327
L 350.133359 108.142335
L 351.918088 105.711895
L 353.11362 104.104201
L 356.125463 100.125561
L 357.572211 98.250303
L 362.190662 92.415629
L 366.765246 86.856036
L 371.625094 81.177117
L 374.986792 77.379439
L 381.251319 70.573434
L 382.585928 69.167579
L 384.162399 67.526477
L 385.059066 66.602419
L 389.384204 62.239738
L 393.287544 58.436305
L 397.693843 54.296044
L 398.487273 53.568
" clip-path="url(#pfe8f3a97c8)" style="fill: none; stroke: #008000; stroke-opacity: 0.5; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_17">
<path d="M 158.047058 238.657706
L 158.493768 238.586674
L 160.4537 238.270032
L 161.436968 238.108055
L 163.889049 237.694671
L 166.177749 237.296049
L 169.417748 236.708899
L 172.511588 236.120751
L 174.1609 235.795183
L 177.310134 235.148038
L 182.184882 234.072442
L 183.930028 233.663079
L 190.358524 232.028863
L 194.588991 230.832266
L 195.64228 230.517952
L 196.774266 230.172541
L 203.865259 227.819487
L 205.468552 227.240015
L 211.993095 224.692189
L 212.404886 224.521013
L 212.491588 224.484814
L 219.081978 221.5732
L 221.588951 220.38402
L 223.58233 219.407518
L 228.349846 216.966604
L 232.744962 214.596348
L 240.395848 210.250922
L 245.634281 207.169493
L 247.047044 206.331151
L 247.768722 205.902413
L 250.259463 204.422605
L 255.122316 201.553148
L 256.261009 200.88921
L 260.935617 198.217439
L 263.971829 196.544898
L 269.2018 193.825204
L 271.190088 192.85685
L 272.08308 192.435401
L 272.173162 192.393371
L 284.193732 187.729798
L 290.620786 186.165335
L 301.292886 185.314389
L 302.642674 185.374649
L 303.360979 185.422624
L 304.182592 185.491111
L 307.359815 185.893423
L 308.051757 186.010113
L 310.776023 186.570729
L 312.400552 186.981672
L 313.34046 187.24545
L 315.392325 187.887077
L 316.993331 188.449798
L 319.454874 189.41939
L 322.029611 190.565849
L 327.131099 193.218471
L 328.300456 193.894225
L 335.46288 198.529042
L 346.819169 207.263606
L 350.133359 210.025322
L 351.918088 211.535358
L 353.11362 212.553128
L 356.125463 215.13007
L 357.572211 216.369984
L 362.190662 220.305429
L 366.765246 224.113425
L 371.625094 227.981091
L 374.986792 230.506909
L 381.251319 234.788567
L 382.585928 235.617456
L 384.162399 236.5547
L 385.059066 237.066776
L 389.384204 239.309386
L 393.287544 240.986448
L 397.693843 242.451988
L 398.487273 242.665485
" clip-path="url(#pfe8f3a97c8)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="patch_3">
<path d="M 57.6 307.584
L 57.6 41.472
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
</g>
<g id="patch_4">
<path d="M 414.72 307.584
L 414.72 41.472
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
</g>
<g id="patch_5">
<path d="M 57.6 307.584
L 414.72 307.584
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
</g>
<g id="patch_6">
<path d="M 57.6 41.472
L 414.72 41.472
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
</g>
<g id="legend_1">
<g id="patch_7">
<path d="M 64.6 93.506375
L 177.615625 93.506375
Q 179.615625 93.506375 179.615625 91.506375
L 179.615625 48.472
Q 179.615625 46.472 177.615625 46.472
L 64.6 46.472
Q 62.6 46.472 62.6 48.472
L 62.6 91.506375
Q 62.6 93.506375 64.6 93.506375
z
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
</g>
<g id="PathCollection_2">
<g>
<use xlink:href="#m35c160629b" x="76.6" y="55.445438" style="fill: #ffa500; stroke: #ffa500"/>
</g>
</g>
<g id="text_16">
<!-- Training points -->
<g transform="translate(94.6 58.070438) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-54" d="M -19 4666
L 3928 4666
L 3928 4134
L 2272 4134
L 2272 0
L 1638 0
L 1638 4134
L -19 4134
L -19 4666
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-72" d="M 2631 2963
Q 2534 3019 2420 3045
Q 2306 3072 2169 3072
Q 1681 3072 1420 2755
Q 1159 2438 1159 1844
L 1159 0
L 581 0
L 581 3500
L 1159 3500
L 1159 2956
Q 1341 3275 1631 3429
Q 1922 3584 2338 3584
Q 2397 3584 2469 3576
Q 2541 3569 2628 3553
L 2631 2963
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-61" d="M 2194 1759
Q 1497 1759 1228 1600
Q 959 1441 959 1056
Q 959 750 1161 570
Q 1363 391 1709 391
Q 2188 391 2477 730
Q 2766 1069 2766 1631
L 2766 1759
L 2194 1759
z
M 3341 1997
L 3341 0
L 2766 0
L 2766 531
Q 2569 213 2275 61
Q 1981 -91 1556 -91
Q 1019 -91 701 211
Q 384 513 384 1019
Q 384 1609 779 1909
Q 1175 2209 1959 2209
L 2766 2209
L 2766 2266
Q 2766 2663 2505 2880
Q 2244 3097 1772 3097
Q 1472 3097 1187 3025
Q 903 2953 641 2809
L 641 3341
Q 956 3463 1253 3523
Q 1550 3584 1831 3584
Q 2591 3584 2966 3190
Q 3341 2797 3341 1997
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-69" d="M 603 3500
L 1178 3500
L 1178 0
L 603 0
L 603 3500
z
M 603 4863
L 1178 4863
L 1178 4134
L 603 4134
L 603 4863
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-6e" d="M 3513 2113
L 3513 0
L 2938 0
L 2938 2094
Q 2938 2591 2744 2837
Q 2550 3084 2163 3084
Q 1697 3084 1428 2787
Q 1159 2491 1159 1978
L 1159 0
L 581 0
L 581 3500
L 1159 3500
L 1159 2956
Q 1366 3272 1645 3428
Q 1925 3584 2291 3584
Q 2894 3584 3203 3211
Q 3513 2838 3513 2113
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-67" d="M 2906 1791
Q 2906 2416 2648 2759
Q 2391 3103 1925 3103
Q 1463 3103 1205 2759
Q 947 2416 947 1791
Q 947 1169 1205 825
Q 1463 481 1925 481
Q 2391 481 2648 825
Q 2906 1169 2906 1791
z
M 3481 434
Q 3481 -459 3084 -895
Q 2688 -1331 1869 -1331
Q 1566 -1331 1297 -1286
Q 1028 -1241 775 -1147
L 775 -588
Q 1028 -725 1275 -790
Q 1522 -856 1778 -856
Q 2344 -856 2625 -561
Q 2906 -266 2906 331
L 2906 616
Q 2728 306 2450 153
Q 2172 0 1784 0
Q 1141 0 747 490
Q 353 981 353 1791
Q 353 2603 747 3093
Q 1141 3584 1784 3584
Q 2172 3584 2450 3431
Q 2728 3278 2906 2969
L 2906 3500
L 3481 3500
L 3481 434
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-20" transform="scale(0.015625)"/>
<path id="DejaVuSans-70" d="M 1159 525
L 1159 -1331
L 581 -1331
L 581 3500
L 1159 3500
L 1159 2969
Q 1341 3281 1617 3432
Q 1894 3584 2278 3584
Q 2916 3584 3314 3078
Q 3713 2572 3713 1747
Q 3713 922 3314 415
Q 2916 -91 2278 -91
Q 1894 -91 1617 61
Q 1341 213 1159 525
z
M 3116 1747
Q 3116 2381 2855 2742
Q 2594 3103 2138 3103
Q 1681 3103 1420 2742
Q 1159 2381 1159 1747
Q 1159 1113 1420 752
Q 1681 391 2138 391
Q 2594 391 2855 752
Q 3116 1113 3116 1747
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-6f" d="M 1959 3097
Q 1497 3097 1228 2736
Q 959 2375 959 1747
Q 959 1119 1226 758
Q 1494 397 1959 397
Q 2419 397 2687 759
Q 2956 1122 2956 1747
Q 2956 2369 2687 2733
Q 2419 3097 1959 3097
z
M 1959 3584
Q 2709 3584 3137 3096
Q 3566 2609 3566 1747
Q 3566 888 3137 398
Q 2709 -91 1959 -91
Q 1206 -91 779 398
Q 353 888 353 1747
Q 353 2609 779 3096
Q 1206 3584 1959 3584
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-74" d="M 1172 4494
L 1172 3500
L 2356 3500
L 2356 3053
L 1172 3053
L 1172 1153
Q 1172 725 1289 603
Q 1406 481 1766 481
L 2356 481
L 2356 0
L 1766 0
Q 1100 0 847 248
Q 594 497 594 1153
L 594 3053
L 172 3053
L 172 3500
L 594 3500
L 594 4494
L 1172 4494
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-73" d="M 2834 3397
L 2834 2853
Q 2591 2978 2328 3040
Q 2066 3103 1784 3103
Q 1356 3103 1142 2972
Q 928 2841 928 2578
Q 928 2378 1081 2264
Q 1234 2150 1697 2047
L 1894 2003
Q 2506 1872 2764 1633
Q 3022 1394 3022 966
Q 3022 478 2636 193
Q 2250 -91 1575 -91
Q 1294 -91 989 -36
Q 684 19 347 128
L 347 722
Q 666 556 975 473
Q 1284 391 1588 391
Q 1994 391 2212 530
Q 2431 669 2431 922
Q 2431 1156 2273 1281
Q 2116 1406 1581 1522
L 1381 1569
Q 847 1681 609 1914
Q 372 2147 372 2553
Q 372 3047 722 3315
Q 1072 3584 1716 3584
Q 2034 3584 2315 3537
Q 2597 3491 2834 3397
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-54"/>
<use xlink:href="#DejaVuSans-72" x="46.333984"/>
<use xlink:href="#DejaVuSans-61" x="87.447266"/>
<use xlink:href="#DejaVuSans-69" x="148.726562"/>
<use xlink:href="#DejaVuSans-6e" x="176.509766"/>
<use xlink:href="#DejaVuSans-69" x="239.888672"/>
<use xlink:href="#DejaVuSans-6e" x="267.671875"/>
<use xlink:href="#DejaVuSans-67" x="331.050781"/>
<use xlink:href="#DejaVuSans-20" x="394.527344"/>
<use xlink:href="#DejaVuSans-70" x="426.314453"/>
<use xlink:href="#DejaVuSans-6f" x="489.791016"/>
<use xlink:href="#DejaVuSans-69" x="550.972656"/>
<use xlink:href="#DejaVuSans-6e" x="578.755859"/>
<use xlink:href="#DejaVuSans-74" x="642.134766"/>
<use xlink:href="#DejaVuSans-73" x="681.34375"/>
</g>
</g>
<g id="line2d_18">
<path d="M 66.6 69.248563
L 76.6 69.248563
L 86.6 69.248563
" style="fill: none; stroke: #008000; stroke-opacity: 0.5; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="text_17">
<!-- Initial prediction -->
<g transform="translate(94.6 72.748563) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-49" d="M 628 4666
L 1259 4666
L 1259 0
L 628 0
L 628 4666
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-6c" d="M 603 4863
L 1178 4863
L 1178 0
L 603 0
L 603 4863
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-65" d="M 3597 1894
L 3597 1613
L 953 1613
Q 991 1019 1311 708
Q 1631 397 2203 397
Q 2534 397 2845 478
Q 3156 559 3463 722
L 3463 178
Q 3153 47 2828 -22
Q 2503 -91 2169 -91
Q 1331 -91 842 396
Q 353 884 353 1716
Q 353 2575 817 3079
Q 1281 3584 2069 3584
Q 2775 3584 3186 3129
Q 3597 2675 3597 1894
z
M 3022 2063
Q 3016 2534 2758 2815
Q 2500 3097 2075 3097
Q 1594 3097 1305 2825
Q 1016 2553 972 2059
L 3022 2063
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-64" d="M 2906 2969
L 2906 4863
L 3481 4863
L 3481 0
L 2906 0
L 2906 525
Q 2725 213 2448 61
Q 2172 -91 1784 -91
Q 1150 -91 751 415
Q 353 922 353 1747
Q 353 2572 751 3078
Q 1150 3584 1784 3584
Q 2172 3584 2448 3432
Q 2725 3281 2906 2969
z
M 947 1747
Q 947 1113 1208 752
Q 1469 391 1925 391
Q 2381 391 2643 752
Q 2906 1113 2906 1747
Q 2906 2381 2643 2742
Q 2381 3103 1925 3103
Q 1469 3103 1208 2742
Q 947 2381 947 1747
z
" transform="scale(0.015625)"/>
<path id="DejaVuSans-63" d="M 3122 3366
L 3122 2828
Q 2878 2963 2633 3030
Q 2388 3097 2138 3097
Q 1578 3097 1268 2742
Q 959 2388 959 1747
Q 959 1106 1268 751
Q 1578 397 2138 397
Q 2388 397 2633 464
Q 2878 531 3122 666
L 3122 134
Q 2881 22 2623 -34
Q 2366 -91 2075 -91
Q 1284 -91 818 406
Q 353 903 353 1747
Q 353 2603 823 3093
Q 1294 3584 2113 3584
Q 2378 3584 2631 3529
Q 2884 3475 3122 3366
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-49"/>
<use xlink:href="#DejaVuSans-6e" x="29.492188"/>
<use xlink:href="#DejaVuSans-69" x="92.871094"/>
<use xlink:href="#DejaVuSans-74" x="120.654297"/>
<use xlink:href="#DejaVuSans-69" x="159.863281"/>
<use xlink:href="#DejaVuSans-61" x="187.646484"/>
<use xlink:href="#DejaVuSans-6c" x="248.925781"/>
<use xlink:href="#DejaVuSans-20" x="276.708984"/>
<use xlink:href="#DejaVuSans-70" x="308.496094"/>
<use xlink:href="#DejaVuSans-72" x="371.972656"/>
<use xlink:href="#DejaVuSans-65" x="410.835938"/>
<use xlink:href="#DejaVuSans-64" x="472.359375"/>
<use xlink:href="#DejaVuSans-69" x="535.835938"/>
<use xlink:href="#DejaVuSans-63" x="563.619141"/>
<use xlink:href="#DejaVuSans-74" x="618.599609"/>
<use xlink:href="#DejaVuSans-69" x="657.808594"/>
<use xlink:href="#DejaVuSans-6f" x="685.591797"/>
<use xlink:href="#DejaVuSans-6e" x="746.773438"/>
</g>
</g>
<g id="line2d_19">
<path d="M 66.6 83.926688
L 76.6 83.926688
L 86.6 83.926688
" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="text_18">
<!-- Final prediction -->
<g transform="translate(94.6 87.426688) scale(0.1 -0.1)">
<defs>
<path id="DejaVuSans-46" d="M 628 4666
L 3309 4666
L 3309 4134
L 1259 4134
L 1259 2759
L 3109 2759
L 3109 2228
L 1259 2228
L 1259 0
L 628 0
L 628 4666
z
" transform="scale(0.015625)"/>
</defs>
<use xlink:href="#DejaVuSans-46"/>
<use xlink:href="#DejaVuSans-69" x="50.269531"/>
<use xlink:href="#DejaVuSans-6e" x="78.052734"/>
<use xlink:href="#DejaVuSans-61" x="141.431641"/>
<use xlink:href="#DejaVuSans-6c" x="202.710938"/>
<use xlink:href="#DejaVuSans-20" x="230.494141"/>
<use xlink:href="#DejaVuSans-70" x="262.28125"/>
<use xlink:href="#DejaVuSans-72" x="325.757812"/>
<use xlink:href="#DejaVuSans-65" x="364.621094"/>
<use xlink:href="#DejaVuSans-64" x="426.144531"/>
<use xlink:href="#DejaVuSans-69" x="489.621094"/>
<use xlink:href="#DejaVuSans-63" x="517.404297"/>
<use xlink:href="#DejaVuSans-74" x="572.384766"/>
<use xlink:href="#DejaVuSans-69" x="611.59375"/>
<use xlink:href="#DejaVuSans-6f" x="639.376953"/>
<use xlink:href="#DejaVuSans-6e" x="700.558594"/>
</g>
</g>
</g>
</g>
</g>
<defs>
<clipPath id="pfe8f3a97c8">
<rect x="57.6" y="41.472" width="357.12" height="266.112"/>
</clipPath>
</defs>
</svg>