mirror of
https://github.com/Doctorado-ML/benchmark.git
synced 2025-08-16 07:55:54 +00:00
Add title and score to select page
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor)
|
PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from benchmark.Utils import Files, Folders, Symbols
|
from benchmark.Utils import Files, Folders
|
||||||
from benchmark.Arguments import Arguments, EnvData
|
from benchmark.Arguments import Arguments, EnvData
|
||||||
from benchmark.ResultsBase import StubReport
|
from benchmark.ResultsBase import StubReport
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
@@ -13,7 +13,6 @@ from flask import render_template, request, redirect, url_for
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
FRAMEWORK = "framework"
|
FRAMEWORK = "framework"
|
||||||
FRAMEWORKS = "frameworks"
|
FRAMEWORKS = "frameworks"
|
||||||
HIDDEN = "hidden"
|
|
||||||
|
|
||||||
|
|
||||||
def process_data(file_name, data):
|
def process_data(file_name, data):
|
||||||
@@ -35,14 +34,23 @@ def process_data(file_name, data):
|
|||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
# Get a list of files in a directory
|
# Get a list of files in a directory
|
||||||
files = Files.get_all_results(hidden=app.config[HIDDEN])
|
files = {}
|
||||||
|
names = Files.get_all_results(hidden=False)
|
||||||
|
for name in names:
|
||||||
|
report = StubReport(os.path.join(Folders.results, name))
|
||||||
|
report.report()
|
||||||
|
files[name] = {
|
||||||
|
"duration": report.duration,
|
||||||
|
"score": report.score,
|
||||||
|
"title": report.title,
|
||||||
|
}
|
||||||
candidate = app.config[FRAMEWORKS].copy()
|
candidate = app.config[FRAMEWORKS].copy()
|
||||||
candidate.remove(app.config[FRAMEWORK])
|
candidate.remove(app.config[FRAMEWORK])
|
||||||
return render_template(
|
return render_template(
|
||||||
f"select.html",
|
"select.html",
|
||||||
files=files,
|
files=files,
|
||||||
framework=candidate[0],
|
candidate=candidate[0],
|
||||||
used_framework=app.config[FRAMEWORK],
|
framework=app.config[FRAMEWORK],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,10 +61,10 @@ def show():
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
summary = process_data(selected_file, data)
|
summary = process_data(selected_file, data)
|
||||||
return render_template(
|
return render_template(
|
||||||
f"report.html",
|
"report.html",
|
||||||
data=data,
|
data=data,
|
||||||
summary=summary,
|
summary=summary,
|
||||||
used_framework=app.config[FRAMEWORK],
|
framework=app.config[FRAMEWORK],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -74,13 +82,13 @@ def config(framework):
|
|||||||
|
|
||||||
|
|
||||||
def main(args_test=None):
|
def main(args_test=None):
|
||||||
arguments = Arguments(prog="be_flask")
|
# arguments = Arguments(prog="be_flask")
|
||||||
arguments.xset("model", required=False)
|
# arguments.xset("model", required=False)
|
||||||
arguments.xset("score", required=False).xset("compare").xset("hidden")
|
# arguments.xset("score", required=False).xset("compare")
|
||||||
arguments.xset("nan")
|
# arguments.xset("nan")
|
||||||
args = arguments.parse(args_test)
|
# args = arguments.parse(args_test)
|
||||||
app.config[FRAMEWORK] = EnvData().load()[FRAMEWORK]
|
config = EnvData().load()
|
||||||
app.config[HIDDEN] = args.hidden
|
app.config[FRAMEWORK] = config[FRAMEWORK]
|
||||||
app.config[FRAMEWORKS] = ["bootstrap", "bulma"]
|
app.config[FRAMEWORKS] = ["bootstrap", "bulma"]
|
||||||
webbrowser.open_new("http://127.0.0.1:1234/")
|
webbrowser.open_new("http://127.0.0.1:1234/")
|
||||||
app.run(port=1234)
|
app.run(port=1234)
|
||||||
|
40
benchmark/scripts/templates/base.html
Normal file
40
benchmark/scripts/templates/base.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ title }}</title>
|
||||||
|
{% if framework == "bootstrap" %}
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Courier;
|
||||||
|
}
|
||||||
|
#file-table tbody tr.selected td{
|
||||||
|
background-color: #0dcaf0;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% else %}
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Courier;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endif %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
{% if framework == "bootstrap" %}
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
{% endif %}
|
||||||
|
</html>
|
@@ -1,25 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>{{ title }}</title>
|
|
||||||
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
||||||
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Courier;
|
|
||||||
}
|
|
||||||
#file-table tbody tr.selected td{
|
|
||||||
background-color: #0dcaf0;
|
|
||||||
color:white;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% block content %}
|
|
||||||
{% endblock %}
|
|
||||||
</body>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
</html>
|
|
@@ -1,21 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>{{ title }}</title>
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
|
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Courier;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% block content %}
|
|
||||||
{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@@ -6,8 +6,9 @@
|
|||||||
"ordering": true,
|
"ordering": true,
|
||||||
"info": true,
|
"info": true,
|
||||||
"select.items": "row",
|
"select.items": "row",
|
||||||
|
"pageLength": 25,
|
||||||
"columnDefs": [{
|
"columnDefs": [{
|
||||||
"targets": 6,
|
"targets": 8,
|
||||||
"orderable": false
|
"orderable": false
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
{% for item in data.results %}
|
{% for item in data.results %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{item.dataset}}
|
{{item.dataset}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{'{:,}'.format(item.samples)}}
|
{{'{:,}'.format(item.samples)}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{"%d" % item.features}}
|
{{"%d" % item.features}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{"%d" % item.classes}}
|
{{"%d" % item.classes}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{'{:,.2f}'.format(item.nodes)}}
|
{{'{:,.2f}'.format(item.nodes)}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}
|
{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ right }}">
|
<td class="{{ right }}">
|
||||||
{{"%.6f±%.4f" % (item.time, item.time_std)}}
|
{{"%.6f±%.4f" % (item.time, item.time_std)}}
|
||||||
</td>
|
</td>
|
||||||
<td class="{{ center }}">
|
<td class="{{ center }}">
|
||||||
{{item.hyperparameters}}
|
{{item.hyperparameters}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
@@ -78,6 +78,7 @@
|
|||||||
<h7><b>
|
<h7><b>
|
||||||
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
|
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
|
||||||
</b></h7>
|
</b></h7>
|
||||||
|
<h7>Number of files: {{ data.results | length }}</h7>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
@@ -84,6 +84,7 @@
|
|||||||
<button class="delete" onclick="location.href='/index';"></button>
|
<button class="delete" onclick="location.href='/index';"></button>
|
||||||
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
|
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
|
||||||
</b></h2>
|
</b></h2>
|
||||||
|
<h2>Number of files: {{ data.results | length }}</h2>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
@@ -7,24 +7,28 @@
|
|||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Time</th>
|
<th>Time</th>
|
||||||
<th>Stratified</th>
|
<th>Stratified</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Score</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for file in files %}
|
{% for file, data in files.items() %}
|
||||||
{% set parts = file.split('_') %}
|
{% set parts = file.split('_') %}
|
||||||
{% set stratified = parts[6].split('.')[0] %}
|
{% set stratified = parts[6].split('.')[0] %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ parts[2] }}</td>
|
<td>{{ parts[2] }}</td>
|
||||||
<td>{{ parts[1] }}</td>
|
<td>{{ parts[1] }}</td>
|
||||||
<td>{{ parts[3] }}</td>
|
<td>{{ parts[3] }}</td>
|
||||||
<td>{{ parts[4] }}</td>
|
<td>{{ parts[4] }}</td>
|
||||||
<td>{{ parts[5] }}</td>
|
<td>{{ parts[5] }}</td>
|
||||||
<td>{{ 'True' if stratified =='1' else 'False' }}</td>
|
<td>{{ 'True' if stratified =='1' else 'False' }}</td>
|
||||||
<td>
|
<td>{{ "%s" % data["title"] }}</td>
|
||||||
{{ button_pre | safe }}{{ file }}{{ button_post | safe }}
|
<td>{{ "%.6f" % data["score"] }}</td>
|
||||||
</td>
|
<td>
|
||||||
</tr>
|
{{ button_pre | safe }}{{ file }}{{ button_post | safe }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
@@ -1,8 +1,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="{{ h1_class }}"><b>Benchmark Results</b></h1>
|
<h1 class="{{ h1_class }}"><b>Benchmark Results</b></h1>
|
||||||
<button class="{{ button_class }}" onclick="location.href='/config/{{ framework }}';">Use {{ framework
|
<button class="{{ button_class }}" onclick="location.href='/config/{{ candidate }}';">Use {{ candidate
|
||||||
}}</button>
|
}}</button>
|
||||||
|
|
||||||
{% include "partials/table_select.html" %}
|
{% include "partials/table_select.html" %}
|
||||||
</div>
|
</div>
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
{% set title = "Report Viewer" %}
|
{% set title = "Report Viewer" %}
|
||||||
{% if used_framework == "bootstrap" %}
|
{% extends "base.html" %}
|
||||||
{% extends "base_bootstrap.html" %}
|
|
||||||
{% else %}
|
|
||||||
{% extends "base_bulma.html" %}
|
|
||||||
{% endif%}
|
|
||||||
{% block content%}
|
{% block content%}
|
||||||
{% if used_framework == "bootstrap" %}
|
{% if framework == "bootstrap" %}
|
||||||
{% set center = "text-center" %}
|
{% set center = "text-center" %}
|
||||||
{% set right = "text-end" %}
|
{% set right = "text-end" %}
|
||||||
{% include "partials/table_report_bootstrap.html" %}
|
{% include "partials/table_report_bootstrap.html" %}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{% set title = "Benchmark Results" %}
|
{% set title = "Benchmark Results" %}
|
||||||
{% if used_framework == "bootstrap" %}
|
{% extends "base.html" %}
|
||||||
{% extends "base_bootstrap.html" %}
|
{% if framework == "bootstrap" %}
|
||||||
{% set button_class = "btn btn-primary bt-sm" %}
|
{% set button_class = "btn btn-primary bt-sm" %}
|
||||||
{% set h1_class = "text-center" %}
|
{% set h1_class = "text-center" %}
|
||||||
{% set table_class = "table table-striped table-hover" %}
|
{% set table_class = "table table-striped table-hover" %}
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
onclick="showFile(\''%}
|
onclick="showFile(\''%}
|
||||||
{% set button_post = '\')">View</button>' %}
|
{% set button_post = '\')">View</button>' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% extends "base_bulma.html" %}
|
|
||||||
{% set button_class = "button is-primary is-small" %}
|
{% set button_class = "button is-primary is-small" %}
|
||||||
{% set h1_class = "title is-1 has-text-centered" %}
|
{% set h1_class = "title is-1 has-text-centered" %}
|
||||||
{% set table_class = "table is-striped is-hoverable cell-border" %}
|
{% set table_class = "table is-striped is-hoverable cell-border" %}
|
||||||
|
Reference in New Issue
Block a user