mirror of
https://github.com/Doctorado-ML/benchmark.git
synced 2025-08-16 07:55:54 +00:00
Begin best results report
This commit is contained in:
@@ -14,4 +14,6 @@ def create_app():
|
|||||||
app.register_blueprint(main)
|
app.register_blueprint(main)
|
||||||
app.config[FRAMEWORK] = config[FRAMEWORK]
|
app.config[FRAMEWORK] = config[FRAMEWORK]
|
||||||
app.config[FRAMEWORKS] = ["bootstrap", "bulma"]
|
app.config[FRAMEWORKS] = ["bootstrap", "bulma"]
|
||||||
|
app.jinja_env.auto_reload = True
|
||||||
|
app.config["TEMPLATES_AUTO_RELOAD"] = True
|
||||||
return app
|
return app
|
||||||
|
@@ -91,9 +91,12 @@ def datasets(compare):
|
|||||||
framework=current_app.config[FRAMEWORK],
|
framework=current_app.config[FRAMEWORK],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/showfile/<file_name>/<compare>")
|
@main.route("/showfile/<file_name>/<compare>")
|
||||||
def showfile(file_name, compare):
|
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
|
||||||
|
print(f"back [{back}]")
|
||||||
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:
|
||||||
@@ -106,15 +109,19 @@ def showfile(file_name, compare):
|
|||||||
file=file_name,
|
file=file_name,
|
||||||
summary=summary,
|
summary=summary,
|
||||||
framework=current_app.config[FRAMEWORK],
|
framework=current_app.config[FRAMEWORK],
|
||||||
compare=compare,
|
back=back,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/show", methods=["post"])
|
@main.route("/show", methods=["post"])
|
||||||
def show():
|
def show():
|
||||||
selected_file = request.form["selected-file"]
|
selected_file = request.form["selected-file"]
|
||||||
compare = request.form["compare"]
|
compare = request.form["compare"]
|
||||||
return showfile(selected_file, compare)
|
return showfile(
|
||||||
|
file_name=selected_file,
|
||||||
|
compare=compare,
|
||||||
|
back=url_for("main.index", compare=compare),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/excel", methods=["post"])
|
@main.route("/excel", methods=["post"])
|
||||||
@@ -167,3 +174,13 @@ def config(framework, compare):
|
|||||||
current_app.config[FRAMEWORK] = framework
|
current_app.config[FRAMEWORK] = framework
|
||||||
return redirect(url_for("main.index", compare=compare))
|
return redirect(url_for("main.index", compare=compare))
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/best_results/<file>/<compare>")
|
||||||
|
def best_results(file, compare):
|
||||||
|
compare = compare.capitalize() == "True"
|
||||||
|
try:
|
||||||
|
with open(os.path.join(Folders.results, file)) as f:
|
||||||
|
data = json.load(f)
|
||||||
|
except Exception as e:
|
||||||
|
return render_template("error.html", message=str(e), compare=compare)
|
||||||
|
return render_template("report_best.html", data=data, compare=compare)
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
{%- macro get_table_class() -%}
|
{%- macro get_table_class() -%}
|
||||||
table table-striped table-hover table-bordered
|
table table-striped table-hover table-bordered
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro icon(icon) -%}
|
{%- macro icon(icon_name) -%}
|
||||||
<i class="mdi mdi-{{icon}}"></i>
|
<i class="mdi mdi-{{icon_name}}"></i>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro get_button(text, action) -%}
|
{%- macro get_button(text, action) -%}
|
||||||
<button class="btn btn-primary btn-small" onclick="{{ action }}">{{ text|safe }}</button>
|
<button class="btn btn-primary btn-small" onclick="{{ action }}">{{ text|safe }}</button>
|
||||||
@@ -15,8 +15,8 @@ table table-striped table-hover table-bordered
|
|||||||
{%- macro get_button_class() -%}
|
{%- macro get_button_class() -%}
|
||||||
button btn-primary btn-small
|
button btn-primary btn-small
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
{%- macro get_button_view(file) -%}
|
{%- macro get_button_tag(icon_name, method, visible=True, name="") -%}
|
||||||
<button class="btn btn-primary btn-small" onclick="showFile('{{ file }}')"><i class="mdi mdi-eye"></i></button>
|
<button class="btn btn-primary btn-small" onclick="{{ method }}" {{ "" if visible else "hidden='true'" }} {{ "" if name=="" else "name='" + name +"'"}}><i class="mdi mdi-{{ icon_name }}"></i></button>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro get_button_reset() -%}
|
{%- macro get_button_reset() -%}
|
||||||
<button class="btn btn-primary btn-small btn-danger" onclick="setCheckBoxes(false)"><i class="mdi mdi-checkbox-multiple-blank"></i></button>
|
<button class="btn btn-primary btn-small btn-danger" onclick="setCheckBoxes(false)"><i class="mdi mdi-checkbox-multiple-blank"></i></button>
|
||||||
|
@@ -8,14 +8,14 @@
|
|||||||
{%- macro get_table_class() -%}
|
{%- macro get_table_class() -%}
|
||||||
table is-striped is-hoverable cell-border is-bordered
|
table is-striped is-hoverable cell-border is-bordered
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro icon(icon) -%}
|
{%- macro icon(icon_name) -%}
|
||||||
<i class="mdi mdi-{{icon}}"></i>
|
<i class="mdi mdi-{{icon_name}}"></i>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro get_button(text, action) -%}
|
{%- macro get_button(text, action) -%}
|
||||||
<button class="button is-primary is-small" onclick="{{ action }}">{{ text|safe }}</button>
|
<button class="button is-primary is-small" onclick="{{ action }}">{{ text|safe }}</button>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro get_button_view(file) -%}
|
{%- macro get_button_tag(icon_name, method, visible=True, name="") -%}
|
||||||
<span class="tag is-link is-normal" type="button" onclick="showFile('{{ file }}')"><i class="mdi mdi-eye"></i></span>
|
<span class="{{ "tag is-link is-normal" if visible else "" }}" type="button" onclick="{{ method }}" {{ "" if visible else "hidden='true'" }} {{ "" if name=="" else "name='" + name +"'"}}>{{icon(icon_name)}}</span>
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro get_button_reset() -%}
|
{%- macro get_button_reset() -%}
|
||||||
<span class="tag is-link is-danger" type="button" onclick="setCheckBoxes(false)"><i class="mdi mdi-checkbox-multiple-blank"></i></span>
|
<span class="tag is-link is-danger" type="button" onclick="setCheckBoxes(false)"><i class="mdi mdi-checkbox-multiple-blank"></i></span>
|
||||||
|
@@ -1,71 +1,97 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var table = $('#file-table').DataTable({
|
var table = $("#file-table").DataTable({
|
||||||
"paging": true,
|
paging: true,
|
||||||
"searching": true,
|
searching: true,
|
||||||
"ordering": true,
|
ordering: true,
|
||||||
"info": true,
|
info: true,
|
||||||
"select.items": "row",
|
"select.items": "row",
|
||||||
"pageLength": 25,
|
pageLength: 25,
|
||||||
"columnDefs": [{
|
columnDefs: [
|
||||||
"targets": 8,
|
{
|
||||||
"orderable": false
|
targets: 8,
|
||||||
}],
|
orderable: false,
|
||||||
//"language": {
|
},
|
||||||
// "lengthMenu": "_MENU_"
|
],
|
||||||
//}
|
//"language": {
|
||||||
});
|
// "lengthMenu": "_MENU_"
|
||||||
// Check if row is selected
|
//}
|
||||||
$('#file-table tbody').on('click', 'tr', function () {
|
});
|
||||||
if ($(this).hasClass('{{ select.selected() }}')) {
|
// Check if row is selected
|
||||||
$(this).removeClass('{{ select.selected() }}');
|
$("#file-table tbody").on("click", "tr", function () {
|
||||||
} else {
|
if ($(this).hasClass("{{ select.selected() }}")) {
|
||||||
table.$('tr.{{ select.selected() }}').removeClass('{{ select.selected() }}');
|
$(this).removeClass("{{ select.selected() }}");
|
||||||
$(this).addClass('{{ select.selected() }}');
|
} else {
|
||||||
}
|
table
|
||||||
});
|
.$("tr.{{ select.selected() }}")
|
||||||
// Show file with doubleclick
|
.removeClass("{{ select.selected() }}");
|
||||||
$('#file-table tbody').on('dblclick', 'tr', function () {
|
$(this).addClass("{{ select.selected() }}");
|
||||||
showFile($(this).attr("id"));
|
}
|
||||||
});
|
});
|
||||||
$(document).ajaxStart(function(){
|
// Show file with doubleclick
|
||||||
$("body").addClass('ajaxLoading');
|
$("#file-table tbody").on("dblclick", "tr", function () {
|
||||||
});
|
showFile($(this).attr("id"));
|
||||||
$(document).ajaxStop(function(){
|
});
|
||||||
$("body").removeClass('ajaxLoading');
|
$(document).ajaxStart(function () {
|
||||||
});
|
$("body").addClass("ajaxLoading");
|
||||||
|
});
|
||||||
|
$(document).ajaxStop(function () {
|
||||||
|
$("body").removeClass("ajaxLoading");
|
||||||
|
});
|
||||||
|
$('#compare').change(function() {
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
$("[name='best_buttons']").removeAttr("hidden");
|
||||||
|
$("[name='best_buttons']").addClass("tag is-link is-normal");
|
||||||
|
} else {
|
||||||
|
$("[name='best_buttons']").attr("hidden", true);
|
||||||
|
$("[name='best_buttons']").removeClass("tag is-link is-normal");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($('#compare').is(':checked')) {
|
||||||
|
$("[name='best_buttons']").removeAttr("hidden");
|
||||||
|
$("[name='best_buttons']").addClass("tag is-link is-normal");
|
||||||
|
} else {
|
||||||
|
$("[name='best_buttons']").attr("hidden", true);
|
||||||
|
$("[name='best_buttons']").removeClass("tag is-link is-normal");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
function showFile(selectedFile) {
|
function showFile(selectedFile) {
|
||||||
var form = $('<form action="/show" method="post">' +
|
var form = $(
|
||||||
'<input type="hidden" name="selected-file" value="' + selectedFile + '" />' +
|
'<form action="/show" method="post">' +
|
||||||
'<input type="hidden" name="compare" value='+$("#compare").is(':checked')+' />' +
|
'<input type="hidden" name="selected-file" value="' +
|
||||||
'</form>');
|
selectedFile +
|
||||||
$('body').append(form);
|
'" />' +
|
||||||
form.submit();
|
'<input type="hidden" name="compare" value=' +
|
||||||
|
$("#compare").is(":checked") +
|
||||||
|
" />" +
|
||||||
|
"</form>"
|
||||||
|
);
|
||||||
|
$("body").append(form);
|
||||||
|
form.submit();
|
||||||
}
|
}
|
||||||
function excel() {
|
function excel() {
|
||||||
var checkbox = document.getElementsByName("selected_files");
|
var checkbox = document.getElementsByName("selected_files");
|
||||||
var selectedFiles = [];
|
var selectedFiles = [];
|
||||||
for (var i = 0; i < checkbox.length; i++) {
|
for (var i = 0; i < checkbox.length; i++) {
|
||||||
if (checkbox[i].checked) {
|
if (checkbox[i].checked) {
|
||||||
selectedFiles.push(checkbox[i].value);
|
selectedFiles.push(checkbox[i].value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (selectedFiles.length == 0) {
|
}
|
||||||
alert("Select at least one file");
|
if (selectedFiles.length == 0) {
|
||||||
return;
|
alert("Select at least one file");
|
||||||
}
|
return;
|
||||||
var compare = $("#compare").is(':checked');
|
}
|
||||||
excelFiles(selectedFiles, compare);
|
var compare = $("#compare").is(":checked");
|
||||||
|
excelFiles(selectedFiles, compare);
|
||||||
}
|
}
|
||||||
function setCheckBoxes(value) {
|
function setCheckBoxes(value) {
|
||||||
var checkbox = document.getElementsByName("selected_files");
|
var checkbox = document.getElementsByName("selected_files");
|
||||||
for (i = 0; i < checkbox.length; i++) {
|
for (i = 0; i < checkbox.length; i++) {
|
||||||
checkbox[i].checked=value;
|
checkbox[i].checked = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function redirectIndex(candidate){
|
function redirectDouble(route, parameter) {
|
||||||
location.href="/config/"+ candidate + "/" + $("#compare").is(':checked');
|
location.href = "/"+ route + "/" + parameter + "/" + $("#compare").is(":checked");
|
||||||
|
}
|
||||||
|
function redirectSimple(route) {
|
||||||
|
location.href = "/" + route + "/" + $("#compare").is(":checked");
|
||||||
}
|
}
|
||||||
function redirectDatasets(){
|
|
||||||
location.href="/datasets/" + $("#compare").is(':checked');
|
|
||||||
}
|
|
@@ -2,7 +2,7 @@
|
|||||||
<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 = '/index/{{ compare }}'"></button>
|
<button type="button" class="btn-close" aria-label="Close" onclick="location.href = '{{back}}'"></button>
|
||||||
<h1>{{ data.title }}</h1>
|
<h1>{{ data.title }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<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 = '/index/{{ compare }}'"></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>
|
||||||
|
@@ -26,7 +26,9 @@
|
|||||||
<td>{{ "%s" % data["title"] }}</td>
|
<td>{{ "%s" % data["title"] }}</td>
|
||||||
<td class="{{ select.get_align_right() }}">{{ "%.6f" % data["score"] }}</td>
|
<td class="{{ select.get_align_right() }}">{{ "%.6f" % data["score"] }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ select.get_button_view(file) | safe }}
|
{{ select.get_button_tag("eye", "showFile('" ~ file ~ "')") | safe }}
|
||||||
|
{% set file_best = "best_results_" ~ parts[1] ~ "_" ~ parts[2] ~ ".json" %}
|
||||||
|
{{ select.get_button_tag("star-circle-outline", "redirectDouble('best_results', '" ~ file_best ~ "')", visible=False, name="best_buttons") | safe }}
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
name="selected_files"
|
name="selected_files"
|
||||||
|
@@ -2,12 +2,11 @@
|
|||||||
{{ select.header("Benchmark Results") }}
|
{{ select.header("Benchmark Results") }}
|
||||||
<div class="{{ select.get_level_class() }}">
|
<div class="{{ select.get_level_class() }}">
|
||||||
<div class="{{ select.get_left_position() }}">
|
<div class="{{ select.get_left_position() }}">
|
||||||
{{ select.get_button("Use " ~ candidate, "redirectIndex('" ~ candidate ~ "')")|safe }}
|
{{ select.get_button("Use " ~ candidate, "redirectDouble('config', '" ~ candidate ~ "')")|safe }}
|
||||||
{{ select.get_button(select.icon("excel") ~ " Excel", "excel()")|safe }}
|
{{ select.get_button(select.icon("excel") ~ " Excel", "excel()")|safe }}
|
||||||
{{ select.get_button(select.icon("database-eye") ~ " Datasets", "redirectDatasets()")|safe }}
|
{{ select.get_button(select.icon("database-eye") ~ " Datasets", "redirectSimple('datasets')")|safe }}
|
||||||
{{ select.get_button(select.icon("star-circle-outline") ~ " Best results", "{{ url_for('best_results')}}")}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class={{ select.get_right_position }}>
|
<div class="{{ select.get_right_position() }}">
|
||||||
<input type="checkbox" id="compare" name="compare" {% if compare %} {{ "checked" }} {% endif %}>
|
<input type="checkbox" id="compare" name="compare" {% if compare %} {{ "checked" }} {% endif %}>
|
||||||
<span class="{{ select.get_tag_class() }}">Comparing with best results</span>
|
<span class="{{ select.get_tag_class() }}">Comparing with best results</span>
|
||||||
</div>
|
</div>
|
||||||
|
23
benchmark/scripts/app/templates/report_best.html
Normal file
23
benchmark/scripts/app/templates/report_best.html
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Dataset</th>
|
||||||
|
<th>Score</th>
|
||||||
|
<th>Hyperparameters</th>
|
||||||
|
<th>File</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for dataset, info in data.items() %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ dataset }}</td>
|
||||||
|
<td>{{ '%9.7f' % info[0] }}</td>
|
||||||
|
<td>{{ info[1] }}</td>
|
||||||
|
<td>
|
||||||
|
{% set url = url_for(request.endpoint, **request.view_args)|urlencode %}
|
||||||
|
<a href="{{ url_for('main.showfile', file_name = info[2], compare = compare) }}?url={{ url }}">{{ info[2] }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
Reference in New Issue
Block a user