Update format to report

This commit is contained in:
2023-06-26 11:07:12 +02:00
parent 4b17cc2230
commit 6844d13973
4 changed files with 177 additions and 167 deletions

View File

@@ -3,6 +3,7 @@ import os
import json import json
import shutil import shutil
import xlsxwriter import xlsxwriter
from dotenv import dotenv_values
from benchmark.Utils import Files, Folders from benchmark.Utils import Files, Folders
from benchmark.Arguments import EnvData from benchmark.Arguments import EnvData
from benchmark.ResultsBase import StubReport from benchmark.ResultsBase import StubReport
@@ -99,7 +100,7 @@ def datasets(compare):
def showfile(file_name, compare, back=None): def showfile(file_name, compare, back=None):
compare = compare.capitalize() == "True" compare = compare.capitalize() == "True"
back = request.args["url"] if back is None else back back = request.args["url"] if back is None else back
print(f"back [{back}]") app_config = dotenv_values(".env")
with open(os.path.join(Folders.results, file_name)) as f: with open(os.path.join(Folders.results, file_name)) as f:
data = json.load(f) data = json.load(f)
try: try:
@@ -113,6 +114,7 @@ def showfile(file_name, compare, back=None):
summary=summary, summary=summary,
framework=current_app.config[FRAMEWORK], framework=current_app.config[FRAMEWORK],
back=back, back=back,
app_config=app_config,
) )

View File

@@ -1,28 +1,14 @@
{% for item in data.results %} {% for item in data.results %}
<tr> <tr>
<td> <td>{{ item.dataset }}</td>
{{item.dataset}} <td class="{{ right }}">{{ '{:,}'.format(item.samples) }}</td>
</td> <td class="{{ right }}">{{"%d" % item.features}}</td>
<td class="{{ right }}"> <td class="{{ right }}">{{"%d" % item.classes}}</td>
{{'{:,}'.format(item.samples)}} <td class="{{ right }}">{{ '{:,.2f}'.format(item.nodes|float) }}</td>
</td> <td class="{{ right }}">{{ '{:,.2f}'.format(item.leaves|float) }}</td>
<td class="{{ right }}"> <td class="{{ right }}">{{ '{:,.2f}'.format(item.depth|float) }}</td>
{{"%d" % item.features}} <td class="{{ right }}">{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}</td>
</td> <td class="{{ right }}">{{"%.6f±%.4f" % (item.time, item.time_std)}}</td>
<td class="{{ right }}"> <td class="{{ center }}">{{ item.hyperparameters }}</td>
{{"%d" % item.classes}}
</td>
<td class="{{ right }}">
{{'{:,.2f}'.format(item.nodes)}}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.time, item.time_std)}}
</td>
<td class="{{ center }}">
{{item.hyperparameters}}
</td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@@ -1,69 +1,77 @@
<div id="app"> <div id="app">
<section class="section"> <section class="section">
<div class="container-fluid"> <div class="container-fluid">
<div class="p-4 bg-primary text-white"> <div class="p-4 bg-primary text-white">
<button type="button" class="btn-close" aria-label="Close" onclick="location.href = '{{back}}'"></button> <button type="button"
<h1>{{ data.title }}</h1> class="btn-close"
</div> aria-label="Close"
<div> onclick="location.href = '{{ back }}'"></button>
<table class="table table-bordered"> <h1>{{ data.title }}</h1>
<thead> </div>
<tr class="bg-info text-white"> <div>
<th class="text-center">Platform</th> <table class="table table-bordered">
<th class="text-center">Model</th> <thead>
<th class="text-center">Date</th> <tr class="bg-info text-white">
<th class="text-center">Time</th> <th class="text-center">Platform</th>
{% if data.duration > 7200 %} <th class="text-center">Model</th>
<th class="text-center">Date</th>
<th class="text-center">Time</th>
{% if data.duration > 7200 %}
{% set unit = "h" %} {% set unit = "h" %}
{% set divider = 3600 %} {% set divider = 3600 %}
{% else %} {% else %}
{% set unit = "min" %} {% set unit = "min" %}
{% set divider = 60 %} {% set divider = 60 %}
{% endif %} {% endif %}
<th class="text-center">Duration ({{ unit }})</th> <th class="text-center">Duration ({{ unit }})</th>
<th class="text-center">Stratified</th> <th class="text-center">Stratified</th>
<th class="text-center">Discretized</th> <th class="text-center">Discretized</th>
<th class="text-center"># Folds</th> <th class="text-center"># Folds</th>
</tr> </tr>
<tr> <tr>
<th class="text-center">{{ data.platform }}</th> <th class="text-center">{{ data.platform }}</th>
<th class="text-center">{{ data.model }} {{ data.version }}</th> <th class="text-center">{{ data.model }} {{ data.version }}</th>
<th class="text-center">{{ data.date}}</th> <th class="text-center">{{ data.date }}</th>
<th class="text-center">{{ data.time}}</th> <th class="text-center">{{ data.time }}</th>
<th class="text-center">{{ "%.2f" % (data.duration/divider) }}</th> <th class="text-center">{{ "%.2f" % (data.duration/divider) }}</th>
<th class="text-center">{{ data.stratified }}</th> <th class="text-center">{{ data.stratified }}</th>
<th class="text-center">{{ data.discretized }}</th> <th class="text-center">{{ data.discretized }}</th>
<th class="text-center">{{ data.folds }}</th> <th class="text-center">{{ data.folds }}</th>
</tr> </tr>
<tr> <tr>
<th class="text-center bg-info text-white">Language</th> <th class="text-center bg-info text-white">Language</th>
<th class="text-center" colspan=3>{{ data.language }} {{ data.language_version }}</th> <th class="text-center" colspan=3>{{ data.language }} {{ data.language_version }}</th>
<th class="text-center bg-info text-white">Seeds</th> <th class="text-center bg-info text-white">Seeds</th>
<th class="text-center" colspan=6>{{ data.seeds }}</th> <th class="text-center" colspan=6>{{ data.seeds }}</th>
</tr> </tr>
</thead> </thead>
</table> </table>
<div> <div>
<button class="{{ button }}" onclick="excelFile()"><i class="mdi mdi-file-excel"></i> Excel</button> <button class="{{ button }}" onclick="excelFile()">
</div> <i class="mdi mdi-file-excel"></i> Excel
<table id="report-table" class="table table-striped table-hover table-bordered"> </button>
<thead> </div>
<tr class="bg-primary text-white"> <table id="report-table"
<th class="text-center">Dataset</th> class="table table-striped table-hover table-bordered">
<th class="text-center">Samples</th> <thead>
<th class="text-center">Features</th> <tr class="bg-primary text-white">
<th class="text-center">Classes</th> <th class="text-center">Dataset</th>
<th class="text-center">Nodes</th> <th class="text-center">Samples</th>
<th class="text-center">{{data.score_name|capitalize}}</th> <th class="text-center">Features</th>
<th class="text-center">Time</th> <th class="text-center">Classes</th>
<th class="text-center">hyperparameters</th> <th class="text-center">{{ app_config.nodes }}</th>
</tr> <th class="text-center">{{ app_config.leaves }}</th>
</thead> <th class="text-center">{{ app_config.depth }}</th>
<tbody> <th class="text-center">{{ data.score_name|capitalize }}</th>
<th class="text-center">Time</th>
<th class="text-center">hyperparameters</th>
</tr>
</thead>
<tbody>
{% include "partials/table_report.html" %} {% include "partials/table_report.html" %}
</tbody> </tbody>
</table> </table>
{% if summary|length > 0 %} {% if summary|length > 0 %}
<div class="col-4 col-lg-4"> <div class="col-4 col-lg-4">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
@@ -76,12 +84,19 @@
{% include "partials/table_summary.html" %} {% include "partials/table_summary.html" %}
</table> </table>
</div> </div>
{% endif %} {% endif %}
<button type="button" class="btn-close" aria-label="Close" onclick="location.href = '/index/{{ compare }}'"></button> <button type="button"
<h7><b> class="btn-close"
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} aria-label="Close"
</b></h7> onclick="location.href = '/index/{{ compare }}'"></button>
<h7>Number of files: {{ data.results | length }}</h7> <h7>
</div> <b>
Total score: {{ "%.6f" % (data.results | sum(attribute="score") ) }}
</b>
</h7>
<h7>
Number of files: {{ data.results | length }}
</h7>
</div>
</section> </section>
</div> </div>

View File

@@ -1,75 +1,80 @@
<div id="app"> <div id="app">
<header> <header>
<div class="container is-fluid"> <div class="container is-fluid">
<div class="hero is-info is-bold"> <div class="hero is-info is-bold">
<div class="hero-body"> <div class="hero-body">
<button class="delete is-large" onclick="location.href = '{{ back }}'"></button> <button class="delete is-large" onclick="location.href = '{{ back }}'"></button>
<h1 class="is-size-3">{{ data.title }}</h1> <h1 class="is-size-3">{{ data.title }}</h1>
</div>
</div> </div>
</div> </div>
</header> </div>
<section class="section"> </header>
<div class="container is-fluid"> <section class="section">
<div> <div class="container is-fluid">
<table class="table is-fullwidth is-striped is-bordered"> <div>
<thead> <table class="table is-fullwidth is-striped is-bordered">
<tr class="is-selected"> <thead>
<th class="has-text-centered">Platform</th> <tr class="is-selected">
<th class="has-text-centered">Model</th> <th class="has-text-centered">Platform</th>
<th class="has-text-centered">Date</th> <th class="has-text-centered">Model</th>
<th class="has-text-centered">Time</th> <th class="has-text-centered">Date</th>
{% if data.duration > 7200 %} <th class="has-text-centered">Time</th>
{% if data.duration > 7200 %}
{% set unit = "h" %} {% set unit = "h" %}
{% set divider = 3600 %} {% set divider = 3600 %}
{% else %} {% else %}
{% set unit = "min" %} {% set unit = "min" %}
{% set divider = 60 %} {% set divider = 60 %}
{% endif %} {% endif %}
<th class="has-text-centered">Duration ({{ unit }})</th> <th class="has-text-centered">Duration ({{ unit }})</th>
<th class="has-text-centered">Stratified</th> <th class="has-text-centered">Stratified</th>
<th class="has-text-centered">Discretized</th> <th class="has-text-centered">Discretized</th>
<th class="has-text-centered"># Folds</th> <th class="has-text-centered"># Folds</th>
</tr> </tr>
<tr> <tr>
<th class="has-text-centered">{{ data.platform }}</th> <th class="has-text-centered">{{ data.platform }}</th>
<th class="has-text-centered">{{ data.model }} {{ data.version }}</th> <th class="has-text-centered">{{ data.model }} {{ data.version }}</th>
<th class="has-text-centered">{{ data.date}}</th> <th class="has-text-centered">{{ data.date }}</th>
<th class="has-text-centered">{{ data.time}}</th> <th class="has-text-centered">{{ data.time }}</th>
<th class="has-text-centered">{{ "%.2f" % (data.duration/divider) }}</th> <th class="has-text-centered">{{ "%.2f" % (data.duration/divider) }}</th>
<th class="has-text-centered">{{ data.stratified }}</th> <th class="has-text-centered">{{ data.stratified }}</th>
<th class="has-text-centered">{{ data.discretized }}</th> <th class="has-text-centered">{{ data.discretized }}</th>
<th class="has-text-centered">{{ data.folds }}</th> <th class="has-text-centered">{{ data.folds }}</th>
</tr> </tr>
<tr> <tr>
<th class="has-text-center is-selected">Language</th> <th class="has-text-center is-selected">Language</th>
<th class="has-text-centered" colspan=3>{{ data.language }} {{ data.language_version }}</th> <th class="has-text-centered" colspan=3>{{ data.language }} {{ data.language_version }}</th>
<th class="has-text-centered is-selected">Seeds</th> <th class="has-text-centered is-selected">Seeds</th>
<th class="has-text-centered" colspan=6>{{ data.seeds }}</th> <th class="has-text-centered" colspan=6>{{ data.seeds }}</th>
</tr> </tr>
</thead> </thead>
</table> </table>
<div> <div>
<button class="{{ button }}" onclick="excelFile()"><i class="mdi mdi-file-excel"></i> Excel</button> <button class="{{ button }}" onclick="excelFile()">
</div> <i class="mdi mdi-file-excel"></i> Excel
<table id="report-table" class="table is-fullwidth is-striped is-hoverable is-bordered"> </button>
<thead> </div>
<tr class="is-selected"> <table id="report-table"
<th class="has-text-centered">Dataset</th> class="table is-fullwidth is-striped is-hoverable is-bordered">
<th class="has-text-centered">Samples</th> <thead>
<th class="has-text-centered">Features</th> <tr class="is-selected">
<th class="has-text-centered">Classes</th> <th class="has-text-centered">Dataset</th>
<th class="has-text-centered">Nodes</th> <th class="has-text-centered">Samples</th>
<th class="has-text-centered">{{data.score_name|capitalize}}</th> <th class="has-text-centered">Features</th>
<th class="has-text-centered">Time</th> <th class="has-text-centered">Classes</th>
<th class="has-text-centered">hyperparameters</th> <th class="has-text-centered">{{ app_config.nodes }}</th>
</tr> <th class="has-text-centered">{{ app_config.leaves }}</th>
</thead> <th class="has-text-centered">{{ app_config.depth }}</th>
<tbody> <th class="has-text-centered">{{ data.score_name|capitalize }}</th>
{% include "partials/table_report.html" %} <th class="has-text-centered">Time</th>
</tbody> <th class="has-text-centered">hyperparameters</th>
</table> </tr>
{% if summary|length > 0 %} </thead>
<tbody>
{% include "partials/table_report.html" %}
</tbody>
</table>
{% if summary|length > 0 %}
<div class="col-2 col-lg-2"> <div class="col-2 col-lg-2">
<table class="table is-bordered"> <table class="table is-bordered">
<thead> <thead>
@@ -82,12 +87,14 @@
{% include "partials/table_summary.html" %} {% include "partials/table_summary.html" %}
</table> </table>
</div> </div>
{% endif %} {% endif %}
<h2 class="has-text-white has-background-primary"><b> <h2 class="has-text-white has-background-primary">
<button class="delete" onclick="location.href = '/index/{{ compare }}'"></button> <b>
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} <button class="delete" onclick="location.href = '/index/{{ compare }}'"></button>
</b></h2> Total score: {{ "%.6f" % (data.results | sum(attribute="score") ) }}
<h2>Number of files: {{ data.results | length }}</h2> </b>
</div> </h2>
<h2>Number of files: {{ data.results | length }}</h2>
</div>
</section> </section>
</div> </div>