Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtutorial.html
More file actions
Latest commit
423 lines (286 loc) · 24.9 KB
/
Copy pathtutorial.html
File metadata and controls
423 lines (286 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--><htmlclass="no-js" lang="en" ><!--<![endif]-->
<head>
<metacharset="utf-8">
<metaname="viewport" content="width=device-width, initial-scale=1.0">
<title>QML Tutorial — QML 0.4.0 documentation</title>
<linkrel="stylesheet" href="_static/css/theme.css" type="text/css" />
<linkrel="stylesheet" href="_static/pygments.css" type="text/css" />
<linkrel="index" title="Index" href="genindex.html" />
<linkrel="search" title="Search" href="search.html" />
<linkrel="next" title="Examples" href="examples.html" />
<linkrel="prev" title="Citing use of QML" href="citation.html" />
<scriptsrc="_static/js/modernizr.min.js"></script>
</head>
<bodyclass="wy-body-for-nav">
<divclass="wy-grid-for-nav">
<navdata-toggle="wy-nav-shift" class="wy-nav-side">
<divclass="wy-side-scroll">
<divclass="wy-side-nav-search">
<ahref="index.html" class="icon icon-home"> QML
</a>
<divrole="search">
<formid="rtd-search-form" class="wy-form" action="search.html" method="get">
<inputtype="text" name="q" placeholder="Search docs" />
<inputtype="hidden" name="check_keywords" value="yes" />
<inputtype="hidden" name="area" value="default" />
</form>
</div>
</div>
<divclass="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<pclass="caption"><spanclass="caption-text">GETTING STARTED:</span></p>
<ulclass="current">
<liclass="toctree-l1"><aclass="reference internal" href="installation.html">Installing QML</a></li>
<liclass="toctree-l1"><aclass="reference internal" href="citation.html">Citing use of QML</a></li>
<liclass="toctree-l1 current"><aclass="current reference internal" href="#">QML Tutorial</a><ul>
<liclass="toctree-l2"><aclass="reference internal" href="#theory">Theory</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#tutorial-exercises">Tutorial exercises</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-1-representations">Exercise 1: Representations</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-2-kernels">Exercise 2: Kernels</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-3-regression">Exercise 3: Regression</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-4-prediction">Exercise 4: Prediction</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-5-learning-curves">Exercise 5: Learning curves</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#exercise-6-delta-learning">Exercise 6: Delta learning</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="#references">References</a></li>
</ul>
</li>
<liclass="toctree-l1"><aclass="reference internal" href="examples.html">Examples</a></li>
</ul>
<pclass="caption"><spanclass="caption-text">SOURCE DOCUMENTATION:</span></p>
<ul>
<liclass="toctree-l1"><aclass="reference internal" href="qml.html">Python API documentation</a></li>
</ul>
</div>
</div>
</nav>
<sectiondata-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<navclass="wy-nav-top" aria-label="top navigation">
<idata-toggle="wy-nav-top" class="fa fa-bars"></i>
<ahref="index.html">QML</a>
</nav>
<divclass="wy-nav-content">
<divclass="rst-content">
<divrole="navigation" aria-label="breadcrumbs navigation">
<ulclass="wy-breadcrumbs">
<li><ahref="index.html">Docs</a> »</li>
<li>QML Tutorial</li>
<liclass="wy-breadcrumbs-aside">
<ahref="_sources/tutorial.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<divrole="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<divitemprop="articleBody">
<divclass="section" id="qml-tutorial">
<h1>QML Tutorial<aclass="headerlink" href="#qml-tutorial" title="Permalink to this headline">¶</a></h1>
<p>This tutorial is a general introduction to kernel-ridge regression with QML.</p>
<divclass="section" id="theory">
<h2>Theory<aclass="headerlink" href="#theory" title="Permalink to this headline">¶</a></h2>
<p>Regression model of some property, <spanclass="math notranslate nohighlight">\(y\)</span>, for some system, <spanclass="math notranslate nohighlight">\(\widetilde{\mathbf{X}}\)</span> - this could correspond to e.g. the atomization energy of a molecule:</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(y\left(\widetilde{\mathbf{X}} \right) = \sum_i \alpha_i \ K\left( \widetilde{\mathbf{X}}, \mathbf{X}_i\right)\)</span></div></blockquote>
<p>E.g. Using Gaussian kernel function with Frobenius norm:</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(K_{ij} = K\left( \mathbf{X}_i, \mathbf{X}_j\right) = \exp\left( -\frac{\| \mathbf{X}_i - \mathbf{X}_j\|_2^2}{2\sigma^2}\right)\)</span></div></blockquote>
<p>Regression coefficients are obtained through kernel matrix inversion and multiplication with reference labels</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(\boldsymbol{\alpha} = (\mathbf{K} + \lambda \mathbf{I})^{-1} \mathbf{y}\)</span></div></blockquote>
</div>
<divclass="section" id="tutorial-exercises">
<h2>Tutorial exercises<aclass="headerlink" href="#tutorial-exercises" title="Permalink to this headline">¶</a></h2>
<p>Clone the following GIT repository to access the necessary scripts and QM7 dataset (atomization energies and relaxed geometries at PBE0/def2-TZVP level of theory) for ~7k GDB1-7 molecules. <aclass="footnote-reference" href="#rupp" id="id1">[1]</a><aclass="footnote-reference" href="#ruddigkeit" id="id2">[2]</a></p>
<divclass="code bash highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="n">git</span><spanclass="n">clone</span><spanclass="n">https</span><spanclass="p">:</span><spanclass="o">//</span><spanclass="n">github</span><spanclass="o">.</span><spanclass="n">com</span><spanclass="o">/</span><spanclass="n">qmlcode</span><spanclass="o">/</span><spanclass="n">tutorial</span><spanclass="o">.</span><spanclass="n">git</span>
</pre></div>
</div>
<p>Additionally, the repository contains Python3 scripts with the solutions to each exercise.</p>
</div>
<divclass="section" id="exercise-1-representations">
<h2>Exercise 1: Representations<aclass="headerlink" href="#exercise-1-representations" title="Permalink to this headline">¶</a></h2>
<p>In this exercise we use qml~to generate the Coulomb matrix and Bag of bonds (BoB) representations. <aclass="footnote-reference" href="#montavon" id="id3">[3]</a>
In QML data can be parsed via the <codeclass="docutils literal notranslate"><spanclass="pre">Compound</span></code> class, which stores data and generates representations in Numpy’s ndarray format.
If you run the code below, you will read in the file <codeclass="docutils literal notranslate"><spanclass="pre">qm7/0001.xyz</span></code> (a methane molecule) and generate a coulomb matrix representation (sorted by row-norm) and a BoB representation.</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="kn">import</span><spanclass="nn">qml</span>
<spanclass="c1"># Create the compound object mol from the file qm7/0001.xyz which happens to be methane</span>
<spanclass="n">mol</span><spanclass="o">=</span><spanclass="n">qml</span><spanclass="o">.</span><spanclass="n">Compound</span><spanclass="p">(</span><spanclass="n">xyz</span><spanclass="o">=</span><spanclass="s2">"qm7/0001.xyz"</span><spanclass="p">)</span>
<spanclass="c1"># Generate and print a coulomb matrix for compound with 5 atoms</span>
<spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">generate_coulomb_matrix</span><spanclass="p">(</span><spanclass="n">size</span><spanclass="o">=</span><spanclass="mi">5</span><spanclass="p">,</span><spanclass="n">sorting</span><spanclass="o">=</span><spanclass="s2">"row-norm"</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">representation</span><spanclass="p">)</span>
<spanclass="c1"># Generate and print BoB bags for compound containing C and H</span>
<spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">generate_bob</span><spanclass="p">(</span><spanclass="n">asize</span><spanclass="o">=</span><spanclass="p">{</span><spanclass="s2">"C"</span><spanclass="p">:</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="s2">"H"</span><spanclass="p">:</span><spanclass="mi">5</span><spanclass="p">})</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">representation</span><spanclass="p">)</span>
</pre></div>
</div>
<p>The representations are simply stored as 1D-vectors.
Note the keyword <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> which is the largest number of atoms in a molecule occurring in test or training set.
Additionally, the coulomb matrix can take a sorting scheme as keyword, and the BoB representations requires the specifications of how many atoms of a certain type to make room for in the representations.</p>
<p>Lastly, you can print the following properties which is read from the XYZ file:</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Print other properties stored in the object</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">coordinates</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">atomtypes</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">nuclear_charges</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">name</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">unit_cell</span><spanclass="p">)</span>
</pre></div>
</div>
</div>
<divclass="section" id="exercise-2-kernels">
<h2>Exercise 2: Kernels<aclass="headerlink" href="#exercise-2-kernels" title="Permalink to this headline">¶</a></h2>
<p>In this exercise we generate a Gaussian kernel matrix, <spanclass="math notranslate nohighlight">\(\mathbf{K}\)</span>, using the representations, <spanclass="math notranslate nohighlight">\(\mathbf{X}\)</span>, which are generated similarly to the example in the previous exercise:</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(K_{ij} = \exp\left( -\frac{\| \mathbf{X}_i - \mathbf{X}_j\|_2^2}{2\sigma^2}\right)\)</span></div></blockquote>
<p>QML supplies functions to generate the most basic kernels (E.g. Gaussian, Laplacian). In the exercise below, we calculate a Gaussian kernel for the QM7 dataset.
In order to save time you can import the entire QM7 dataset as <codeclass="docutils literal notranslate"><spanclass="pre">Compound</span></code> objects from the file <codeclass="docutils literal notranslate"><spanclass="pre">tutorial_data.py</span></code> found in the tutorial GitHub repository.</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Import QM7, already parsed to QML</span>
<spanclass="kn">from</span><spanclass="nn">tutorial_data</span><spanclass="k">import</span><spanclass="n">compounds</span>
<spanclass="kn">from</span><spanclass="nn">qml.kernels</span><spanclass="k">import</span><spanclass="n">gaussian_kernel</span>
<spanclass="c1"># For every compound generate a coulomb matrix or BoB</span>
<spanclass="k">for</span><spanclass="n">mol</span><spanclass="ow">in</span><spanclass="n">compounds</span><spanclass="p">:</span>
<spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">generate_coulomb_matrix</span><spanclass="p">(</span><spanclass="n">size</span><spanclass="o">=</span><spanclass="mi">23</span><spanclass="p">,</span><spanclass="n">sorting</span><spanclass="o">=</span><spanclass="s2">"row-norm"</span><spanclass="p">)</span>
<spanclass="c1"># mol.generate_bob(size=23, asize={"O":3, "C":7, "N":3, "H":16, "S":1})</span>
<spanclass="c1"># Make a big 2D array with all the representations</span>
<spanclass="n">X</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">array</span><spanclass="p">([</span><spanclass="n">mol</span><spanclass="o">.</span><spanclass="n">representation</span><spanclass="k">for</span><spanclass="n">mol</span><spanclass="ow">in</span><spanclass="n">compounds</span><spanclass="p">])</span>
<spanclass="c1"># Print all representations</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">X</span><spanclass="p">)</span>
<spanclass="c1"># Run on only a subset of the first 100 (for speed)</span>
<spanclass="n">X</span><spanclass="o">=</span><spanclass="n">X</span><spanclass="p">[:</span><spanclass="mi">100</span><spanclass="p">]</span>
<spanclass="c1"># Define the kernel width</span>
<spanclass="n">sigma</span><spanclass="o">=</span><spanclass="mf">1000.0</span>
<spanclass="c1"># K is also a Numpy array</span>
<spanclass="n">K</span><spanclass="o">=</span><spanclass="n">gaussian_kernel</span><spanclass="p">(</span><spanclass="n">X</span><spanclass="p">,</span><spanclass="n">X</span><spanclass="p">,</span><spanclass="n">sigma</span><spanclass="p">)</span>
<spanclass="c1"># Print the kernel</span>
<spanclass="nb">print</span><spanclass="n">K</span>
</pre></div>
</div>
</div>
<divclass="section" id="exercise-3-regression">
<h2>Exercise 3: Regression<aclass="headerlink" href="#exercise-3-regression" title="Permalink to this headline">¶</a></h2>
<p>With the kernel matrix and representations sorted out in the previous two exercise, we can now solve the <spanclass="math notranslate nohighlight">\(\boldsymbol{\alpha}\)</span> regression coefficients:</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(\boldsymbol{\alpha} = (\mathbf{K} + \lambda \mathbf{I})^{-1} \mathbf{y}\label{eq:inv}\)</span></div></blockquote>
<p>One of the most efficient ways of solving this equation is using a Cholesky-decomposition.
QML includes a function named <codeclass="docutils literal notranslate"><spanclass="pre">cho_solve()</span></code> to do this via the math module <codeclass="docutils literal notranslate"><spanclass="pre">qml.math</span></code>.
In this step it is convenient to only use a subset of the full dataset as training data (see below).
The following builds on the code from the previous step.
To save time, you can import the PBE0/def2-TZVP atomization energies for the QM7 dataset from the file <codeclass="docutils literal notranslate"><spanclass="pre">tutorial_data.py</span></code>.
This has been sorted to match the ordering of the representations generated in the previous exercise.
Extend your code from the previous step with the code below:</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="kn">from</span><spanclass="nn">qml.math</span><spanclass="k">import</span><spanclass="n">cho_solve</span>
<spanclass="kn">from</span><spanclass="nn">tutorial_data</span><spanclass="k">import</span><spanclass="n">energy_pbe0</span>
<spanclass="c1"># Assign 1000 first molecules to the training set</span>
<spanclass="n">X_training</span><spanclass="o">=</span><spanclass="n">X</span><spanclass="p">[:</span><spanclass="mi">1000</span><spanclass="p">]</span>
<spanclass="n">Y_training</span><spanclass="o">=</span><spanclass="n">energy_pbe0</span><spanclass="p">[:</span><spanclass="mi">1000</span><spanclass="p">]</span>
<spanclass="n">sigma</span><spanclass="o">=</span><spanclass="mf">4000.0</span>
<spanclass="n">K</span><spanclass="o">=</span><spanclass="n">gaussian_kernel</span><spanclass="p">(</span><spanclass="n">X_training</span><spanclass="p">,</span><spanclass="n">X_training</span><spanclass="p">,</span><spanclass="n">sigma</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">K</span><spanclass="p">)</span>
<spanclass="c1"># Add a small lambda to the diagonal of the kernel matrix</span>
<spanclass="n">K</span><spanclass="p">[</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">diag_indices_from</span><spanclass="p">(</span><spanclass="n">K</span><spanclass="p">)]</span><spanclass="o">+=</span><spanclass="mf">1e-8</span>
<spanclass="c1"># Use the built-in Cholesky-decomposition to solve</span>
<spanclass="n">alpha</span><spanclass="o">=</span><spanclass="n">cho_solve</span><spanclass="p">(</span><spanclass="n">K</span><spanclass="p">,</span><spanclass="n">Y_training</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="n">alpha</span><spanclass="p">)</span>
</pre></div>
</div>
</div>
<divclass="section" id="exercise-4-prediction">
<h2>Exercise 4: Prediction<aclass="headerlink" href="#exercise-4-prediction" title="Permalink to this headline">¶</a></h2>
<p>With the <spanclass="math notranslate nohighlight">\(\boldsymbol{\alpha}\)</span> regression coefficients from the previous step, we have (successfully) trained the machine, and we are now ready to do predictions for other compounds.
This is done using the following equation:</p>
<blockquote>
<div><spanclass="math notranslate nohighlight">\(y\left(\widetilde{\mathbf{X}} \right) = \sum_i \alpha_i \ K\left( \widetilde{\mathbf{X}}, \mathbf{X}_i\right)\)</span></div></blockquote>
<p>In this step we further divide the dataset into a training and a test set. Try using the last 1000 entries as test set.</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Assign 1000 last molecules to the test set</span>
<spanclass="n">X_test</span><spanclass="o">=</span><spanclass="n">X</span><spanclass="p">[</span><spanclass="o">-</span><spanclass="mi">1000</span><spanclass="p">:]</span>
<spanclass="n">Y_test</span><spanclass="o">=</span><spanclass="n">energy_pbe0</span><spanclass="p">[</span><spanclass="o">-</span><spanclass="mi">1000</span><spanclass="p">:]</span>
<spanclass="c1"># calculate a kernel matrix between test and training data, using the same sigma</span>
<spanclass="n">Ks</span><spanclass="o">=</span><spanclass="n">gaussian_kernel</span><spanclass="p">(</span><spanclass="n">X_test</span><spanclass="p">,</span><spanclass="n">X_training</span><spanclass="p">,</span><spanclass="n">sigma</span><spanclass="p">)</span>
<spanclass="c1"># Make the predictions</span>
<spanclass="n">Y_predicted</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">dot</span><spanclass="p">(</span><spanclass="n">Ks</span><spanclass="p">,</span><spanclass="n">alpha</span><spanclass="p">)</span>
<spanclass="c1"># Calculate mean-absolute-error (MAE):</span>
<spanclass="nb">print</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">mean</span><spanclass="p">(</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">abs</span><spanclass="p">(</span><spanclass="n">Y_predicted</span><spanclass="o">-</span><spanclass="n">Y_test</span><spanclass="p">))</span>
</pre></div>
</div>
</div>
<divclass="section" id="exercise-5-learning-curves">
<h2>Exercise 5: Learning curves<aclass="headerlink" href="#exercise-5-learning-curves" title="Permalink to this headline">¶</a></h2>
<p>Repeat the prediction from Exercise 2.4 with training set sizes of 1000, 2000, and 4000 molecules.
Note the MAE for every training size.
Plot a learning curve of the MAE versus the training set size.
Generate a learning curve for the Gaussian and Laplacian kernels, as well using the coulomb matrix and bag-of-bonds representations.
Which combination gives the best learning curve? Note you will have to adjust the kernel width (sigma) underway.</p>
</div>
<divclass="section" id="exercise-6-delta-learning">
<h2>Exercise 6: Delta learning<aclass="headerlink" href="#exercise-6-delta-learning" title="Permalink to this headline">¶</a></h2>
<p>A powerful technique in machine learning is the delta learning approach. Instead of predicting the PBE0/def2-TZVP atomization energies, we shall try to predict the difference between DFTB3 (a semi-empirical quantum method) and PBE0 atomization energies.
Instead of importing the <codeclass="docutils literal notranslate"><spanclass="pre">energy_pbe0</span></code> data, you can import the <codeclass="docutils literal notranslate"><spanclass="pre">energy_delta</span></code> and use this instead</p>
<divclass="code python highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="kn">from</span><spanclass="nn">tutorial_data</span><spanclass="k">import</span><spanclass="n">energy_delta</span>
<spanclass="n">Y_training</span><spanclass="o">=</span><spanclass="n">energy_delta</span><spanclass="p">[:</span><spanclass="mi">1000</span><spanclass="p">]</span>
<spanclass="n">Y_test</span><spanclass="o">=</span><spanclass="n">energy_delta</span><spanclass="p">[</span><spanclass="o">-</span><spanclass="mi">1000</span><spanclass="p">:]</span>
</pre></div>
</div>
<p>Finally re-draw one of the learning curves from the previous exercise, and note how the prediction improves.</p>
</div>
<divclass="section" id="references">
<h2>References<aclass="headerlink" href="#references" title="Permalink to this headline">¶</a></h2>
<tableclass="docutils footnote" frame="void" id="rupp" rules="none">
<colgroup><colclass="label" /><col/></colgroup>
<tbodyvalign="top">
<tr><tdclass="label"><aclass="fn-backref" href="#id1">[1]</a></td><td>Rupp et al, Phys Rev Letters, 2012.</td></tr>
</tbody>
</table>
<tableclass="docutils footnote" frame="void" id="ruddigkeit" rules="none">
<colgroup><colclass="label" /><col/></colgroup>
<tbodyvalign="top">
<tr><tdclass="label"><aclass="fn-backref" href="#id2">[2]</a></td><td>Ruddigkeit et al, J Chem Inf Model, 2012.</td></tr>
</tbody>
</table>
<tableclass="docutils footnote" frame="void" id="montavon" rules="none">
<colgroup><colclass="label" /><col/></colgroup>
<tbodyvalign="top">
<tr><tdclass="label"><aclass="fn-backref" href="#id3">[3]</a></td><td>Montavon et al, New J Phys, 2013.</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<footer>
<divclass="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<ahref="examples.html" class="btn btn-neutral float-right" title="Examples" accesskey="n" rel="next">Next <spanclass="fa fa-arrow-circle-right"></span></a>
<ahref="citation.html" class="btn btn-neutral" title="Citing use of QML" accesskey="p" rel="prev"><spanclass="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<divrole="contentinfo">
<p>
© Copyright 2017, Anders S. Christensen.
</p>
</div>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<scripttype="text/javascript">
varDOCUMENTATION_OPTIONS={
URL_ROOT:'./',
VERSION:'0.4.0',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<scripttype="text/javascript" src="_static/jquery.js"></script>
<scripttype="text/javascript" src="_static/underscore.js"></script>
<scripttype="text/javascript" src="_static/doctools.js"></script>
<scripttype="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<scripttype="text/javascript" src="_static/js/theme.js"></script>
<scripttype="text/javascript">
jQuery(function(){
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>