hands-on-tutorial.bkr 235 KB
Newer Older
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
{
    "beaker": "2",
    "evaluators": [
        {
            "name": "HTML",
            "plugin": "HTML",
            "view": {
                "cm": {
                    "mode": "htmlmixed"
                }
            }
        },
        {
            "name": "JavaScript",
            "plugin": "JavaScript",
            "view": {
                "cm": {
                    "mode": "javascript",
                    "background": "#FFE0F0"
                }
            },
            "languageVersion": "ES2015"
        },
        {
            "name": "IPython",
            "plugin": "IPython",
            "setup": "%matplotlib inline\nimport numpy\nimport matplotlib\nfrom matplotlib import pylab, mlab, pyplot\nnp = numpy\nplt = pyplot\nfrom IPython.display import display\nfrom IPython.core.pylabtools import figsize, getfigs\nfrom pylab import *\nfrom numpy import *\n",
            "view": {
                "cm": {
                    "mode": "python"
                }
            }
        },
        {
            "name": "TeX",
            "plugin": "TeX",
            "view": {
                "cm": {
                    "mode": "stex"
                }
            }
        }
    ],
    "cells": [
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
            "id": "markdowndtwMRP",
            "type": "markdown",
            "body": [
                "<style type=\"text/css\">",
                "/*!",
                " * Nomad Beaker Notebook Template",
                " *",
                " * @copyright  Copyright 2017 Fritz Haber Institute of the Max Planck Society,",
                " *             Benjamin Regler - Apache 2.0 License",
                " * @license    http://www.apache.org/licenses/LICENSE-2.0",
                " * @author     Benjamin Regler",
                " * @version    1.0.0",
                " *",
                " * Licensed under the Apache License, Version 2.0 (the \"License\");",
                " * you may not use this file except in compliance with the License.",
                " * You may obtain a copy of the License at",
                " * ",
                " *     http://www.apache.org/licenses/LICENSE-2.0",
                " *",
                " * Unless required by applicable law or agreed to in writing, software",
                " * distributed under the License is distributed on an \"AS IS\" BASIS,",
                " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
                " * See the License for the specific language governing permissions and",
                " * limitations under the License.",
                " */",
                "p{margin-bottom:1.3em}h1,h2,h3,h4{margin:1.414em 0 .5em;font-weight:inherit;line-height:1.2}h1{margin-top:0;font-size:3.998em}h2{font-size:2.827em}h3{font-size:1.999em}h4{font-size:1.414em}.font_small,small{font-size:.707em}notebook-container{font-size:16px}.nomad--header h2{color:#20335d;font-weight:700;margin:0 0 .2em}.nomad--header h3{color:#20335d;font-weight:700;margin-top:0;text-indent:-1em;padding-left:1em}.nomad--header h3:before{content:\"\\2014\";padding-right:.25em}.nomad--header .nomad--description{margin:-1em 0 0 2em}.atomic-data--block,.nomad--last-updated{display:inline-block;margin-top:1em}.nomad--last-updated{color:grey;float:right;position:relative;z-index:1}.nomad--last-updated::before{bottom:-75%;content:attr(data-version);font-size:4em;font-weight:700;opacity:.2;position:absolute;right:0}.atomic-data label{display:block;font-size:medium;font-weight:700}.atomic-data--select,.chosen-container{width:100%!important}.atomic-data--select:disabled{color:#d3d3d3}.atomic-data--reset-buton{display:inline-block;margin-top:1.6em;width:100%}.modal-dialog{max-width:1000px;width:80%}.modal-header h1{font-size:2em;line-height:1.2}.modal-dialog h2{font-size:1.414em}.modal-dialog h2:first-child{margin-top:0}.modal-dialog h3{font-size:1.2em}.modal-dialog dt{font-size:larger;margin-top:1.414em}.modal-dialog img{width:100%}.modal-dialog .authors{text-transform:uppercase}",
                "summary{list-style:disc; margin: 2px;padding: 10px;border: 0px;border:8px double   green; font-size:16px;padding-left: 32px;padding-right: 22px; width:89%}",
                "</style>",
                "",
                "<div id=\"teaser\" style='background-color: rgba(149,170,79, 1.0); background-position:  right center; background-size: 200px; background-repeat: no-repeat; ",
                "    padding-top: 20px;",
                "    padding-right: 10px;",
                "    padding-bottom: 50px;",
                "    padding-left: 80px;' > ",
                "",
                "  <div class=\"nomad--header\">",
                "   <div style=\"text-align:center\">",
                "    <h2> <img id=\"nomad\" src=\"https://nomad-coe.eu/uploads/nomad/images/NOMAD_Logo2.png\" height=\"100\" alt=\"NOMAD Logo\">  NOMAD Analytics Toolkit  <img id=\"nomad\" src=\"https://www.nomad-coe.eu/uploads/nomad/backgrounds/head_big-data_analytics_2.png\" height=\"80\" alt=\"NOMAD Logo\"> </h2>",
                "  </div>",
                "    <h3>Hands-on Workshop Density-Functional Theory and Beyond:<br> Compressed sensing for identifying descriptors ",
                "    </h3>",
                "    <p class=\"nomad--description\">",
                "      created by:",
                " Emre Ahmetcik<sup>1</sup>, ",
                " Angelo Ziletti<sup> 1</sup>,",
                " Runhai Ouyang<sup>1</sup>,",
                " Luca Ghiringhelli<sup>1</sup>,",
                " and Matthias Scheffler<sup>1</sup> <br><br>",
                "   ",
                "      <sup>1</sup> Fritz Haber Institute of the Max Planck Society, Faradayweg 4-6, D-14195 Berlin, Germany <br>",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
96
                "      <span class=\"nomad--last-updated\" data-version=\"v1.0.0\">[Last updated: August 8, 2018]</span>",
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
                "    </p>",
                "</div>",
                "</div>",
                "",
                "<div style='text-align: right;'>",
                "<a href=\"https://analytics-toolkit.nomad-coe.eu/home/\" class=\"btn btn-primary\" style=\"font-size:larger;\">Back to Analytics Home</a> ",
                "<a href=\"https://www.nomad-coe.eu/\" class=\"btn btn-primary\" style=\"font-size:larger;\">Back to NOMAD CoE Home</a> ",
                "</div>  ",
                "",
                "",
                "",
                "<br><br><br>",
                "This tutorial shows how to find descriptive parameters (short formulas) to predict materials properties using compressed sensing tools. As an example we adress the prediction of the crystal structure stability of 82 octet binary compounds. We provide scripts which access the relevant data from the NOMAD Archive and determine descriptors for both regression models (predicting the rocksalt (RS) vs zincblende (ZB) structure energy difference) and classification (a compound is predicted to be most stable in either RS, ZB, CsCl, NiAs or CrB structure) .",
                "",
                "The idea of using compressed sensing tools: Starting from simple physical quantities (\"building blocks\", here properties of the constituent free atoms such as orbital radii), millions (or billions) of candidate formulas are generated by applying arithmetic operations combining building blocks, for example forming sums and products of them. These candidate formulas constitute the so-called \"feature space\". Then a feature selection method is used to select only a few of these formulas that explain the data. In this tutorial we use the methods LASSO+$\\ell_0$ as introduced in ",
                "<div style=\"padding: 1ex; margin-top: 1ex; margin-bottom: 1ex; border-style: dotted; border-width: 1pt; border-color: blue; border-radius: 3px;\">",
                "L. M. Ghiringhelli, J. Vybiral, S. V. Levchenko, C. Draxl, M. Scheffler: <span style=\"font-style: italic;\">Big Data of Materials Science: Critical Role of the Descriptor</span>,  Phys. Rev. Lett. 114, 105503 (2015) <a href=\"http://journals.aps.org/prl/abstract/10.1103/PhysRevLett.114.105503\" target=\"_blank\">[PDF]</a></div>",
                " and Sure Independence Screening Sparse Operator  (SISSO) as proposed in",
                "<div style=\"padding: 1ex; margin-top: 1ex; margin-bottom: 1ex; border-style: dotted; border-width: 1pt; border-color: blue; border-radius: 3px;\">",
116
                "R. Ouyang, S. Curtarolo, E. Ahmetcik, M. Scheffler, L. M. Ghiringhelli: <span style=\"font-style: italic;\">SISSO: a compressed-sensing method for identifying the best low-dimensional descriptor in an immensity of offered candidates</span>, Phys. Rev. Materials  2, 083802 (2018) <a href=\"https://journals.aps.org/prmaterials/abstract/10.1103/PhysRevMaterials.2.083802\" target=\"_blank\">[PDF]</a> .",
117 118 119 120
                "</div>",
                ""
            ],
            "evaluatorReader": false
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
            "id": "sectionFrtJgy",
            "type": "section",
            "title": "Introduction to the compressed sensing methods",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdownVA6agA",
            "type": "markdown",
            "body": [
                "The feature space is generated by creating a list of analytical expressions (the derived features), obtained by combining the primary features and arithmetic operations. We put all $m$ derived features into a descriptor matrix $\\mathbf{D} \\in \\mathbb{R}^{82 \\times m}$ where each column stands for a derived feature and each row for a compound. An $\\ell_0$-regularization ",
                "",
                "$\\text{argmin}_{\\mathbf{c} \\in \\mathbb{R}^{m}} \\{\\|\\mathbf{P} - \\mathbf{D}\\mathbf{c}\\|^2_2 +\\lambda \\|\\mathbf{c}\\|_0\\}$",
                "",
                "determines those few feature columns which approximate a property vector $\\mathbf{P} \\in \\mathbb{R}^{82}$ (i.e RS vs. ZB energy differences) best. The subscript 0 stays for the $\\ell_0$-quasinorm, that counts the number of non-zero elements of $\\mathbf{c}$ and $\\lambda > 0$ is called the regularization parameter. Performing the $\\ell_0$-regularization becomes fast computational infeasable and often approximations (i.e. LASSO, LASSO+L0, SIS+L0) are needed since in practice the $\\ell_0$-regularization needs to be solved combinatorial: All singletons, pairs, triplets, ... $n$-tuples (up to the selected maximum dimension of the descriptor) are listed and for each set a least-square regression is performed. The $n$-tuple that gives the lowest mean square error for the least-square regression fit is selected as the resulting $n$-dimensional descriptor."
            ],
            "evaluatorReader": false
        },
        {
            "id": "sectionS8rXSG",
            "type": "section",
            "title": "The LASSO+$\\ell_0$ method",
            "level": 2,
            "evaluatorReader": false,
            "collapsed": false
        },
        {
            "id": "markdown28rftM",
            "type": "markdown",
            "body": [
                " LASSO+$\\ell_0$  combines the Least Absolute Shrinkage and Selection Operator (LASSO)  and the $\\ell_0$-regularization. In the first step the LASSO minimization",
                "",
                "$\\text{argmin}_{\\mathbf{c} \\in \\mathbb{R}^{m}} \\{\\|\\mathbf{P} - \\mathbf{D}\\mathbf{c}\\|^2_2 +\\lambda \\|\\mathbf{c}\\|_1\\}$",
                "",
                "is performed repetitively by decreasing $\\lambda$ in small steps starting from the largest value that gives one non-zero element in $\\mathbf{c}$,  until a desired number of features (i.e. 30) that have non-zero coefficient in $\\mathbf{c}$ are collected/saved.  Using these collected features  the $\\ell_0$-regularization is performed subsequently.",
                ""
            ],
            "evaluatorReader": false
        },
        {
            "id": "sectionbYEx1l",
            "type": "section",
            "title": "The SISSO for regression",
            "level": 2,
            "evaluatorReader": false,
            "collapsed": false
        },
        {
            "id": "markdownyyqzw4",
            "type": "markdown",
            "body": [
                "SISSO works iteratively. In the first iteration, a number $k$ of features is collected that have the largest correlation (scalar product) with $\\mathbf{P}$. The feature with the largest correlation is simply the 1D descriptor. Next, a residual is constructed as the error made at the first iteration. A new set of $k$ features is now selected as those having the largest correlation with the residual. The 2D descriptor is the pair of features that yield the smallest fitting error upon least-square regression, among all possible pairs contained in the union of the sets selected in this and the first iteration. In each next iteration a new residual is constructed as the error made in the previous iteration, then a new set of $k$ features is extracted as those that have largest correlation with each new residual. The $n$D descriptor is the $n$-tuple of features that yield the smallest fitting error upon least square regression, among all possible $n$-tuples contained in the union of the sets obtained in each new iteration and all the previous iterations. If $k=1$ the method collapses to the so-called orthogonal matching pursuit."
            ],
            "evaluatorReader": false
        },
        {
            "id": "sectionH1x7Pk",
            "type": "section",
            "title": "The SISSO for classification",
            "level": 2,
            "evaluatorReader": false,
            "collapsed": false
        },
        {
            "id": "markdownNO8Ito",
            "type": "markdown",
            "body": [
                "For classification (categorial target),  the SISSO is applied with a different loss function. Given the convex hull of each target class, now,  the number of data points located in overlapping convex hull regions is minimized. "
            ],
            "evaluatorReader": false
        },
        {
            "id": "sectionB3Bqbw",
            "type": "section",
            "title": "Get the data from the NOMAD Archive",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdownOfpScv",
            "type": "markdown",
            "body": [
                "<summary>",
                "<li>See that the data from the repository can be accessed easily with simple python scripts.</li>",
                "<li>Consider the specific case of 82 octet binary compounds in the RS and ZB structure. Process the data to build the target property $\\mathbf{P} \\in \\mathbb{R}^{82}$ of RS vs ZB energy differences.</li>",
                "<li>Construct the descriptor matrix $\\mathbf{D} \\in \\mathbb{R}^{82 \\times m}$ using primary features from the NOMAD atomic data collection.</li>",
                "</summary>"
            ],
            "evaluatorReader": false
214 215 216 217 218
        },
        {
            "id": "markdownocHinB",
            "type": "markdown",
            "body": [
219
                "In the following cell we declare the paths to the JSON files of the DFT calculations. The list provides 2 x 82 paths of single point calculations at (close to) the equilibrium of the RS and ZB crystal symmetry."
220 221 222
            ],
            "evaluatorReader": false
        },
223 224 225 226 227 228
        {
            "id": "codeOi5KIx",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
229
                    "json_list = [ ",
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
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PudDm0on_-EHhn0SHX20l2vdbSQ1x.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pp4wUDDucIEdS9euDT89Y6xQA_JPq.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pd5Tx2nPg7dFY-jys9XwKne6OQtKX.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PyukHM_doowQLr1Ipwa8feMxPVmI2.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PHiW0XWZCN8j4FL20b8tZzv7Vz59s.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PnhDURE4i9Q5yUaSUbEmarpPFd-oP.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Phw2RDlr8RJrjY8nb2PfCE6Bf--N0.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PxJnNtspUIcqGhneVuSJKposdVxH_.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pl7aTuAjyxpsJM7vLAOVHYwJm-QE6.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PvkvzEExTn8uE2HYyp39OAr0XeTVs.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P5q6OPnbkCI9OZnxRMmigkwjECTEe.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pq_S1pMWXyVEwLQtS_CRQLruINQc7.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PN0Q_OXA7e5yO6EkDKkOpGHM6hyCj.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P49a5P12dU5LYRyFCHIIWWy_T06lE.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Ph7OdXYR4ndMpTcR0zX4mqRoBZpP9.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PAlWHa4oJtvotPEJZkbrlNC_sn0h2.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P-R6dmrIaT8iFyy2ObACxIHGWnNOy.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PKhAdygZBTTTF8uvQjKv1RdaX-cR-.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PKu0vasdF5E6n3C3QydIjCtGOIla4.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PZpgpSkSltbUhJUCSbPqBKkIvQi8v.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PctpEiY3VdEmVYwH7UjqZpiDWZtpM.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PItWNNwGWlKJ12UjZAOfNetX3xlkd.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PrTcNbJ50u8bqAFWGjPJKqnuuEvY7.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PfFPGDGw6-cK5ARIXtsKl496E6A0G.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PeXgyF2iElVtNWSX9xZhroKK8nJJ4.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P7kHL_6prXXdx5_MzMVmwsmStNoc0.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PaMvDXJtsbfDgbdvrFdiFSKpXNYyC.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P9sheCSX6Gol5L-IsCvDlnmT_MEGG.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PSy2hA53Gi7wXfU9SCowqkmFWD2gp.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P51AKUeSNYXrRBK_-uc8y1-bCfUNg.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PaqU_UGMSvVN6niB3zqMYchjsLHRX.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PcyDh6nCotXyohIHh5k1dx5L5D5X9.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PudM2fYFckG7O5R4BJqg04tK_l1bd.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P9Yuhn2S6hqpJ0cf9E9uw5G5bJlzV.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PqmzGiDuYJ-Q8j-KfLDlQBvWb2Gjt.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PCeh79N53GyBSPmZQQJ97G0eAHaDT.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PfgDGZGQLelhbTh9ZtsKqWGFxvhJ9.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PB0yzgD_PWA0LKTKGJ8ZZuD33YEUG.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PAy8gmVjhXEQxzCJ8LOWZakyvudO8.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PxHkLq1KNzXy50hbEPelPan0cCrsH.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PWkXOKoiw0iAE585QkElUZNCYOqYI.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PgemHvDiNrY7gsuhCx0VTL8kPb7AM.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PlIiyctCzbm5lbDOxpwEi3GbORHRD.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PGRvHpDj8bRbzvIL0c9yfOmeZjfah.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PHG50HtPjrXvkxeCITsjzFtq9N4hK.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PZuBrsUzsdX__rAeKn_JQgfX-YGoo.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PshguFKUbvULqOUN80QC-M3xQvrmJ.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PXoBZDFv4BhXvWTO29YBcGBXXu1vS.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PsmYUa8-6qr40jG7XJhUIynL1Ue8b.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P-M1B6jU_t-kPPKkoFU9kZkEbx332.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pq1Tvh6kPeJ-PO77jXvOsp92PMK4P.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PfA960McVCueQzY_t-TVT0wgbZCC5.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P-eZyP4BB8uo0pdmQIIrat2mhXQBN.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PmenrFglDQWoTWLNvVVobyI3dmkIe.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PoEQrdbxDvcCldS5_cpSOcAS57svB.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PQUYoBu1tULTvysw2jz8XwBnIeewS.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PYOw5h3ttt0tMyUPOvqDPc6yArPTy.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pzl8jOEFAC45VXxnxMJ7_nf2xS6v2.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PmkSmszyXIzY3yIzTUnkvOCwqNFFg.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P7JW4GQVa_xQ4YKM88F9LFzyVoXke.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PsL8fyWYvrq6V0pE3zTfoNsWAVUd1.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PbVMALFnpGdoEyabKhI_3DtbUX6W7.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PME2sPwrfVW7U0veuObWai6ryPqou.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PSzD2TkeF0Gg9fnlc1cNvyK7NL24E.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PQB49fu8BN3kua7uLKQLlT5dWdHi0.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PzkPWSKWCQ14F1io7eGkOhK7h0O_Q.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P_18Q5thpEagvBD-4tUdeTopJwCTV.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PKmJzuNjx3TVhnGoqyqoWSnwEgjGm.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P7oSkZrV7zs3KG6S8IZyTSE_FmwBQ.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PIwvZmuUIIrtn2HcPLoozMo73I4uz.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P-70iigSqFlM9BO7d8xReToc2yoJL.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PS3i4SxrlnWE9AUgOmy00D3f5dMgE.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PKSpxMXqdSstTt6Es26kroYBYENnq.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P_DFu-YobOdcOb1mfdI22vrtaSQAh.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PZQkSWOat-bIQV5IVle0tBtpUg_u-.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Po4TFqVuLhanZRORPTA7dDA2sdbrg.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PvVLlR_Pq2Ibks3hWK2HOSJ1GgVRY.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PmmsPJ6ouZjFnoIdGfis_3AHs9clP.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PQESlzgesuFywpq09x-vZ0gikcjPf.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PKfJHS4WQGppgde2dACUjMuVoL2sB.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PcEzW227FYLGI2t3jk-gLCgcEZWZe.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P36pL30yblwhze_vHZYZ_cybqeH4V.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PjGykEyzLOFynTPTNDcycF0GYg1PE.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PRzzJL7OHYeejsIvgfG1ph6BAeS_q.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PNavIaZhgwAeZM0-QhWHe_38iUgEF.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PpxTrTc6NkExiq1nzQkhd3cJ1-yRY.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PVYIDqiD6OslrGDcpUvuqvc0bD8Jr.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PiZTl1-v3bdCUDjxt-w2VxKMGW3-6.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PomJQS9nQ4WsUIr718n6H4YbM0Fi7.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PEC0GOHh7MviqeJkG1qukjk4bALIS.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PNXyczNslCGZT642R9ZFYGvidFvua.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PpyJZtNPyNqX3ofwfNMpvJU_9PEKI.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PA3s37bS9VLUzI5wYL_ntZ6RIM6IJ.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PvEU0OOwFN7eFqiwt9m9S_SmhCJUm.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PsJUIeSLEotoIZk6R54H-G2JWPnQG.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PUT_umVDXGUamLH1R7nkazwKz95dz.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P_rlThO8Jv0C2YIgYKLbCTM1rvfW-.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PyizrsR40QyxopYKKk2jUtl7nElXJ.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PQhb3_h4Bo9e5xjhhTUBY_8uOEtTM.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P0tj3NYHfrit7NB0ewfG-fIjRWuJD.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PlrW3wNN03bq-G8TLkXHpALwSTUUg.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P3hSpXydSB6z3p79OEIOQK6llto1K.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pa7ltCNBQsk7Owlu0bJnsE8iY-Rmw.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PYeYlDJb7j4qJ9ol38GSM_eYJsiSe.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PX39jEfgLeDPddrkPuTvUfVv4_thl.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PWNXU92VwL7KkuoxItglRiuifcOnk.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PoWlbXJuGJ4-22DclM15L_g44LN3P.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PEYkIqgUpWfoq4Tcsy8_bFVUs9mko.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pst86UVhV07OfKDhwlp0PNxiMtXki.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PVc9Pn-w-6MEpu41jV4p_keLeM-Yy.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P81vIYtJtOEx4n865B86z-KvUb6hA.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P8BMwwn-g_0Xezs6oK3ay6ZRXIRR-.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P8nQ1bSGP4pyRMOa4i5Uhjpb1Mord.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PCmzvvjhPSzkp_bhkAuDWK375Fs9g.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PhaEAJ72mzGm65KpjGcnVVlFax_l7.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PvXy3VrpadhZLQAwphJE6GVB_0OUp.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P3486jK16L4wlXG0B4v1-csMQ6oJ3.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/POL8lsjGueHjkLb9hMpptti6c8Phg.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PULp85M-UCJ52e4UaGcyeLDmUeq2Z.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pr6E85ezTMa4WX-GTFoms6w0Rb0hT.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P0e8gRRxOvcJquPDa7SeYFk2OCiFS.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Px8VpfH0LzX99ht06ME-0EsmmrSqe.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PM3KjHYJjTA26va4uYXD8homH7pUm.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P6GMfPCT_Fa40hXkVKpqnygEBt4PG.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pu9uI6ldU3ZVgwfmy-Um0D7IBxTCK.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PN0ekL4w0k3A5OXacRBScDJ9KlGMf.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P39GmzBY478BzuXrZM-0i2Z-njyb9.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PEhAEeu8aSPA_d3_dHCjTlAi1y09j.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PVshjrYqjAg_8QtgfGW2ABnR-mlIP.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PDjDFM8OWbY0TtHCY-DBYRJmRQ8fO.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PxkyksXrwYuxnJ_wD7qN890rycd67.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PUDiBRLe2pg5Hjvd3kc_20wMbinMI.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PpikjM2BVj1atNlsbkcJzK9TkUIox.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PcYC-NeMnx_goUeYg8PmaNVo0chDc.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PQFhJGR6USZg0MrTttQvXm1IiHIdq.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PGvuYKpzVCcWnf33I4uy8fGyJVxXq.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PV--hzM8rvSS8a6LZBuuW6IPbqvY6.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PHQ9WIyu3N7whYM_ykFZunv5to3l2.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P2_H4gO4T7T7jknE474jzrc1Y4Tjm.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PFs1SxWG79Zqj0jssdOIqUicZk9aH.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PiOIHShEKCjdganj-Sd0MkJaLglGr.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pn-jKNaG1IM7sKsxBh-ekfl3M3hIa.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P_80H6vlBefw1U3rKFDPPtpJAX1GH.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PdHoVKHCES7XtBpTVk0eihbo0kqmR.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PAzsSjYMU1-CdGulNpG_KzgFlfRrK.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PVlh5JoGn6jHWlE96SKt6eRMYTIVK.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PHfNgOoPEHjzs9iOh900vIUv-GVJl.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PVTUPQyCTvrAWV0DEN_xnPgrBPmM2.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pws96oc5f7jIltD9Vvqc3svzL4mcW.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PLJBz0uY-AywnUhGMCXMounM-_Af3.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Pkole11VWAOiu91qHeq6lOzIM2Y1Y.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P2R4Ds9DFm8USF_AgHtQnWK1TkQiR.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PxrF4NRKjX9jsmVIocs7uQuLwD_cS.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PMxYGoRCMDXQWrNytWJHc-vUgRKTT.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PK3-3e-av7nkv5AOEwjZyyjkI9Hgy.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PC8N-y0PPPHeAwhkYGyYYI9H1UUHy.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PqWPF7Pn3u9LPGyrxipPfrpfm31zz.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PM_ADyGOaL4e2biSXvxQWrEDM78Z3.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PfGXdJkORwLQ-aX-d9bla7obqtnkt.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PmILc9BsSYjJ9OKH4MkPr0D4LGYGC.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/Py-J0ezaQ_Fdsh_196hT-XgsYNQAs.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/PUJUPZHk2jrE1KVUS7H13mKBH4oVR.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/POIYfYCEIron9yzowfHWhVea-VEFW.json',",
                    "'/parsed/prod-032/FhiAimsParser2.0.0-17-g1384da3/RWApItBGtGUDsfMVlHKqrjUQ4rShT/P_1mfRE8eDZ7zCLQwGT_3n8YC34dE.json'",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
394 395
                    "]",
                    "print \"Done\""
396
                ]
397 398 399
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
400
                "selectedType": "Results",
401
                "pluginName": "IPython",
402
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
403
                "height": 0
404 405
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
406
            "lineCount": 167,
407 408
            "tags": "json_list"
        },
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
        {
            "id": "codeGWRW4M",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "import warnings",
                    "warnings.filterwarnings('ignore')",
                    "import h5py"
                ]
            },
            "output": {
                "state": {},
                "pluginName": "IPython",
                "shellId": "62CC99770FAB493895350F18A7AE127A",
                "elapsedTime": 5793
            },
            "evaluatorReader": true,
            "lineCount": 3,
            "initialization": true
        },
430 431 432 433
        {
            "id": "markdownjLPoKc",
            "type": "markdown",
            "body": [
434
                "Now, import and use the class 'NOMADStructure'  to get the chemical formula, the total energy and the space group from each json file. You can type 'help(NOMADStructure)' to find out, what else can be extracted from a structure."
435 436 437 438 439 440 441 442 443 444
            ],
            "evaluatorReader": false
        },
        {
            "id": "code7GfA9p",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "from nomad_sim.nomad_structures import NOMADStructure",
445
                    "",
446
                    "# save the structures in a list",
447
                    "nomad_structure_list = [NOMADStructure(in_file=json_path, file_format='NOMAD', take_first='False') for json_path in json_list]",
448
                    "",
449 450 451 452 453 454 455
                    "# Consider first element of nomad_structure_list as an example",
                    "first_structure = nomad_structure_list[0]",
                    "print first_structure.chemical_symbols[0,0]",
                    "print first_structure.chemical_formula[0,0]",
                    "print first_structure.spacegroup_analyzer[0,0].get_space_group_number() ",
                    "print first_structure.energy_total__eV[0,0] # energy per unit cell",
                    "print first_structure.energy_total__eV[0,0]/ len(first_structure.atoms[0,0]) # energy per atom"
456 457 458 459 460 461
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
462
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
463
                "height": 0
464 465
            },
            "evaluatorReader": true,
466
            "lineCount": 12,
467 468
            "tags": "nomad_structure_list"
        },
469 470 471 472 473 474 475 476
        {
            "id": "markdownI6KjT2",
            "type": "markdown",
            "body": [
                "Find the function 'get_energies'  in the following cell which returns a data frame of  2 x 82 rows containing the chemical formula, the total energy per atom in eV, the space group and the json path."
            ],
            "evaluatorReader": false
        },
477 478 479 480 481 482 483
        {
            "id": "codeE3BU1L",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "import pandas as pd",
484
                    "",
485 486 487 488 489 490 491
                    "def get_energies(nomad_structure_list):",
                    "    chemical_formula_list = [nomad_structure.chemical_formula[0,0] for nomad_structure in nomad_structure_list]",
                    "    energy_list = [nomad_structure.energy_total__eV[0,0] / len(nomad_structure.atoms[0,0]) for nomad_structure in nomad_structure_list ]",
                    "    space_group_list = [nomad_structure.spacegroup_analyzer[0,0].get_space_group_number() for nomad_structure in nomad_structure_list]",
                    "    ",
                    "    data = zip(chemical_formula_list, energy_list, space_group_list, json_list)",
                    "    df_out = pd.DataFrame(data, columns=['chemical_formula', 'energy', 'space_group', 'json_path'])",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
492 493
                    "    return df_out",
                    "print \"Done\""
494 495 496 497
                ]
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
498
                "selectedType": "Results",
499
                "pluginName": "IPython",
500
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
501
                "height": 0
502 503
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
504
            "lineCount": 11,
505 506
            "tags": "get_energies"
        },
507 508 509 510 511 512 513 514
        {
            "id": "markdownbEHiV5",
            "type": "markdown",
            "body": [
                "Call 'get_energies' and print the data frame sorted by the chemical formula."
            ],
            "evaluatorReader": false
        },
515 516 517 518 519 520
        {
            "id": "codeheXP3D",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
521
                    "# set pandas option to display whole data frame",
522 523
                    "pd.set_option('display.max_rows', 200)",
                    "pd.set_option('display.expand_frame_repr', False)",
524 525 526
                    "",
                    "df_energies = get_energies(nomad_structure_list)",
                    "print df_energies.sort_values('chemical_formula')"
527 528 529 530 531 532
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
533
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
534
                "height": 0
535 536 537 538 539 540 541 542
            },
            "evaluatorReader": true,
            "lineCount": 6
        },
        {
            "id": "markdownnT2K2b",
            "type": "markdown",
            "body": [
543
                "In the following cell, a function to construct the property vector $\\mathbf{P}$ of RS vs ZB energy differences is defined using the just introduced function 'get_energies'. The structures are separated by their space groups: 225 and 221 for RS and 216 and 227 for ZB (the second space group of each structure takes account of the elemental solids). Furthermore the json path of the minimum structure (RS or ZB) is returned."
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
            ],
            "evaluatorReader": false
        },
        {
            "id": "code2z75Py",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "def get_energy_diffs(nomad_structure_list):    ",
                    "    df = get_energies(nomad_structure_list)",
                    "    ",
                    "    spacegroup_tuples = [(225, 221), (216, 227)] # [(RS), (ZB)]",
                    "    selected_space_groups, spacegroups_to_be_replace = zip(*spacegroup_tuples)",
                    "    ",
559
                    "    # replace all 221 by 225 and all 227 by 216 to get one RS and one ZB column",
560
                    "    df['space_group'] = df['space_group'].replace( spacegroups_to_be_replace , selected_space_groups )   ",
561
                    "",
562 563 564 565 566 567 568 569 570
                    "    # df with json_path of minimum energy per chemical_formula",
                    "    df_path_of_min = df.sort_values(by='energy').groupby(['chemical_formula'], as_index=True).first()['json_path']",
                    "    ",
                    "    # transform space_group values to column names",
                    "    df = df.pivot_table('energy', 'chemical_formula', 'space_group')",
                    "    df.columns = [216, 225]",
                    "    ",
                    "    df['energy_diff'] = df[225] - df[216]",
                    "    df['json_path'] = df_path_of_min   ",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
571 572
                    "    return df[['energy_diff', 'json_path']]",
                    "print \"Done\""
573
                ]
574 575 576
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
577
                "selectedType": "Results",
578
                "pluginName": "IPython",
579
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
580
                "height": 0
581 582
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
583
            "lineCount": 20,
584
            "tags": "get_energy_diffs"
585
        },
Emre Ahmetcik's avatar
Emre Ahmetcik committed
586 587 588 589 590 591 592 593 594 595 596
        {
            "id": "codexaiFel",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "P_df = get_energy_diffs(nomad_structure_list)",
                    "print P_df"
                ]
            },
            "output": {
Emre Ahmetcik's avatar
Emre Ahmetcik committed
597 598 599
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
600
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
601
                "height": 0
Emre Ahmetcik's avatar
Emre Ahmetcik committed
602 603 604 605
            },
            "evaluatorReader": true,
            "lineCount": 2
        },
606
        {
Emre Ahmetcik's avatar
Emre Ahmetcik committed
607 608 609
            "id": "markdownOBfktj",
            "type": "markdown",
            "body": [
610
                "Now let's consider a function which creates the descriptor matrix $\\mathbf{D}$ . The function is rather technical, so you can ignore the definition (but run the cell)."
Emre Ahmetcik's avatar
Emre Ahmetcik committed
611 612 613
            ],
            "evaluatorReader": false
        },
614
        {
Emre Ahmetcik's avatar
Emre Ahmetcik committed
615
            "id": "codeWJJ3l4",
616 617 618 619
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
620 621
                    "from nomad_sim.descriptors import AtomicFeatures",
                    "from nomadcore.local_meta_info import loadJsonFile, InfoKindEl",
622
                    "from nomad_sim.utils_binaries import get_chemical_formula_binaries",
623 624 625
                    "from nomad_sim.l1_l0 import  combine_features",
                    "import __builtin__",
                    "__builtin__.isBeaker = True",
626
                    "",
627
                    "def get_descriptors(nomad_structure_list=[] ,selected_feature_list=[], allowed_operations=[], **kwargs):",
628 629 630 631
                    "    metadata_info_path = '/nomad-meta-info/meta_info/nomad_meta_info/atomic_data.nomadmetainfo.json'",
                    "    metadata_info, warns = loadJsonFile(filePath=metadata_info_path, dependencyLoader=None,",
                    "                                        extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,uri=None)",
                    "    descriptor = AtomicFeatures(metadata_info=metadata_info, materials_class='binaries', **kwargs)",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
632
                    "",
633 634 635 636
                    "    # keep only one nomad_structure per chemical_formula since in our case the descriptors of same chemical_formula ",
                    "    # but different structures are the same ",
                    "    helper_dict = { get_chemical_formula_binaries(nomad_structure.atoms[0,0]): nomad_structure for nomad_structure in nomad_structure_list}",
                    "    unique_formula_nomad_structure_list = helper_dict.values()",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
637
                    "    ",
638 639 640
                    "    ll = [descriptor.calculate(nomad_structure, selected_feature_list) for nomad_structure in unique_formula_nomad_structure_list]",
                    "    df_features = pd.concat(ll)",
                    "    df_features = df_features.set_index('chemical_formula')",
641 642 643
                    "",
                    "    # convert numerical columns in float",
                    "    for col in df_features.columns.tolist():",
644 645
                    "        df_features[col] = df_features[col].astype(float)",
                    "    ",
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
                    "    # arethmetic combinations",
                    "    df_combined = combine_features(",
                    "                                    df=df_features,",
                    "                                    energy_unit=kwargs['energy_unit'],",
                    "                                    length_unit=kwargs['length_unit'],",
                    "                                    metadata_info=metadata_info,",
                    "                                    allowed_operations=allowed_operations)",
                    "",
                    "    #Transform metadata names to shortnames. First make dict with metadata name: shortname",
                    "    feature_list = df_features.columns.tolist()",
                    "    feature_list = [feature.split('(', 1)[0] for feature in feature_list]",
                    "        ",
                    "    # in for lop to allow exception",
                    "    shortname = []",
                    "    for feature in feature_list:",
                    "        try:",
                    "            shortname.append(metadata_info[str(feature)]['shortname'])",
                    "        except:",
                    "            shortname.append(feature)",
                    "",
                    "    shortnames_dict = dict(zip(feature_list, shortname))",
667
                    "    ",
668 669 670 671 672 673
                    "    combined_feature_list = df_combined.columns.tolist()",
                    "    for fullname, shortname in shortnames_dict.items():",
                    "        combined_feature_list = [item.replace(fullname.lower(), shortname) for item in combined_feature_list]",
                    "    df_combined.columns = combined_feature_list",
                    "    ",
                    "    return df_combined"
674
                ]
675 676 677
            },
            "output": {
                "state": {},
678
                "selectedType": "Hidden",
679
                "pluginName": "IPython",
680 681
                "shellId": "2AE09B3957224934A1D62458982D7D68",
                "height": 81
682 683
            },
            "evaluatorReader": true,
684
            "lineCount": 54,
685
            "tags": "get_descriptors"
686
        },
687 688 689 690 691 692 693 694
        {
            "id": "markdownS5NEVZ",
            "type": "markdown",
            "body": [
                "Use 'get_descriptors' to obtain the descriptor matrix $\\mathbf{D}$ of the radii at the maximum value of  the s, p, and d valence radial probability density:  $r_s(A), r_s(B), r_p(A), r_p(B), r_d(A), r_d(B)$. If the list of allowed (arithmetic) operations is empty only the six primary features are returned. If strings of arithmetic operations are included (i.e. \"$+$\", \"$-$\", \"$/$\", \"$\\exp$\") also derived features will be added to the matrix."
            ],
            "evaluatorReader": false
        },
695
        {
696
            "id": "codeWjXSr9",
697 698 699 700
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
701 702
                    "kwargs = {",
                    "          'nomad_structure_list': nomad_structure_list,",
703 704 705 706 707 708
                    "          'selected_feature_list': None,",
                    "          'allowed_operations': None,",
                    "          'path_to_collection': '/data/shared/tutorials/nomad_sim/data_zcrs/ExtendedBinaries_Dimers_Atoms_new.json',",
                    "          'feature_order_by': 'atomic_mulliken_electronegativity',",
                    "          'energy_unit': 'eV',",
                    "          'length_unit': 'angstrom'                ",
709 710
                    "         }",
                    "",
711 712 713
                    "kwargs['selected_feature_list'] = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
                    "# kwargs['allowed_operations'] = ['+', '-', '|-|', '*', '/' '^2', '^3',  'exp']",
                    "kwargs['allowed_operations'] = []",
714 715
                    "df_desc = get_descriptors(**kwargs)",
                    "print df_desc"
716 717 718 719 720 721
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
722
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
723
                "height": 0
724 725
            },
            "evaluatorReader": true,
726
            "lineCount": 15
727 728 729 730 731
        },
        {
            "id": "markdownjES4yc",
            "type": "markdown",
            "body": [
732
                "Let's summarize the untill now declared functions to a new function 'get_data' which returns the numpy arrays  $\\mathbf{P}$ and $\\mathbf{D}$, the list of feature name strings, the list of compound strings ( the order matches to the ones of the rows of both $\\mathbf{P}$ and $\\mathbf{D}$) and the list of json paths of the minimum energy structures (also in the right order). We will need this function in the next chapters."
733 734
            ],
            "evaluatorReader": false
735 736
        },
        {
737
            "id": "code57Huu9",
738
            "type": "code",
739
            "evaluator": "IPython",
740 741
            "input": {
                "body": [
742 743 744 745
                    "def get_data(selected_feature_list, allowed_operations):",
                    "    kwargs = {",
                    "          'nomad_structure_list': nomad_structure_list,",
                    "          'selected_feature_list': selected_feature_list,",
746 747 748 749 750 751
                    "          'allowed_operations': allowed_operations,",
                    "          'path_to_collection': '/data/shared/tutorials/nomad_sim/data_zcrs/ExtendedBinaries_Dimers_Atoms_new.json',",
                    "          'feature_order_by': 'atomic_mulliken_electronegativity',",
                    "          'energy_unit': 'eV',",
                    "          'length_unit': 'angstrom'                ",
                    "         }  ",
752 753 754 755 756 757 758 759 760 761
                    "    D_df = get_descriptors(**kwargs)",
                    "    P_df = get_energy_diffs(nomad_structure_list)",
                    "    ",
                    "    feature_list = D_df.columns.tolist()",
                    "    compounds_list = D_df.index.tolist()",
                    "    P_df = P_df.reindex(compounds_list)",
                    "    ",
                    "    json_paths = P_df['json_path'].tolist()",
                    "    P_df =  P_df['energy_diff']",
                    "    ",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
762 763
                    "    return P_df.values, D_df.values, feature_list, compounds_list, json_paths",
                    "print \"Done\""
764
                ]
765 766 767
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
768
                "selectedType": "Results",
769
                "pluginName": "IPython",
770
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
771
                "height": 0
772 773
            },
            "evaluatorReader": true,
774
            "lineCount": 22,
775
            "tags": "get_data"
776 777
        },
        {
778
            "id": "code6YvnAC",
779 780 781 782
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
Emre Ahmetcik's avatar
Emre Ahmetcik committed
783
                    "# check that get_data works",
784
                    "selected_feature_list = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
785 786
                    "allowed_operations = []",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)",
787
                    "print P.shape, D.shape, len(feature_list), len(json_paths)"
788 789 790 791 792 793
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
794
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
795
                "height": 0
796 797
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
798
            "lineCount": 5
799 800
        },
        {
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
            "id": "sectionCs89Kj",
            "type": "section",
            "title": "Determining low-dimensional descriptors with the $\\ell_0$ method",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdownUK5ZfK",
            "type": "markdown",
            "body": [
                "<summary>",
                "<li> Perform an $\\ell_0$-regularization to identify the best low dimensional descriptors using the primary features.</li>",
                "<li> Show that non-linear functions of the primary features improve the models significantly. </li>",
                "<li> See that the $\\ell_0$-regularization can rapidly become computational infeasible.</li>",
                "</summary>"
            ],
            "evaluatorReader": false
        },
        {
            "id": "markdownJaNdzs",
            "type": "markdown",
            "body": [
                "For the case you have skipped a chapter, at the beginning of each chapter a JavaScript cell is provided which runs the relevant cells from chapters before with functions we will need in this chapter."
            ],
            "evaluatorReader": false
827 828
        },
        {
829
            "id": "coderkkthv",
830
            "type": "code",
831
            "evaluator": "JavaScript",
832 833
            "input": {
                "body": [
834
                    "// 'Import' relevant functions from chapter before",
835 836 837 838 839 840 841
                    "var functions_list = [\"json_list\", \"nomad_structure_list\", \"get_energies\", \"get_energy_diffs\", \"get_descriptors\", \"get_data\"];",
                    "var n_functions = functions_list.length",
                    "var i;",
                    "for (i = 0; i < n_functions; i++) {",
                    "    beaker.evaluate(functions_list[i]);",
                    "    beaker.print('import '+functions_list[i]);",
                    "}"
842
                ]
843 844 845
            },
            "output": {
                "state": {},
846 847
                "selectedType": "Results",
                "pluginName": "JavaScript",
848
                "height": 0
849 850
            },
            "evaluatorReader": true,
851
            "lineCount": 8
852 853
        },
        {
854 855 856
            "id": "markdownxZfCEL",
            "type": "markdown",
            "body": [
Emre Ahmetcik's avatar
Emre Ahmetcik committed
857
                "Our target is to find the best low dimensional descriptor for a linear model. The $\\ell_0$ regularization",
858 859 860 861
                "",
                "$\\text{argmin}_{\\mathbf{c} \\in \\mathbb{R}^{m}} \\{\\|\\mathbf{P} - \\mathbf{D}\\mathbf{c}\\|^2_2 +\\lambda \\|\\mathbf{c}\\|_0\\}$",
                "",
                "provides exactly what we want. It is defined in the follwing and solved combinatorial:"
862 863 864 865
            ],
            "evaluatorReader": false
        },
        {
866
            "id": "codeVTzLtQ",
867 868 869 870
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
871
                    "from itertools import combinations",
872
                    "",
873 874 875 876 877 878 879 880
                    "def L0(P, D, dimension):",
                    "    n_rows, n_columns = D.shape",
                    "    D = np.column_stack((D,np.ones(n_rows)))",
                    "    SE_min = np.inner(P,P)",
                    "    coef_min, permu_min = None, None",
                    "    for permu in combinations(range(n_columns),dimension):",
                    "        D_ls = D[:,permu+(-1,)]",
                    "        coef, SE, __1, __2 = np.linalg.lstsq(D_ls,P)",
881 882 883 884 885 886
                    "        try:",
                    "            if SE[0] < SE_min: ",
                    "                SE_min = SE[0]",
                    "                coef_min, permu_min = coef, permu",
                    "        except:",
                    "            pass",
887
                    "    RMSE = np.sqrt(SE_min/n_rows)",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
888 889
                    "    return RMSE, coef_min, permu_min",
                    "print \"Done\""
890 891 892 893
                ]
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
894
                "selectedType": "Results",
895
                "pluginName": "IPython",
896
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
897
                "height": 0
898 899
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
900
            "lineCount": 19,
901 902
            "tags": "L0"
        },
903 904 905 906 907 908 909 910
        {
            "id": "markdownkIHqDn",
            "type": "markdown",
            "body": [
                "Perform the $\\ell_0$-regularization for different dimensions (numbers of non-zero coefficients in the model) and see the root mean square errors (RMSE) and the selected features."
            ],
            "evaluatorReader": false
        },
911 912 913 914 915 916
        {
            "id": "code5rtN3R",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
917
                    "selected_feature_list = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
918 919
                    "allowed_operations = []",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)",
920
                    "",
921
                    "print \"    RMSE           Best desriptor\"",
922 923
                    "for dim in range(1,7):",
                    "    RMSE, coefficients, selected_indices = L0(P,D,dim)",
924
                    "    print '%sD:' %dim, RMSE, [feature_list[i] for i in selected_indices]"
925 926 927 928 929 930
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
931
                "shellId": "2AE09B3957224934A1D62458982D7D68",
932
                "height": 0
933 934
            },
            "evaluatorReader": true,
935
            "lineCount": 8
936 937
        },
        {
938 939 940 941 942 943
            "id": "markdown7wwBua",
            "type": "markdown",
            "body": [
                "Improvements can be obtained by increasing the feature space using more complex features (the derived features). Run the following script and plot the results afterwards. How does the accuracy of the models change? How does the feature space size and the dimension of the descriptors depend on the needed time to solve the $\\ell_0$-problem?"
            ],
            "evaluatorReader": false
944 945
        },
        {
946
            "id": "codeLJovcN",
947 948 949 950
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
951
                    "from time import time",
952
                    "selected_feature_list = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
953 954 955
                    "op_lists = [[], ['+','|-|'], ['+','|-|','exp'], ['+','|-|','exp', '^2'] ]",
                    "X  = []",
                    "Errors, Time = np.empty([3,len(op_lists)]), np.empty([3,len(op_lists)])",
956
                    "",
957 958
                    "for n_op, allowed_operations in enumerate(op_lists):",
                    "    P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)",
959 960
                    "    number_of_features = len(feature_list)",
                    "    X.append(number_of_features)",
961 962 963 964 965 966 967 968 969
                    "    for dim in range(1,4):",
                    "        t1= time()",
                    "        RMSE, coefficients, selected_indices = L0(P,D,dim)",
                    "        t2 = time()-t1             ",
                    "        ",
                    "        Time [dim-1][n_op] = t2",
                    "        Errors[dim-1][n_op] = RMSE ",
                    "        ",
                    "        print \"features: %s; %sD  RMSE: %s  best features: %s\" %(len(feature_list), dim, RMSE, [feature_list[i] for i in selected_indices])"
970 971 972 973 974 975
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
976
                "shellId": "2AE09B3957224934A1D62458982D7D68",
977
                "height": 0
978 979
            },
            "evaluatorReader": true,
980
            "lineCount": 19
981 982
        },
        {
983
            "id": "codeZtBOQi",
984
            "type": "code",
985
            "evaluator": "IPython",
986 987
            "input": {
                "body": [
988 989 990
                    "#plot",
                    "f, (ax1, ax2) = plt.subplots(1,2, sharex=True, figsize=(12,8))",
                    "ax1.set_xlabel('Number of features')",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
991 992
                    "ax2.set_xlabel('Number of features'",
                    ")",
993 994 995
                    "ax1.set_ylabel('RMSE [eV]')",
                    "ax2.set_ylabel('Time [s]')",
                    "#ax2.set_yscale('log')",
996
                    "",
997 998 999
                    "for dim in range(1,4):",
                    "    ax1.plot(X, Errors[dim-1], 's-', label='%sD' %dim)",
                    "    ax2.plot(X, Time[dim-1], 's-', label='%sD' %dim)",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1000 1001
                    "ax2.legend(loc='best')",
                    "plt.show()"
1002
                ]
1003 1004 1005
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1006
                "selectedType": "Html",
1007
                "pluginName": "IPython",
1008
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1009
                "height": 0
1010 1011
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1012
            "lineCount": 14
1013 1014
        },
        {
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
            "id": "markdownJAAraB",
            "type": "markdown",
            "body": [
                "Assume now that we would like to include thousands or millions of (more) complex features to obtain more accurate models..."
            ],
            "evaluatorReader": false
        },
        {
            "id": "sectionX7Z2F0",
            "type": "section",
            "title": "Approximations to the $\\ell_0$ method",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdowneXLmPW",
            "type": "markdown",
            "body": [
                "<summary>",
                "<li >Perform a LASSO minimization and the LASSO+$\\ell_0$ method.</li>",
                "<li >Compare the solutions with the ones from the $\\ell_0$ method.</li>",
                "</summary>"
            ],
            "evaluatorReader": false
        },
        {
            "id": "codeSGrV0g",
1043
            "type": "code",
1044
            "evaluator": "JavaScript",
1045 1046
            "input": {
                "body": [
1047
                    "// 'Import' relevant functions from chapters before",
1048 1049 1050 1051 1052 1053 1054
                    "var functions_list = [\"json_list\", \"nomad_structure_list\", \"get_energies\", \"get_energy_diffs\", \"get_descriptors\", \"get_data\", \"L0\"];",
                    "var n_functions = functions_list.length",
                    "var i;",
                    "for (i = 0; i < n_functions; i++) {",
                    "    beaker.evaluate(functions_list[i]);",
                    "    beaker.print('import '+functions_list[i]);",
                    "}"
1055
                ]
1056 1057 1058 1059
            },
            "output": {
                "state": {},
                "selectedType": "Results",
1060
                "pluginName": "JavaScript",
1061
                "height": 0
1062 1063
            },
            "evaluatorReader": true,
1064 1065 1066 1067 1068 1069 1070 1071 1072
            "lineCount": 8
        },
        {
            "id": "section96VfCa",
            "type": "section",
            "title": "The LASSO",
            "level": 2,
            "evaluatorReader": false,
            "collapsed": false
1073 1074 1075 1076 1077 1078
        },
        {
            "id": "markdownHjYp4E",
            "type": "markdown",
            "body": [
                "",
1079 1080 1081 1082 1083 1084
                "One state-of-the art approximation to the $\\ell_0$-method is the LASSO: ",
                "",
                "$\\text{argmin}_{\\mathbf{c} \\in \\mathbb{R}^{m}} \\{\\|\\mathbf{P} - \\mathbf{D}\\mathbf{c}\\|^2_2 +\\lambda \\|\\mathbf{c}\\|_1\\}$.",
                "",
                "Before performing the LASSO regression we standardize the data to have mean 0 and variance 1, since otherwise the $\\ell_2$-norm of a column would affect bias its contribution to the model. <br>",
                "Note that we can use the LASSO also only for feature selection. We can use then a least-square model with the selected features afterwards instead of the LASSO model directly."
1085 1086
            ],
            "evaluatorReader": false
1087
        },
1088 1089 1090 1091 1092 1093 1094 1095 1096
        {
            "id": "code3B4gWJ",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "from sklearn.linear_model import Lasso",
                    "import scipy.stats as ss",
                    "",
1097
                    "def lasso_fit(lam, P, D, feature_list):",
1098 1099 1100 1101 1102 1103
                    "    #LASSO",
                    "    D_standardized = ss.zscore(D)",
                    "    lasso =  Lasso(alpha=lam)",
                    "    lasso.fit(D_standardized, P)",
                    "    coef =  lasso.coef_",
                    "    ",
1104
                    "    # get strings of selected features",
1105 1106 1107
                    "    selected_indices = coef.nonzero()[0]",
                    "    selected_features = [feature_list[i] for i in selected_indices]",
                    "    ",
1108 1109 1110 1111 1112
                    "    # get RMSE of LASSO model",
                    "    P_predict = lasso.predict(D_standardized)",
                    "    RMSE_LASSO = np.linalg.norm(P-P_predict) / np.sqrt(82.)",
                    "       ",
                    "    #get RMSE for least-square fit",
1113 1114
                    "    D_new = D[:, selected_indices]",
                    "    D_new = np.column_stack((D_new, np.ones(82)))",
1115 1116
                    "    RMSE_LS = np.sqrt(np.linalg.lstsq(D_new,P)[1][0]/82.)",
                    "        ",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1117 1118
                    "    return RMSE_LASSO, RMSE_LS, coef, selected_features",
                    "print \"Done\""
1119 1120 1121 1122
                ]
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1123
                "selectedType": "Results",
1124
                "pluginName": "IPython",
1125
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1126
                "height": 0
1127 1128
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1129
            "lineCount": 25
1130 1131 1132 1133 1134
        },
        {
            "id": "markdown5p8ptN",
            "type": "markdown",
            "body": [
1135
                "$\\lambda$ regulates the sparsity of the coefficient vector of the model. Get the data and try different $\\lambda$ by shifting the lever along the range. How good does LASSO (directly or with a least square fit afterwards) approximate the L0-method (when the same feature space is used for both)?"
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
            ],
            "evaluatorReader": false
        },
        {
            "id": "codeQQDvNE",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "#import Data",
1146
                    "selected_feature_list = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
1147 1148 1149 1150
                    "allowed_operations = ['+','|-|','exp', '^2']",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)"
                ]
            },
1151 1152 1153 1154
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
1155
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1156
                "height": 0
1157 1158
            },
            "evaluatorReader": true,
1159
            "lineCount": 4
1160 1161
        },
        {
1162
            "id": "codeQMp7hF",
1163
            "type": "code",
1164
            "evaluator": "HTML",
1165 1166
            "input": {
                "body": [
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
                    "<input id=\"valBox\" type=\"range\" min=\"0.02\" max=\"0.36\" step=\"0.01\" ",
                    "   oninput=\"showVal(this.value)\" >",
                    "<output for=value id=\"output\">lambda: </output>",
                    "<script>",
                    "function showVal(newVal){",
                    "  beaker.lam = newVal;",
                    "  beaker.evaluate(\"lambda_cell\")",
                    "  document.querySelector('#output').value = \"lambda: \"+newVal;;",
                    "}",
                    "</script>"
1177 1178 1179 1180 1181
                ],
                "hidden": true
            },
            "output": {
                "state": {},
1182 1183
                "selectedType": "BeakerDisplay",
                "height": 0,
1184 1185 1186
                "result": {
                    "type": "BeakerDisplay",
                    "innertype": "Html",
1187
                    "object": "<script>\nvar beaker = bkHelper.getBeakerObject().beakerObj;\n</script>\n<input id=\"valBox\" type=\"range\" min=\"0.02\" max=\"0.36\" step=\"0.01\" \n   oninput=\"showVal(this.value)\" >\n<output for=value id=\"output\">lambda: </output>\n<script>\nfunction showVal(newVal){\n  beaker.lam = newVal;\n  beaker.evaluate(\"lambda_cell\")\n  document.querySelector('#output').value = \"lambda: \"+newVal;;\n}\n</script>"
1188
                },
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1189
                "elapsedTime": 0
1190 1191
            },
            "evaluatorReader": true,
1192 1193
            "lineCount": 10,
            "initialization": true
1194 1195
        },
        {
1196
            "id": "coded2PoWQ",
1197
            "type": "code",
1198
            "evaluator": "IPython",
1199 1200
            "input": {
                "body": [
1201
                    "lam = float(beaker.lam)",
1202
                    "RMSE_LASSO, RMSE_LS, coef, selected_features = lasso_fit(lam, P, D, feature_list)",
1203 1204 1205 1206
                    "plt.bar(range(len(coef)), np.abs(coef))",
                    "plt.xlabel(\"Coefficient index $i$\")",
                    "plt.ylabel(\"$|c_i|$\")",
                    "",
1207 1208
                    "print \"lambda: %.3f\\t dimension of descriptor: %s\\t RMSE_LASSO: %.3f\\t RMSE_LS: %.3f\" %(lam, len(selected_features), RMSE_LASSO, RMSE_LS)",
                    "print pd.DataFrame({'features':np.array(selected_features), 'abs(nonzero_coef_LASSO)': np.abs(coef[coef.nonzero()])})",
1209
                    "    "
1210 1211
                ],
                "hidden": true
1212 1213 1214
            },
            "output": {
                "state": {},
1215 1216
                "selectedType": "Results",
                "pluginName": "IPython",
1217
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1218
                "height": 0,
1219
                "dataresult": "\n1D  RMSE: 0.296667854538  best features: [u'r_p(A)+r_d(B)']\n\n\n2D  RMSE: 0.194137980385  best features: [u'r_p(A)+r_s(B)', u'(r_p(A)+r_s(B))^2']\n\n3D  RMSE: 0.170545574785  best features: [u'r_p(A)+r_s(B)', u'(r_p(A)+r_s(B))^2', u'exp(r_p(A)+r_s(B))']\n"
1220 1221
            },
            "evaluatorReader": true,
1222 1223
            "lineCount": 9,
            "tags": "lambda_cell"
1224
        },
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
        {
            "id": "markdownXXp8Xd",
            "type": "markdown",
            "body": [
                "Hint:",
                "Compare these results to the L0 results you have obtained before from the same feature space, copied and pasted in here:<br>",
                "\"Number of total features generated: 99 <br>",
                " features: 99; 1D  RMSE: 0.296667831742  best features: ['(r_p(A)+r_d(B))'] <br>",
                " features: 99; 2D  RMSE: 0.194137965466  best features: ['(r_s(B)+r_p(A))', '(r_s(B)+r_p(A))^2'] <br>",
                " features: 99; 3D  RMSE: 0.170545556349  best features: ['(r_s(B)+r_p(A))', '(r_s(B)+r_p(A))^2', 'exp(r_s(B)+r_p(A))']\""
            ],
            "evaluatorReader": false
        },
1238 1239 1240 1241 1242 1243 1244 1245
        {
            "id": "section0K9XU9",
            "type": "section",
            "title": "The LASSO+$\\ell_0$-method",
            "level": 2,
            "evaluatorReader": false,
            "collapsed": false
        },
1246
        {
1247 1248 1249
            "id": "markdownMRkeOn",
            "type": "markdown",
            "body": [
1250
                "In the follwoing cell, the LASSO+$\\ell_0$ method is implemented. Just run the cell."
1251 1252 1253 1254 1255
            ],
            "evaluatorReader": false
        },
        {
            "id": "code1xeZvT",
1256 1257 1258 1259
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
1260 1261
                    "from sklearn.linear_model import Lasso",
                    "import scipy.stats as ss",
1262
                    "from itertools import combinations",
1263
                    "",
1264
                    "def iter_lasso(P , D, lambda_grid, lasso_number=30, print_lasso=False):",
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
                    "    collection=[]",
                    "    if print_lasso:",
                    "        print 'lamda      #collected   Indices'",
                    "        ",
                    "    for lam in lambda_grid:",
                    "        lasso = Lasso(alpha=lam)",
                    "        lasso.fit(D, P)",
                    "        coef = lasso.coef_ ",
                    "        collection = collection + list(set(np.nonzero(coef)[0]) - set(collection))",
                    "        if print_lasso:",
                    "            print '%.10f   %s   %s'%(lam,len(collection), np.nonzero(coef)[0])",
                    "        if len(collection) > lasso_number - 1:",
                    "            break",
                    "            ",
                    "    if len(collection)<lasso_number and print_lasso:",
                    "        print \"Only %s features are collected\" %len(collection)",
                    "    collection=collection[:lasso_number]",
                    "    collection.sort()",
                    "    return collection   ",
1284
                    "",
1285 1286 1287 1288 1289 1290 1291 1292 1293
                    "def evaluate_lambda_grid(P, D, lambda_grid_points=150, lambda_max_factor=1.0, lambda_min_factor=0.001):",
                    "    correlations = np.abs(np.dot(P,D))",
                    "    lam_max = max(correlations) / (len(P)) # max lambda with nonzero LASSO solution",
                    "    lam_min = lam_max * lambda_min_factor",
                    "    lam_max = lam_max * lambda_max_factor",
                    "    log_max, log_min = np.log10(lam_max), np.log10(lam_min)",
                    "    lambda_grid = [pow(10,i) for i in np.linspace(log_min,log_max,lambda_grid_points)]",
                    "    lambda_grid.sort(reverse=True)",
                    "    return lambda_grid",
1294
                    "",
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
                    "def get_string(selected_features, coef, RMSE):",
                    "    dimension = len(selected_features)",
                    "    string = '%sD:\\t%8f\\t' %(dimension, RMSE)",
                    "    for i in range(dimension+1):",
                    "        if coef[i] > 0.:",
                    "            sign = '+' ",
                    "            c = coef[i]",
                    "        else:",
                    "            sign = '-'",
                    "            c = abs(coef[i]) ",
                    "        if i < dimension:",
                    "            string += '%s %.3f %s ' %(sign,c,selected_features[i])",
                    "        else:",
                    "            string += '%s %.3f' %(sign,c)",
                    "    return string",
1310
                    "",
1311
                    "def lasso_L0(P,D,features, dimrange=range(1,1+3), lasso_number=30, lambda_grid_points=150, lambda_max_factor=1.0, lambda_min_factor=0.001, print_lasso=False, lambda_grid=None, print_model=False):    ",
1312 1313 1314 1315 1316 1317
                    "    D_standardized = np.array(ss.zscore(D))",
                    "    ",
                    "    # get lambda grid where maximumx value is maximum lambda with nonzero LASSO solution",
                    "    lambda_grid = evaluate_lambda_grid(P, D_standardized)",
                    "    ",
                    "    # collect first lasso_number features appearing when tuning lambda down",
1318
                    "    collection = iter_lasso(P , D_standardized, lambda_grid, lasso_number=lasso_number, print_lasso=print_lasso)    ",
1319 1320 1321 1322 1323
                    "     ",
                    "    D_collection = D[:,collection]",
                    "     ",
                    "    # L0-regularazition",
                    "    out = []   ",
1324
                    "",
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334
                    "    for dim in dimrange:",
                    "        RMSE, coef, selected_indices = L0(P, D_collection, dim)",
                    "        indices_for_D = [collection[i] for i in selected_indices]",
                    "        out.append((indices_for_D, coef, RMSE))",
                    "        ",
                    "    if print_model:",
                    "        string = '%14s %16s\\n' %('RMSE', 'Model')",
                    "        string += \"\\n\".join( [get_string([features[i] for i in o[0]], o[1], o[2]) for o in out] )",
                    "        print string",
                    "        ",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1335 1336
                    "    return out",
                    "print \"Done\""
1337 1338 1339 1340
                ]
            },
            "output": {
                "state": {},
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1341
                "selectedType": "Results",
1342
                "pluginName": "IPython",
1343
                "shellId": "2AE09B3957224934A1D62458982D7D68",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1344
                "height": 0
1345 1346
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1347
            "lineCount": 77,
1348
            "tags": "lasso_L0"
1349 1350
        },
        {
1351
            "id": "codeTMeEsa",
1352 1353 1354 1355
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
1356
                    "#import Data",
1357
                    "selected_feature_list = ['atomic_rs_max', 'atomic_rp_max', 'atomic_rd_max']",
1358 1359
                    "allowed_operations = ['+','|-|','exp', '^2']",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)"
1360 1361 1362 1363
                ]
            },
            "output": {
                "state": {},
1364 1365
                "selectedType": "Results",
                "pluginName": "IPython",
1366
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1367
                "height": 0
1368 1369
            },
            "evaluatorReader": true,
1370 1371 1372 1373 1374 1375 1376 1377 1378
            "lineCount": 4
        },
        {
            "id": "markdownWLKH4F",
            "type": "markdown",
            "body": [
                "Now run the 'lasso_L0' function. How does the LASSO+$\\ell_0$-method compare to the LASSO and to the $\\ell_0$-regularization in terms of accuracy?  How fast ist the LASSO+$\\ell_0$-method compared to the $\\ell_0$-regularization? If 'print_lasso' is set 'True' the indices of the non-zero coefficients are displayed in each $\\lambda$ step. The argument 'lasso_number' specifies how many features shall be collected in the LASSO part. "
            ],
            "evaluatorReader": false
1379 1380
        },
        {
1381
            "id": "codewRNOmz",
1382
            "type": "code",
1383
            "evaluator": "IPython",
1384 1385
            "input": {
                "body": [
1386 1387
                    "out = lasso_L0(P, D, feature_list, print_lasso=True, lasso_number=30, print_model=True)"
                ]
1388 1389 1390
            },
            "output": {
                "state": {},
1391 1392
                "selectedType": "Results",
                "pluginName": "IPython",
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1393
                "shellId": "CFDBBC64C18149AA8C1F32F183239C1A",
1394
                "height": 0
1395 1396
            },
            "evaluatorReader": true,
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417
            "lineCount": 1
        },
        {
            "id": "sectionAFf1Fp",
            "type": "section",
            "title": "Visualization of the descriptors and experimenting with the LASSO+$\\ell_0$ tool",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdownlb696i",
            "type": "markdown",
            "body": [
                "<summary>",
                "<li>Reproduce the results from the <a href=\"http://journals.aps.org/prl/abstract/10.1103/PhysRevLett.114.105503\" target=\"_blank\">reference publication</a>  by including further features.</li>",
                "<li>Visualize the 2D descriptors in an interactive structure map.</li>",
                "<li>Experiment with different settings and investigate the influence of the input parameters on the results. (OPTIONAL)</li>",
                "</summary>"
            ],
            "evaluatorReader": false
1418 1419 1420 1421 1422 1423 1424
        },
        {
            "id": "codeh96cIm",
            "type": "code",
            "evaluator": "JavaScript",
            "input": {
                "body": [
1425 1426
                    "// 'Import' relevant functions from chapters before",
                    "var functions_list = [\"json_list\", \"nomad_structure_list\", \"get_energies\", \"get_energy_diffs\", \"get_descriptors\", \"get_data\", \"L0\", \"lasso_L0\"];",
1427 1428 1429 1430 1431 1432
                    "var n_functions = functions_list.length",
                    "var i;",
                    "for (i = 0; i < n_functions; i++) {",
                    "    beaker.evaluate(functions_list[i]);",
                    "    beaker.print('import '+functions_list[i]);",
                    "}"
1433
                ]
1434 1435 1436 1437 1438
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "JavaScript",
1439
                "height": 0
1440 1441
            },
            "evaluatorReader": true,
1442
            "lineCount": 8
1443 1444 1445 1446 1447
        },
        {
            "id": "markdownk3cQaO",
            "type": "markdown",
            "body": [
1448 1449 1450
                "By just clicking 'CALCULATE' in the HTML cell all follwing cells of this chapter will be run performing the LASSO+$\\ell_0$ method and generating a structure map with the found 2D descriptor.  Click 'View interactiv 2D scater plot' to see the structure map.  You do not need to investigate the remaining cells. ",
                "Note the size of the feature space, the needed time to run the code and the accuracy (using the default settings)!",
                "",
1451
                "If you have enough time you can  experiment, now, with the LASSO+$\\ell_0$ tool  including different primary features, arithmetic operations or changing the number of features ('lasso_number') collected  in the LASSO step. There is also  a <a href=\"https://analytics-toolkit.nomad-coe.eu/notebook-edit/data/shared/tutorials/lasso/LASSO_L0.bkr\">version of the LASSO+$\\ell_0$ tool with an interface</a>."
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463
            ],
            "evaluatorReader": false
        },
        {
            "id": "codev160kC",
            "type": "code",
            "evaluator": "HTML",
            "input": {
                "body": [
                    "<script>",
                    "var run_lasso = function() {",
                    "  $(\"#lasso_result_button\").removeClass(\"active\").addClass(\"disabled\");",
1464
                    "  beaker.evaluate(\"calc_cell\"); ",
1465
                    "};",
1466 1467 1468 1469
                    "beaker.view_result = function(result_link) {",
                    "    $(\"#lasso_result_button\").attr(\"href\", result_link);",
                    "  $(\"#lasso_result_button\").removeClass(\"disabled\").addClass(\"active\");",
                    "}",
1470 1471 1472
                    "</script>",
                    "<div class=\"lasso_control\">",
                    "  <p style=\"margin-top: 1ex;\"></p>",
1473
                    "  <button class=\"btn btn-default\" onclick='run_lasso()' style=\"font-weight: bold;\">CALCULATE</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
1474
                    "  <label title=\"This button becomes active when the",
1475
                    "run is finished. By clicking it, an interactive plot of the 2D-descriptor will be opened\"> ",
1476 1477 1478 1479 1480 1481 1482 1483
                    "  <a href=\"#\" target=\"_blank\" class=\"btn btn-primary disabled\" id=\"lasso_result_button\" >View interactive 2D scatter plot</a> </label>",
                    "</div>",
                    ""
                ],
                "hidden": true
            },
            "output": {
                "state": {},
1484 1485
                "selectedType": "BeakerDisplay",
                "height": 0,
1486 1487 1488
                "result": {
                    "type": "BeakerDisplay",
                    "innertype": "Html",
1489
                    "object": "<script>\nvar beaker = bkHelper.getBeakerObject().beakerObj;\n</script>\n<script>\nvar run_lasso = function() {\n  $(\"#lasso_result_button\").removeClass(\"active\").addClass(\"disabled\");\n  beaker.evaluate(\"calc_cell\"); \n};\nbeaker.view_result = function(result_link) {\n    $(\"#lasso_result_button\").attr(\"href\", result_link);\n  $(\"#lasso_result_button\").removeClass(\"disabled\").addClass(\"active\");\n}\n</script>\n<div class=\"lasso_control\">\n  <p style=\"margin-top: 1ex;\"></p>\n  <button class=\"btn btn-default\" onclick='run_lasso()' style=\"font-weight: bold;\">CALCULATE</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n  <label title=\"This button becomes active when the\nrun is finished. By clicking it, an interactive plot of the 2D-descriptor will be opened\"> \n  <a href=\"#\" target=\"_blank\" class=\"btn btn-primary disabled\" id=\"lasso_result_button\" >View interactive 2D scatter plot</a> </label>\n</div>\n"
1490
                },
1491
                "elapsedTime": 0
1492 1493
            },
            "evaluatorReader": true,
1494 1495
            "lineCount": 18,
            "initialization": true
1496 1497 1498 1499 1500 1501 1502
        },
        {
            "id": "codeo0JBr5",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
1503
                    "#possible operations: '+', '-', '|-|', '*', '/' '^2', '^3',  'exp'",
1504
                    "#possible features: \"atomic_ionization_potential\", \"atomic_electron_affinity\", \"atomic_homo\", \"atomic_lumo\", \"atomic_rs_max\", \"atomic_rp_max\", \"atomic_rd_max\", \"atomic_number\", \"period\", \"atomic_r_by_2_dimer\", \"atomic_electronic_binding_energy_dimer\"",
1505
                    "",
1506
                    "selected_feature_list = ['atomic_ionization_potential', 'atomic_electron_affinity', 'atomic_rs_max', 'atomic_rp_max','atomic_rd_max']",
1507 1508
                    "allowed_operations = ['+','|-|','exp','^2', '/']",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)",
1509
                    "out = lasso_L0(P, D, feature_list, print_lasso=False, lasso_number=50, print_model=True)"
1510 1511 1512 1513
                ]
            },
            "output": {
                "state": {},
1514
                "selectedType": "Results",
1515
                "pluginName": "IPython",
1516
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1517
                "height": 0
1518 1519
            },
            "evaluatorReader": true,
Emre Ahmetcik's avatar
Emre Ahmetcik committed
1520
            "lineCount": 7,
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556
            "tags": "calc_cell"
        },
        {
            "id": "codeZgJkib",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "import hashlib",
                    "from bokeh.util.browser import view",
                    "from nomad_sim.viewer import Viewer",
                    "from nomad_sim.utils_crystals import create_supercell",
                    "from nomad_sim.wrappers import _get_structures",
                    "import __builtin__",
                    "__builtin__.isBeaker = True",
                    "",
                    "index, coef, RMSE = out[1] # 2D",
                    "x_axis_label, y_axis_label = feature_list[index[0]], feature_list[index[1]]",
                    "D_model = D[:,index]",
                    "D_model = np.column_stack((D_model,np.ones(82)))",
                    "P_pred = np.dot(D_model,coef)",
                    "",
                    "# parameters for the nomad viewer",
                    "x_list, y_list, _ones = D_model.transpose().tolist()",
                    "frame_list = [[0] for _ in range(82)]",
                    "op_list = np.zeros(82)",
                    "operations_on_structure = [(create_supercell, {'replicas': [3, 3, 3]})]",
                    "data_folder='/parsed/prod-017/FhiAimsParser2.0.0/RdUzye8EKmv-z4LGNHGTSk8S3S1WY'",
                    "legend_title='Reference E(RS)-E(ZB)'",
                    "plot_title = 'LASSO+L0 structure map'",
                    "target_name='E(RS)-E(ZB)'",
                    "tmp_folder='/home/beaker/.beaker/v1/web/tmp/'",
                    "parameter_list = selected_feature_list+[allowed_operations]",
                    "name_html_page = hashlib.sha224(str(parameter_list)).hexdigest()[:16]",
                    "beaker.viewer_result_ZB_RS = name_html_page",
                    "with open(tmp_folder+'output.log', 'w') as f:",
1557
                    "    f.write(\"Descriptors: %s, %s \\nCoefficients: %s\\n RMSE: %s\\n Allowed operations: %s\\n\" ",
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573
                    "             %(x_axis_label, y_axis_label, coef, RMSE, allowed_operations))",
                    "",
                    "operated_structure_list = _get_structures(json_list=json_paths, file_format='NOMAD', frame_list=frame_list, tmp_folder=tmp_folder,",
                    "                                 operations_on_structure=operations_on_structure, op_list=op_list)",
                    "operated_structure_list = [nomad_structure for sublist in operated_structure_list for nomad_structure in sublist]",
                    "",
                    "# plot",
                    "viewer = Viewer(name=name_html_page)",
                    "file_html_link, file_html_name = viewer.plot(archive=operated_structure_list, frames='list',",
                    "                                             frame_list=frame_list, clustering_x_list=x_list, clustering_y_list=y_list,",
                    "                                             target_list=P.tolist(), target_pred_list=P_pred.tolist(),",
                    "                                             target_class_names=None,target_unit='eV',",
                    "                                             target_name=target_name, legend_title=legend_title,",
                    "                                             plot_convex_hull=False, is_classification=False,",
                    "                                             x_axis_label=x_axis_label, y_axis_label=y_axis_label, plot_title=plot_title,",
                    "                                             tmp_folder=tmp_folder)"
1574 1575
                ],
                "hidden": true
1576 1577 1578
            },
            "output": {
                "state": {},
1579
                "selectedType": "Results",
1580
                "pluginName": "IPython",
1581
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1582 1583 1584 1585
                "dataresult": [
                    "<a target=_blank href='/user/tmp/fc8a35bc76611011.html'>Click here to open the Viewer</a>",
                    "/home/beaker/.beaker/v1/web/tmp/fc8a35bc76611011.html"
                ],
1586
                "height": 0
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
            },
            "evaluatorReader": true,
            "lineCount": 45,
            "tags": "calc_cell"
        },
        {
            "id": "codepqAHnM",
            "type": "code",
            "evaluator": "JavaScript",
            "input": {
                "body": [
                    "var result_link = '/user/tmp/' + beaker.viewer_result_ZB_RS + '.html';",
                    "beaker.view_result(result_link);"
1600 1601
                ],
                "hidden": true
1602 1603 1604 1605 1606
            },
            "output": {
                "state": {},
                "selectedType": "BeakerDisplay",
                "pluginName": "JavaScript",
1607
                "height": 0
1608 1609
            },
            "evaluatorReader": true,
1610
            "lineCount": 2,
1611 1612 1613
            "tags": "calc_cell"
        },
        {
1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
            "id": "sectionI0mFHO",
            "type": "section",
            "title": "Predicting properties of new materials",
            "level": 1,
            "evaluatorReader": false,
            "collapsed": true
        },
        {
            "id": "markdownzajQdg",
            "type": "markdown",
            "body": [
                "<summary>",
                "<li>Perform a leave-one-out cross-validation (LOOCV) using the LASSO+$\\ell_0$ method.</li>",
                "<li>Analyze the prediction accuracy and how often the same descriptor is selected.</li>",
                "</summary>"
            ],
            "evaluatorReader": false
1631 1632 1633 1634 1635 1636 1637
        },
        {
            "id": "codeHbn2aL",
            "type": "code",
            "evaluator": "JavaScript",
            "input": {
                "body": [
1638 1639
                    "// 'Import' relevant functions from chapters before",
                    "var functions_list = [\"json_list\", \"nomad_structure_list\", \"get_energies\", \"get_energy_diffs\", \"get_descriptors\", \"get_data\", \"L0\", \"lasso_L0\"];",
1640 1641 1642 1643 1644 1645
                    "var n_functions = functions_list.length",
                    "var i;",
                    "for (i = 0; i < n_functions; i++) {",
                    "    beaker.evaluate(functions_list[i]);",
                    "    beaker.print('import '+functions_list[i]);",
                    "}"
1646
                ]
1647 1648 1649 1650 1651
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "JavaScript",
1652
                "height": 0
1653 1654
            },
            "evaluatorReader": true,
1655
            "lineCount": 8
1656 1657 1658 1659 1660
        },
        {
            "id": "markdownvfZJaN",
            "type": "markdown",
            "body": [
1661 1662 1663
                "We have seen that we can fit the energy differences of materials accurately. But what about predicting the energy difference of a 'new' material (which was not included when determining the model)? We test the prediction performance via LOOCV.  In a LOOCV for each material the following procedure is performed: the selected material is excluded, the model is built on the remaining materials and the model accurcy is tested on the left out material . This means that we need to run the LASSO+$l_0$ function 82 times. <br>",
                "Get the data in the next cell and run the LOOCV  one cell after. Note that running the LOOCV  could take up to ten minutes. Use the remaining two cells of this chapter to analyse the results.<br>",
                "How is the prediction error compared to the fitting error? How often is the same descriptor selected? Are there materials which had a outlying high/low error?"
1664 1665 1666 1667 1668 1669 1670 1671 1672 1673
            ],
            "evaluatorReader": false
        },
        {
            "id": "codeuKYRFo",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "#Import data",
1674
                    "selected_feature_list = ['atomic_ionization_potential', 'atomic_electron_affinity', 'atomic_rs_max', 'atomic_rp_max','atomic_rd_max']",
1675 1676 1677 1678 1679 1680 1681 1682
                    "allowed_operations = ['+','|-|','exp', '^2', '/']",
                    "P, D, feature_list, compounds_list, json_paths = get_data(selected_feature_list, allowed_operations)"
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
1683
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1684
                "height": 0
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
            },
            "evaluatorReader": true,
            "lineCount": 4
        },
        {
            "id": "codel2Xara",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "from collections import Counter",
                    "",
                    "def split_data(P, D, cv_i):",
                    "    P_1, P_test, P_2 = np.split(P, [cv_i, cv_i+1])",
                    "    P_train = np.concatenate((P_1,P_2))",
                    "    D_1, D_test, D_2 = np.split(D, [cv_i, cv_i+1])",
                    "    D_train = np.concatenate((D_1,D_2))",
                    "    D_test = np.column_stack( (D_test, np.ones(1)) )  ",
                    "    return P_train, P_test, D_train, D_test",
                    "",
                    "# Leave-one-out cross-validation",
                    "compounds = len(P)",
                    "dimensions = range(1,4)",
                    "features_count = [[] for i in range(3)]",
                    "P_predict = np.empty([len(dimensions),compounds])",
1710
                    "print \"####### The LOOCV could take up to 10 minutes #######\\n\"",
1711
                    "for cv_i in range(compounds):",
1712
                    "    print '%2s) Leave out %s: Ediff_ref = %s eV' %(cv_i+1, compounds_list[cv_i],P[cv_i])  ",
1713
                    "    P_train, P_test, D_train, D_test = split_data(P, D, cv_i)",
1714
                    "    out = lasso_L0(P_train, D_train, feature_list, print_lasso=False, lasso_number=20, print_model=True)",
1715 1716 1717 1718
                    "    ",
                    "    for dim in dimensions:",
                    "        indices_for_D, coef, RMSE = out[dim-1]        ",
                    "        features = [ feature_list[i] for i in indices_for_D]",
1719
                    "        predicted_val = np.dot(D_test[:, indices_for_D+[-1]], coef)[0]",
1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
                    "        ",
                    "        features_count[dim-1].append( tuple(features) )        ",
                    "        P_predict[dim-1,cv_i] = predicted_val",
                    "        ",
                    "        print 'Ediff_predicted(%sD) = %s eV' %(dim, predicted_val)",
                    "    print '-----'"
                ]
            },
            "output": {
                "state": {},
                "selectedType": "Results",
                "pluginName": "IPython",
1732
                "shellId": "2AE09B3957224934A1D62458982D7D68",
1733 1734
                "height": 0,
                "dataresult": "\nprint \"Descriptor selection frequency\"\nfor dim in dimensions:    \n    df = pd.DataFrame( Counter(features_count[dim-1]).most_common(10), columns=['Features', 'Frequency'] )\n    print '-----------------\n%sD:\n%s'%(dim,df)\n\n#Plot Prediction errors\nprediction_errors = np.linalg.norm(P-P_predict, axis=1)/np.sqrt(compounds)\nfor dim in dimensions:\n    predict = P_predict[dim-1]\n    if dim == 1:\n        maxi = max(max(P), max(predict))\n        mini = min(min(P), min(predict))\n        plt.plot([maxi,mini], [maxi,mini], 'k')\n    plt.scatter(P, predict, color=['b','r', 'g'][dim-1], label='%sD, RMSE = %.3f eV' %(dim,prediction_errors[dim-1]))\nplt.legend(loc='best')\nplt.show()\n"
1735 1736
            },
            "evaluatorReader": true,
1737
            "lineCount": 31
1738 1739 1740 1741 1742 1743 1744 1745
        },
        {
            "id": "codefvaq33",
            "type": "code",
            "evaluator": "IPython",
            "input": {
                "body": [
                    "#Plot Prediction e