diff --git a/LinearReg/01-Linear-Regression.ipynb b/LinearReg/01-Linear-Regression.ipynb index 607a88e26c68ee17e4701b575e8e8047192a16eb..bcab10d0dd0340661e347417b19cfc2e9f746ce7 100644 --- a/LinearReg/01-Linear-Regression.ipynb +++ b/LinearReg/01-Linear-Regression.ipynb @@ -15,7 +15,7 @@ "\n", "## What we're going to do :\n", "\n", - "Equation : $ Y = X.\\theta + N$ \n", + "Equation : $$Y = X.\\theta + N$$ \n", "Where N is a noise vector\n", "and $\\theta = (a,b)$ a vector as y = a.x + b" ] @@ -121,11 +121,11 @@ "We'll try to find an optimal value of $\\theta$, minimizing a cost function. \n", "The cost function, classically used in the case of linear regressions, is the **root mean square error** (racine carré de l'erreur quadratique moyenne): \n", "\n", - "$RMSE(X,h_\\theta)=\\sqrt{\\frac1n\\sum_{i=1}^n\\left[h_\\theta(X^{(i)})-Y^{(i)}\\right]^2}$ \n", + "$$RMSE(X,h_\\theta)=\\sqrt{\\frac1n\\sum_{i=1}^n\\left[h_\\theta(X^{(i)})-Y^{(i)}\\right]^2}$$\n", "\n", - "With the simplified variant : $MSE(X,h_\\theta)=\\frac1n\\sum_{i=1}^n\\left[h_\\theta(X^{(i)})-Y^{(i)}\\right]^2$\n", + "With the simplified variant : $$MSE(X,h_\\theta)=\\frac1n\\sum_{i=1}^n\\left[h_\\theta(X^{(i)})-Y^{(i)}\\right]^2$$\n", "\n", - "The optimal value of regression is : $ \\hat{ \\theta } =( X^{-T} .X)^{-1}.X^{-T}.Y$\n", + "The optimal value of regression is : $$\\hat{ \\theta } =( X^{-T} .X)^{-1}.X^{-T}.Y$$\n", "\n", "Démontstration : https://eli.thegreenplace.net/2014/derivation-of-the-normal-equation-for-linear-regression" ] diff --git a/fidle/02-running-ci-tests.ipynb b/fidle/02-running-ci-tests.ipynb index d4e0aba25f0e42780fb0825bcd7618b9a67506ba..592397c1453e379a8523c70b21f9b4d2b60d550f 100644 --- a/fidle/02-running-ci-tests.ipynb +++ b/fidle/02-running-ci-tests.ipynb @@ -116,48 +116,50 @@ "\n", "Run : Nb_LINR1\n", " Run notebook.....done.\n", - " Duration : 0:00:06\n", - "=> ../fidle/img/00-Fidle-header-01.svg\n", - "=> ../fidle/img/00-Fidle-logo-01.svg\n", - " Saved as : ./run/ci/01-Linear-Regression==ci==.ipynb\n", - " Saved as : ./run/ci/01-Linear-Regression==ci==.html\n", + " Duration : 0:00:05\n", + " Saved {output_name} as ipynb, html and pdf\n", "\n", "Run : Nb_GRAD1\n", " Run notebook.....done.\n", " Duration : 0:00:09\n", - "=> ../fidle/img/00-Fidle-header-01.svg\n", - "=> ../fidle/img/00-Fidle-logo-01.svg\n", - " Saved as : ./run/ci/02-Gradient-descent==ci==.ipynb\n", - " Saved as : ./run/ci/02-Gradient-descent==ci==.html\n", + " **Error during pdf convert...\n", + " Saved {output_name} as ipynb, html and pdf\n", "\n", "Run : Nb_POLR1\n", " Run notebook.....done.\n", " Duration : 0:00:06\n", - "=> ../fidle/img/00-Fidle-header-01.svg\n", - "=> ../fidle/img/00-Fidle-logo-01.svg\n", - " Saved as : ./run/ci/03-Polynomial-Regression==ci==.ipynb\n", - " Saved as : ./run/ci/03-Polynomial-Regression==ci==.html\n", + " **Error during pdf convert...\n", + " Saved {output_name} as ipynb, html and pdf\n", "\n", "Run : Nb_LOGR1\n", " Run notebook.....done.\n", " Duration : 0:00:06\n", - "=> ../fidle/img/00-Fidle-header-01.svg\n", - "=> ../fidle/img/00-Fidle-logo-01.svg\n", - " Saved as : ./run/ci/04-Logistic-Regression==ci==.ipynb\n", - " Saved as : ./run/ci/04-Logistic-Regression==ci==.html\n", + " **Error during pdf convert...\n", + " Saved {output_name} as ipynb, html and pdf\n", "\n", "Run : Nb_PER57\n", " Run notebook.....done.\n", " Duration : 0:00:05\n", - "=> ../fidle/img/00-Fidle-header-01.svg\n", - "=> ../fidle/img/00-Fidle-logo-01.svg\n", - " Saved as : ./run/ci/01-Simple-Perceptron==ci==.ipynb\n", - " Saved as : ./run/ci/01-Simple-Perceptron==ci==.html\n", + " Saved {output_name} as ipynb, html and pdf\n", "\n", "Run : Nb_BHPD1\n", " set overrides :\n", " FIDLE_OVERRIDE_BHPD1_fit_verbosity = 2\n", - " Run notebook..." + " Run notebook.....done.\n", + " Duration : 0:00:26\n", + " Saved {output_name} as ipynb, html and pdf\n", + "\n", + "Run : Nb_BHPD2\n", + " set overrides :\n", + " FIDLE_OVERRIDE_BHPD2_fit_verbosity = 2\n", + " Run notebook.....done.\n", + " Duration : 0:00:42\n", + " Saved {output_name} as ipynb, html and pdf\n", + "\n", + "End of running process\n", + " Duration : 0:02:03\n", + "\n", + "Complete ci report : /home/pjluc/dev/fidle/fidle/logs/ci_report.json\n" ] } ], @@ -167,11 +169,76 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "./run/ci\n", + "├── html\n", + "│  ├── BHPD\n", + "│  │  ├── 01-DNN-Regression==ci==.html\n", + "│  │  └── 02-DNN-Regression-Premium==ci==.html\n", + "│  ├── IRIS\n", + "│  │  └── 01-Simple-Perceptron==ci==.html\n", + "│  └── LinearReg\n", + "│  ├── 01-Linear-Regression==ci==.html\n", + "│  ├── 02-Gradient-descent==ci==.html\n", + "│  ├── 03-Polynomial-Regression==ci==.html\n", + "│  └── 04-Logistic-Regression==ci==.html\n", + "├── ipynb\n", + "│  ├── BHPD\n", + "│  │  ├── 01-DNN-Regression==ci==.ipynb\n", + "│  │  └── 02-DNN-Regression-Premium==ci==.ipynb\n", + "│  ├── IRIS\n", + "│  │  └── 01-Simple-Perceptron==ci==.ipynb\n", + "│  └── LinearReg\n", + "│  ├── 01-Linear-Regression==ci==.ipynb\n", + "│  ├── 02-Gradient-descent==ci==.ipynb\n", + "│  ├── 03-Polynomial-Regression==ci==.ipynb\n", + "│  └── 04-Logistic-Regression==ci==.ipynb\n", + "└── pdf\n", + " ├── BHPD\n", + " │  ├── 01-DNN-Regression==ci==.pdf\n", + " │  └── 02-DNN-Regression-Premium==ci==.pdf\n", + " ├── IRIS\n", + " │  └── 01-Simple-Perceptron==ci==.pdf\n", + " └── LinearReg\n", + " ├── 01-Linear-Regression==ci==.pdf\n", + " ├── 02-Gradient-descent==ci==.pdf\n", + " ├── 03-Polynomial-Regression==ci==.pdf\n", + " └── 04-Logistic-Regression==ci==.pdf\n", + "\n", + "12 directories, 21 files\n", + " 491718 768 -rw-r--r-- 1 pjluc pjluc 783282 Oct 25 22:21 ../fidle/run/ci/html/BHPD/01-DNN-Regression==ci==.html\n", + " 491660 760 -rw-r--r-- 1 pjluc pjluc 774460 Oct 25 22:22 ../fidle/run/ci/html/BHPD/02-DNN-Regression-Premium==ci==.html\n", + " 491710 680 -rw-r--r-- 1 pjluc pjluc 693754 Oct 25 22:21 ../fidle/run/ci/html/IRIS/01-Simple-Perceptron==ci==.html\n", + " 491690 648 -rw-r--r-- 1 pjluc pjluc 662112 Oct 25 22:20 ../fidle/run/ci/html/LinearReg/01-Linear-Regression==ci==.html\n", + " 491695 836 -rw-r--r-- 1 pjluc pjluc 854754 Oct 25 22:20 ../fidle/run/ci/html/LinearReg/02-Gradient-descent==ci==.html\n", + " 491702 708 -rw-r--r-- 1 pjluc pjluc 722111 Oct 25 22:21 ../fidle/run/ci/html/LinearReg/03-Polynomial-Regression==ci==.html\n", + " 491705 880 -rw-r--r-- 1 pjluc pjluc 900013 Oct 25 22:21 ../fidle/run/ci/html/LinearReg/04-Logistic-Regression==ci==.html\n", + " 491714 232 -rw-r--r-- 1 pjluc pjluc 234633 Oct 25 22:21 ../fidle/run/ci/ipynb/BHPD/01-DNN-Regression==ci==.ipynb\n", + " 138007 216 -rw-r--r-- 1 pjluc pjluc 217906 Oct 25 22:22 ../fidle/run/ci/ipynb/BHPD/02-DNN-Regression-Premium==ci==.ipynb\n", + " 491708 120 -rw-r--r-- 1 pjluc pjluc 121956 Oct 25 22:21 ../fidle/run/ci/ipynb/IRIS/01-Simple-Perceptron==ci==.ipynb\n", + " 491687 96 -rw-r--r-- 1 pjluc pjluc 94494 Oct 25 22:20 ../fidle/run/ci/ipynb/LinearReg/01-Linear-Regression==ci==.ipynb\n", + " 491694 288 -rw-r--r-- 1 pjluc pjluc 291917 Oct 25 22:20 ../fidle/run/ci/ipynb/LinearReg/02-Gradient-descent==ci==.ipynb\n", + " 491696 144 -rw-r--r-- 1 pjluc pjluc 145643 Oct 25 22:21 ../fidle/run/ci/ipynb/LinearReg/03-Polynomial-Regression==ci==.ipynb\n", + " 491704 300 -rw-r--r-- 1 pjluc pjluc 307021 Oct 25 22:21 ../fidle/run/ci/ipynb/LinearReg/04-Logistic-Regression==ci==.ipynb\n", + " 491721 120 -rw-r--r-- 1 pjluc pjluc 121007 Oct 25 22:21 ../fidle/run/ci/pdf/BHPD/01-DNN-Regression==ci==.pdf\n", + " 491677 124 -rw-r--r-- 1 pjluc pjluc 124238 Oct 25 22:22 ../fidle/run/ci/pdf/BHPD/02-DNN-Regression-Premium==ci==.pdf\n", + " 491712 84 -rw-r--r-- 1 pjluc pjluc 82133 Oct 25 22:21 ../fidle/run/ci/pdf/IRIS/01-Simple-Perceptron==ci==.pdf\n", + " 491693 76 -rw-r--r-- 1 pjluc pjluc 76374 Oct 25 22:20 ../fidle/run/ci/pdf/LinearReg/01-Linear-Regression==ci==.pdf\n", + " 491697 0 -rw-r--r-- 1 pjluc pjluc 0 Oct 25 22:20 ../fidle/run/ci/pdf/LinearReg/02-Gradient-descent==ci==.pdf\n", + " 491703 0 -rw-r--r-- 1 pjluc pjluc 0 Oct 25 22:21 ../fidle/run/ci/pdf/LinearReg/03-Polynomial-Regression==ci==.pdf\n", + " 491706 0 -rw-r--r-- 1 pjluc pjluc 0 Oct 25 22:21 ../fidle/run/ci/pdf/LinearReg/04-Logistic-Regression==ci==.pdf\n" + ] + } + ], "source": [ "%%bash\n", + "tree ./run/ci\n", "find .. -name \"*==ci==.*\" -ls | sort -k11\n", "# rm $(find .. -name \"*==ci==.ipynb\")\n", "# rm $(find .. -name \"*==ci==.html\")" @@ -185,65 +252,6 @@ "<img width=\"80px\" src=\"../fidle/img/00-Fidle-logo-01.svg\"></img>" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import base64\n", - "\n", - "def get_base64_image(file):\n", - "\n", - " with open(file, \"rb\") as image_file:\n", - " img64 = base64.b64encode(image_file.read())\n", - " src=\"data:image/svg+xml;base64,\"+img64.decode(\"utf-8\") \n", - " return src" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import re\n", - "s='qsdqd<img width=\"800px\" src=\"img/00-Fidle-header-01.svg\"></img>qsdqd'\n", - "\n", - "def get_base64_image(file):\n", - "\n", - " with open(file, \"rb\") as image_file:\n", - " img64 = base64.b64encode(image_file.read())\n", - " src=\"data:image/svg+xml;base64,\"+img64.decode(\"utf-8\") \n", - " return src\n", - "\n", - " \n", - "def img_embedder64(html):\n", - " '''\n", - " Images embedder. Search images src=\"...\" link and replace them\n", - " by base64 embedded images.\n", - " params:\n", - " html: input html\n", - " return:\n", - " output html\n", - " '''\n", - " for img_tag in re.findall('.*(<img .*>).*', html):\n", - " for src_tag in re.findall('.*src=[\\'\\\"](.*)[\\'\\\"].*', img_tag):\n", - " if src_tag.startswith('data:'): continue\n", - " src_b64 = get_base64_image(src_tag)\n", - " img_b64 = img_tag.replace(src_tag, src_b64)\n", - " html = html.replace(img_tag,img_b64)\n", - " return html\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "metadata": {}, diff --git a/fidle/cookci.py b/fidle/cookci.py index 0f3ed66f3b7918d6d82d02f03deab6a01ef7ab31..372d4fd4caa8db227857b831180f70344e3642b9 100644 --- a/fidle/cookci.py +++ b/fidle/cookci.py @@ -244,14 +244,18 @@ def run_profile(profile_name, report_name=None, error_name=None, top_dir='..'): exporter.template_name = 'classic' (body_html, resources_html) = exporter.from_notebook_node(notebook) - # Check for images to ember in html + # Check for images to embed in html # Hard job - better to do it in markdown # body_html = images_embedder(body_html) # ---- Convert to pdf # - exporter=PDFExporter() - (body_pdf, resources_pdf) = exporter.from_notebook_node(notebook) + try: + exporter=PDFExporter() + (body_pdf, resources_pdf) = exporter.from_notebook_node(notebook) + except: + print(" **Error during pdf convert...") + body_pdf=b'' # ---- Save notebook as ipynb # @@ -268,10 +272,10 @@ def run_profile(profile_name, report_name=None, error_name=None, top_dir='..'): # ---- Save notebook as html # os.makedirs(f'{output_dir}/pdf/{notebook_dir}', mode=0o750, exist_ok=True) - with open( f'{output_dir}/pdf/{notebook_dir}/{output_name}.pdf', mode='w') as f: + with open( f'{output_dir}/pdf/{notebook_dir}/{output_name}.pdf', mode='wb') as f: f.write(body_pdf) - print(' Saved {output_name} as ipynb, html and pdf') + print(f' Saved {output_name} as ipynb, html and pdf') # ---- Clean all ------------------------------------------------------ # diff --git a/fidle/logs/ci_report.json b/fidle/logs/ci_report.json index 5ba1137d6fcf0101d8897edff90124057b512eb3..f02004cc13c146f7f15b162835600b15bc7e4c36 100644 --- a/fidle/logs/ci_report.json +++ b/fidle/logs/ci_report.json @@ -8,18 +8,78 @@ "description": "Full run on a small cpu", "host": "Oban", "profile": "./ci/small_cpu.yml", - "start": "25/10/21 18:22:46", - "end": "Unfinished...", - "duration": "Unfinished..." + "start": "25/10/21 22:20:38", + "end": "25/10/21 22:22:42", + "duration": "0:02:03" }, "Nb_LINR1": { "id": "LINR1", "dir": "LinearReg", "src": "01-Linear-Regression.ipynb", "out": "01-Linear-Regression==ci==", - "start": "25/10/21 18:22:46", - "end": "25/10/21 18:22:52", + "start": "25/10/21 22:20:38", + "end": "25/10/21 22:20:44", + "duration": "0:00:05", + "state": "ok" + }, + "Nb_GRAD1": { + "id": "GRAD1", + "dir": "LinearReg", + "src": "02-Gradient-descent.ipynb", + "out": "02-Gradient-descent==ci==", + "start": "25/10/21 22:20:48", + "end": "25/10/21 22:20:57", + "duration": "0:00:09", + "state": "ok" + }, + "Nb_POLR1": { + "id": "POLR1", + "dir": "LinearReg", + "src": "03-Polynomial-Regression.ipynb", + "out": "03-Polynomial-Regression==ci==", + "start": "25/10/21 22:20:59", + "end": "25/10/21 22:21:06", + "duration": "0:00:06", + "state": "ok" + }, + "Nb_LOGR1": { + "id": "LOGR1", + "dir": "LinearReg", + "src": "04-Logistic-Regression.ipynb", + "out": "04-Logistic-Regression==ci==", + "start": "25/10/21 22:21:08", + "end": "25/10/21 22:21:14", "duration": "0:00:06", "state": "ok" + }, + "Nb_PER57": { + "id": "PER57", + "dir": "IRIS", + "src": "01-Simple-Perceptron.ipynb", + "out": "01-Simple-Perceptron==ci==", + "start": "25/10/21 22:21:16", + "end": "25/10/21 22:21:22", + "duration": "0:00:05", + "state": "ok" + }, + "Nb_BHPD1": { + "id": "BHPD1", + "dir": "BHPD", + "src": "01-DNN-Regression.ipynb", + "out": "01-DNN-Regression==ci==", + "start": "25/10/21 22:21:25", + "end": "25/10/21 22:21:52", + "duration": "0:00:26", + "state": "ok" + }, + "Nb_BHPD2": { + "id": "BHPD2", + "dir": "BHPD", + "src": "02-DNN-Regression-Premium.ipynb", + "out": "02-DNN-Regression-Premium==ci==", + "start": "25/10/21 22:21:56", + "end": "25/10/21 22:22:38", + "duration": "0:00:42", + "state": "ok" } } \ No newline at end of file