From 219b6260618343bb316b6466a7d0cef581fd66bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 00:04:30 +0200 Subject: [PATCH 01/34] Add flask templates --- benchmark/Arguments.py | 18 ++- benchmark/Datasets.py | 2 +- benchmark/Experiments.py | 4 +- benchmark/Results.py | 1 - benchmark/ResultsBase.py | 6 +- benchmark/ResultsFiles.py | 2 +- benchmark/Utils.py | 5 +- benchmark/scripts/be_flask.py | 85 ++++++++++++++ benchmark/scripts/templates/error.html | 23 ++++ .../templates/partials/table_report.html | 28 +++++ .../templates/partials/table_select.html | 30 +++++ .../templates/partials/table_summary.html | 13 +++ .../scripts/templates/report_bootstrap.html | 105 +++++++++++++++++ benchmark/scripts/templates/report_bulma.html | 110 ++++++++++++++++++ .../scripts/templates/select_bootstrap.html | 69 +++++++++++ benchmark/scripts/templates/select_bulma.html | 63 ++++++++++ benchmark/tests/Util_test.py | 8 +- setup.py | 1 + 18 files changed, 554 insertions(+), 19 deletions(-) create mode 100755 benchmark/scripts/be_flask.py create mode 100644 benchmark/scripts/templates/error.html create mode 100644 benchmark/scripts/templates/partials/table_report.html create mode 100644 benchmark/scripts/templates/partials/table_select.html create mode 100644 benchmark/scripts/templates/partials/table_summary.html create mode 100644 benchmark/scripts/templates/report_bootstrap.html create mode 100644 benchmark/scripts/templates/report_bulma.html create mode 100644 benchmark/scripts/templates/select_bootstrap.html create mode 100644 benchmark/scripts/templates/select_bulma.html diff --git a/benchmark/Arguments.py b/benchmark/Arguments.py index 80fae6d..cb43ef7 100644 --- a/benchmark/Arguments.py +++ b/benchmark/Arguments.py @@ -13,21 +13,27 @@ ALL_METRICS = ( class EnvData: - @staticmethod - def load(): - args = {} + def __init__(self): + self.args = {} + + def load(self): try: with open(Files.dot_env) as f: for line in f.read().splitlines(): if line == "" or line.startswith("#"): continue key, value = line.split("=") - args[key] = value + self.args[key] = value except FileNotFoundError: print(NO_ENV, file=sys.stderr) exit(1) else: - return args + return self.args + + def save(self): + with open(Files.dot_env, "w") as f: + for key, value in self.args.items(): + f.write(f"{key}={value}\n") class EnvDefault(argparse.Action): @@ -35,7 +41,7 @@ class EnvDefault(argparse.Action): def __init__( self, envvar, required=True, default=None, mandatory=False, **kwargs ): - self._args = EnvData.load() + self._args = EnvData().load() self._overrides = {} if required and not mandatory: default = self._args[envvar] diff --git a/benchmark/Datasets.py b/benchmark/Datasets.py index 98e2709..ebb5e52 100644 --- a/benchmark/Datasets.py +++ b/benchmark/Datasets.py @@ -109,7 +109,7 @@ class DatasetsSurcov: class Datasets: def __init__(self, dataset_name=None, discretize=None): - env_data = EnvData.load() + env_data = EnvData().load() # DatasetsSurcov, DatasetsTanveer, DatasetsArff,... source_name = getattr( __import__(__name__), diff --git a/benchmark/Experiments.py b/benchmark/Experiments.py index fd2b739..e4dbeac 100644 --- a/benchmark/Experiments.py +++ b/benchmark/Experiments.py @@ -22,7 +22,7 @@ from .Arguments import EnvData class Randomized: @staticmethod def seeds(): - return json.loads(EnvData.load()["seeds"]) + return json.loads(EnvData().load()["seeds"]) class BestResults: @@ -117,7 +117,7 @@ class Experiment: discretize=None, folds=5, ): - env_data = EnvData.load() + env_data = EnvData().load() today = datetime.now() self.time = today.strftime("%H:%M:%S") self.date = today.strftime("%Y-%m-%d") diff --git a/benchmark/Results.py b/benchmark/Results.py index 5669268..7a4317d 100644 --- a/benchmark/Results.py +++ b/benchmark/Results.py @@ -71,7 +71,6 @@ class Report(BaseReport): self._load_best_results( self.data["score_name"], self.data["model"] ) - self._compare_totals = {} self.header_line("*") self.header_line( f" {self.data['model']} ver. {self.data['version']}" diff --git a/benchmark/ResultsBase.py b/benchmark/ResultsBase.py index 0c3fde3..94add18 100644 --- a/benchmark/ResultsBase.py +++ b/benchmark/ResultsBase.py @@ -52,10 +52,11 @@ class BaseReport(abc.ABC): self.score_name = self.data["score_name"] self.__load_env_data() self.__compute_best_results_ever() + self._compare_totals = {} def __load_env_data(self): # Set the labels for nodes, leaves, depth - env_data = EnvData.load() + env_data = EnvData().load() self.nodes_label = env_data["nodes"] self.leaves_label = env_data["leaves"] self.depth_label = env_data["depth"] @@ -149,6 +150,7 @@ class BaseReport(abc.ABC): class StubReport(BaseReport): def __init__(self, file_name): + self.compare = False super().__init__(file_name=file_name, best_file=False) def print_line(self, line) -> None: @@ -165,7 +167,7 @@ class StubReport(BaseReport): class Summary: def __init__(self, hidden=False, compare=False) -> None: - self.results = Files().get_all_results(hidden=hidden) + self.results = Files.get_all_results(hidden=hidden) self.data = [] self.data_filtered = [] self.datasets = {} diff --git a/benchmark/ResultsFiles.py b/benchmark/ResultsFiles.py index 7e87d83..cfa8fde 100644 --- a/benchmark/ResultsFiles.py +++ b/benchmark/ResultsFiles.py @@ -620,7 +620,7 @@ class Benchmark: self.__compute_best_results_ever() def __compute_best_results_ever(self): - args = EnvData.load() + args = EnvData().load() key = args["source_data"] best = BestResultsEver() _, self.best_score_value = best.get_name_value(key, self._score) diff --git a/benchmark/Utils.py b/benchmark/Utils.py index 177b49f..229b187 100644 --- a/benchmark/Utils.py +++ b/benchmark/Utils.py @@ -108,7 +108,8 @@ class Files: ) return None - def get_all_results(self, hidden) -> list[str]: + @staticmethod + def get_all_results(hidden) -> list[str]: result_path = os.path.join( ".", Folders.hidden_results if hidden else Folders.results ) @@ -117,7 +118,7 @@ class Files: else: raise ValueError(f"{result_path} does not exist") result = [] - prefix, suffix = self.results_suffixes() + prefix, suffix = Files.results_suffixes() for result_file in files_list: if result_file.startswith(prefix) and result_file.endswith(suffix): result.append(result_file) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py new file mode 100755 index 0000000..0581b19 --- /dev/null +++ b/benchmark/scripts/be_flask.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +import os +import json +import webbrowser +from benchmark.Utils import Files, Folders, Symbols +from benchmark.Arguments import Arguments, EnvData +from benchmark.ResultsBase import StubReport +from flask import Flask +from flask import render_template, request, redirect, url_for + + +# Launch a flask server to serve the results +app = Flask(__name__) +FRAMEWORK = "framework" +FRAMEWORKS = "frameworks" +HIDDEN = "hidden" + + +def process_data(file_name, data): + report = StubReport(os.path.join(Folders.results, file_name)) + new_list = [] + for result in data["results"]: + symbol = report._compute_status(result["dataset"], result["score"]) + result["symbol"] = symbol if symbol != " " else " " + new_list.append(result) + data["results"] = new_list + # Compute summary with explanation of symbols + summary = {} + for key, value in report._compare_totals.items(): + summary[key] = (report._status_meaning(key), value) + return summary + + +@app.route("/index") +@app.route("/") +def index(): + # Get a list of files in a directory + files = Files.get_all_results(hidden=app.config[HIDDEN]) + candidate = app.config[FRAMEWORKS].copy() + candidate.remove(app.config[FRAMEWORK]) + return render_template( + f"select_{app.config[FRAMEWORK]}.html", + files=files, + framework=candidate[0], + ) + + +@app.route("/show", methods=["post"]) +def show(): + selected_file = request.form["selected-file"] + with open(os.path.join(Folders.results, selected_file)) as f: + data = json.load(f) + summary = process_data(selected_file, data) + return render_template( + f"report_{app.config[FRAMEWORK]}.html", data=data, summary=summary + ) + + +@app.route("/config/") +def config(framework): + if not framework in app.config[FRAMEWORKS]: + message = f"framework {framework} not supported" + return render_template("error.html", message=message) + env = EnvData() + env.load() + env.args[FRAMEWORK] = framework + env.save() + app.config[FRAMEWORK] = framework + return redirect(url_for("index")) + + +def main(args_test=None): + arguments = Arguments(prog="be_flask") + arguments.xset("model", required=False) + arguments.xset("score", required=False).xset("compare").xset("hidden") + arguments.xset("nan") + args = arguments.parse(args_test) + app.config[FRAMEWORK] = EnvData().load()[FRAMEWORK] + app.config[HIDDEN] = args.hidden + app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + webbrowser.open_new("http://127.0.0.1:1234/") + app.run(port=1234) + + # Poner checkboxes para seleccionar resultados y poner un botón abajo para hacer un excel con los seleccionados + # Calcular símbolo igual que en list, o bien si ha puesto el parámetro de compare, con best o con zeror diff --git a/benchmark/scripts/templates/error.html b/benchmark/scripts/templates/error.html new file mode 100644 index 0000000..4156b77 --- /dev/null +++ b/benchmark/scripts/templates/error.html @@ -0,0 +1,23 @@ + + + + + Error + + + + +
+ +
+ + + \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report.html b/benchmark/scripts/templates/partials/table_report.html new file mode 100644 index 0000000..fa03681 --- /dev/null +++ b/benchmark/scripts/templates/partials/table_report.html @@ -0,0 +1,28 @@ +{% for item in data.results %} + + + {{item.dataset}} + + + {{'{:,}'.format(item.samples)}} + + + {{"%d" % item.features}} + + + {{"%d" % item.classes}} + + + {{'{:,.2f}'.format(item.nodes)}} + + + {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} + + + {{"%.6f±%.4f" % (item.time, item.time_std)}} + + + {{item.hyperparameters}} + + +{% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html new file mode 100644 index 0000000..d217c0f --- /dev/null +++ b/benchmark/scripts/templates/partials/table_select.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + {% for file in files %} + {% set parts = file.split('_') %} + {% set stratified = parts[6].split('.')[0] %} + + + + + + + + + + {% endfor %} + +
ModelMetricPlatformDateTimeStratified
{{ parts[2] }}{{ parts[1] }}{{ parts[3] }}{{ parts[4] }}{{ parts[5] }}{{ 'True' if stratified =='1' else 'False' }} + {{ button_pre | safe }}{{ file }}{{ button_post | safe }} +
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_summary.html b/benchmark/scripts/templates/partials/table_summary.html new file mode 100644 index 0000000..dda3edf --- /dev/null +++ b/benchmark/scripts/templates/partials/table_summary.html @@ -0,0 +1,13 @@ +{% for key, value in summary.items() %} + + + {{key}} + + + {{value[0]}} + + + {{'{:,}'.format(value[1])}} + + +{% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/report_bootstrap.html b/benchmark/scripts/templates/report_bootstrap.html new file mode 100644 index 0000000..dcbedc9 --- /dev/null +++ b/benchmark/scripts/templates/report_bootstrap.html @@ -0,0 +1,105 @@ + + + + + + + + Report Viewer + + + + + {% set center = "text-center" %} + {% set right = "text-end" %} +
+
+
+
+ +

{{ data.title }}

+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} + + + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} + +
+
+
+ + + \ No newline at end of file diff --git a/benchmark/scripts/templates/report_bulma.html b/benchmark/scripts/templates/report_bulma.html new file mode 100644 index 0000000..a2da25b --- /dev/null +++ b/benchmark/scripts/templates/report_bulma.html @@ -0,0 +1,110 @@ + + + + + + + + Report Viewer + + + + + {% set center = "has-text-centered" %} + {% set right = "has-text-right" %} +
+
+
+
+
+ +

{{ data.title }}

+
+
+
+
+
+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} +

+ + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} +

+
+
+
+ + + \ No newline at end of file diff --git a/benchmark/scripts/templates/select_bootstrap.html b/benchmark/scripts/templates/select_bootstrap.html new file mode 100644 index 0000000..1e2aba2 --- /dev/null +++ b/benchmark/scripts/templates/select_bootstrap.html @@ -0,0 +1,69 @@ + + + + + Benchmark + + + + + + + +
+

Benchmark Results

+ + {% set table_class = "table table-striped table-hover" %} + {% set button_pre = '' %} + {% include "partials/table_select.html" %} +
+ + + + + + + \ No newline at end of file diff --git a/benchmark/scripts/templates/select_bulma.html b/benchmark/scripts/templates/select_bulma.html new file mode 100644 index 0000000..c306978 --- /dev/null +++ b/benchmark/scripts/templates/select_bulma.html @@ -0,0 +1,63 @@ + + + + + Benchmark Results + + + + + + +
+

Benchmark Results

+ + {% set table_class = "table is-striped is-hoverable cell-border" %} + {% set button_pre = 'View' %} + {% include "partials/table_select.html" %} +
+ + + + + + \ No newline at end of file diff --git a/benchmark/tests/Util_test.py b/benchmark/tests/Util_test.py index 3cca34d..81b4919 100644 --- a/benchmark/tests/Util_test.py +++ b/benchmark/tests/Util_test.py @@ -118,7 +118,7 @@ class UtilTest(TestBase): def test_Files_get_results(self): os.chdir(os.path.dirname(os.path.abspath(__file__))) self.assertCountEqual( - Files().get_all_results(hidden=False), + Files.get_all_results(hidden=False), [ "results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json", "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json", @@ -130,7 +130,7 @@ class UtilTest(TestBase): ], ) self.assertCountEqual( - Files().get_all_results(hidden=True), + Files.get_all_results(hidden=True), [ "results_accuracy_STree_iMac27_2021-11-01_23:55:16_0.json", "results_accuracy_XGBoost_MacBookpro16_2022-05-04_11:00:35_" @@ -143,7 +143,7 @@ class UtilTest(TestBase): # check with results os.rename(Folders.results, f"{Folders.results}.test") try: - Files().get_all_results(hidden=False) + Files.get_all_results(hidden=False) except ValueError: pass else: @@ -153,7 +153,7 @@ class UtilTest(TestBase): # check with hidden_results os.rename(Folders.hidden_results, f"{Folders.hidden_results}.test") try: - Files().get_all_results(hidden=True) + Files.get_all_results(hidden=True) except ValueError: pass else: diff --git a/setup.py b/setup.py index ea9875c..e5693ac 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ def script_names(): "report", "summary", "init_project", + "flask", ] result = [] for script in scripts: From 3928b9c583c27131dcb440124a370f96a10993be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 03:12:12 +0200 Subject: [PATCH 02/34] Change partials criteria --- benchmark/scripts/be_flask.py | 8 +- .../scripts/templates/base_bootstrap.html | 25 +++ benchmark/scripts/templates/base_bulma.html | 21 ++ .../scripts/templates/partials/js_select.html | 30 +++ .../partials/table_select_design.html | 11 ++ benchmark/scripts/templates/report.html | 187 ++++++++++++++++++ .../scripts/templates/report_bootstrap.html | 105 ---------- benchmark/scripts/templates/report_bulma.html | 110 ----------- benchmark/scripts/templates/select.html | 22 +++ .../scripts/templates/select_bootstrap.html | 69 ------- benchmark/scripts/templates/select_bulma.html | 63 ------ 11 files changed, 302 insertions(+), 349 deletions(-) create mode 100644 benchmark/scripts/templates/base_bootstrap.html create mode 100644 benchmark/scripts/templates/base_bulma.html create mode 100644 benchmark/scripts/templates/partials/js_select.html create mode 100644 benchmark/scripts/templates/partials/table_select_design.html create mode 100644 benchmark/scripts/templates/report.html delete mode 100644 benchmark/scripts/templates/report_bootstrap.html delete mode 100644 benchmark/scripts/templates/report_bulma.html create mode 100644 benchmark/scripts/templates/select.html delete mode 100644 benchmark/scripts/templates/select_bootstrap.html delete mode 100644 benchmark/scripts/templates/select_bulma.html diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 0581b19..56ba6c9 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -39,9 +39,10 @@ def index(): candidate = app.config[FRAMEWORKS].copy() candidate.remove(app.config[FRAMEWORK]) return render_template( - f"select_{app.config[FRAMEWORK]}.html", + f"select.html", files=files, framework=candidate[0], + used_framework=app.config[FRAMEWORK], ) @@ -52,7 +53,10 @@ def show(): data = json.load(f) summary = process_data(selected_file, data) return render_template( - f"report_{app.config[FRAMEWORK]}.html", data=data, summary=summary + f"report.html", + data=data, + summary=summary, + used_framework=app.config[FRAMEWORK], ) diff --git a/benchmark/scripts/templates/base_bootstrap.html b/benchmark/scripts/templates/base_bootstrap.html new file mode 100644 index 0000000..cd6a841 --- /dev/null +++ b/benchmark/scripts/templates/base_bootstrap.html @@ -0,0 +1,25 @@ + + + + {{ title }} + + + + + + + {% block content %} + {% endblock %} + + + diff --git a/benchmark/scripts/templates/base_bulma.html b/benchmark/scripts/templates/base_bulma.html new file mode 100644 index 0000000..927ea63 --- /dev/null +++ b/benchmark/scripts/templates/base_bulma.html @@ -0,0 +1,21 @@ + + + + {{ title }} + + + + + + {% block content %} + {% endblock %} + + diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html new file mode 100644 index 0000000..4a76c38 --- /dev/null +++ b/benchmark/scripts/templates/partials/js_select.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html new file mode 100644 index 0000000..5c1589a --- /dev/null +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -0,0 +1,11 @@ +
+

Benchmark Results

+ + + {% include "partials/table_select.html" %} +
+ + + +{% include "partials/js_select.html" %} \ No newline at end of file diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html new file mode 100644 index 0000000..82e7f5c --- /dev/null +++ b/benchmark/scripts/templates/report.html @@ -0,0 +1,187 @@ +{% set title = "Report Viewer" %} +{% if used_framework == "bootstrap" %} + {% extends "base_bootstrap.html" %} +{% else %} + {% extends "base_bulma.html" %} +{% endif%} +{% block content%} + {% if used_framework == "bootstrap" %} + {% set center = "text-center" %} + {% set right = "text-end" %} +
+
+
+
+ +

{{ data.title }}

+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} + + + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} + +
+
+
+ {% else %} + {% set center = "has-text-centered" %} + {% set right = "has-text-right" %} +
+
+
+
+
+ +

{{ data.title }}

+
+
+
+
+
+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} +

+ + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} +

+
+
+
+ {% endif %} +{% endblock %} diff --git a/benchmark/scripts/templates/report_bootstrap.html b/benchmark/scripts/templates/report_bootstrap.html deleted file mode 100644 index dcbedc9..0000000 --- a/benchmark/scripts/templates/report_bootstrap.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - Report Viewer - - - - - {% set center = "text-center" %} - {% set right = "text-end" %} -
-
-
-
- -

{{ data.title }}

-
-
- - - - - - - - {% if data.duration > 7200 %} - {% set unit = "h" %} - {% set divider = 3600 %} - {% else %} - {% set unit = "min" %} - {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
- - - - - - - - - - - - - - - {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
- {% if summary|length > 0 %} -
- - - - - - - - - {% include "partials/table_summary.html" %} -
SymbolMeaningCount
-
- {% endif %} - - - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} - -
-
-
- - - \ No newline at end of file diff --git a/benchmark/scripts/templates/report_bulma.html b/benchmark/scripts/templates/report_bulma.html deleted file mode 100644 index a2da25b..0000000 --- a/benchmark/scripts/templates/report_bulma.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - Report Viewer - - - - - {% set center = "has-text-centered" %} - {% set right = "has-text-right" %} -
-
-
-
-
- -

{{ data.title }}

-
-
-
-
-
-
-
- - - - - - - - {% if data.duration > 7200 %} - {% set unit = "h" %} - {% set divider = 3600 %} - {% else %} - {% set unit = "min" %} - {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
- - - - - - - - - - - - - - - {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
- {% if summary|length > 0 %} -
- - - - - - - - - {% include "partials/table_summary.html" %} -
SymbolMeaningCount
-
- {% endif %} -

- - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} -

-
-
-
- - - \ No newline at end of file diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html new file mode 100644 index 0000000..7ab074c --- /dev/null +++ b/benchmark/scripts/templates/select.html @@ -0,0 +1,22 @@ +{% set title = "Benchmark Results" %} +{% if used_framework == "bootstrap" %} + {% extends "base_bootstrap.html" %} + {% set button_class = "btn btn-primary bt-sm" %} + {% set h1_class = "text-center" %} + {% set table_class = "table table-striped table-hover" %} + {% set button_pre = '' %} +{% else %} + {% extends "base_bulma.html" %} + {% set button_class = "button is-primary is-small" %} + {% set h1_class = "title is-1 has-text-centered" %} + {% set table_class = "table is-striped is-hoverable cell-border" %} + {% set button_pre = 'View' %} + {% set selected = "is-selected" %} +{% endif %} +{% block content %} + {% include "partials/table_select_design.html" %} +{% endblock %} diff --git a/benchmark/scripts/templates/select_bootstrap.html b/benchmark/scripts/templates/select_bootstrap.html deleted file mode 100644 index 1e2aba2..0000000 --- a/benchmark/scripts/templates/select_bootstrap.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Benchmark - - - - - - - -
-

Benchmark Results

- - {% set table_class = "table table-striped table-hover" %} - {% set button_pre = '' %} - {% include "partials/table_select.html" %} -
- - - - - - - \ No newline at end of file diff --git a/benchmark/scripts/templates/select_bulma.html b/benchmark/scripts/templates/select_bulma.html deleted file mode 100644 index c306978..0000000 --- a/benchmark/scripts/templates/select_bulma.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - Benchmark Results - - - - - - -
-

Benchmark Results

- - {% set table_class = "table is-striped is-hoverable cell-border" %} - {% set button_pre = 'View' %} - {% include "partials/table_select.html" %} -
- - - - - - \ No newline at end of file From 83cfc3e5f54be43138b7614ce299c6a9640d8a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 03:20:15 +0200 Subject: [PATCH 03/34] Enhance report templates --- benchmark/scripts/templates/error.html | 33 ++-- .../partials/table_report_bootstrap.html | 83 +++++++++ .../partials/table_report_bulma.html | 89 +++++++++ benchmark/scripts/templates/report.html | 174 +----------------- 4 files changed, 189 insertions(+), 190 deletions(-) create mode 100644 benchmark/scripts/templates/partials/table_report_bootstrap.html create mode 100644 benchmark/scripts/templates/partials/table_report_bulma.html diff --git a/benchmark/scripts/templates/error.html b/benchmark/scripts/templates/error.html index 4156b77..a809305 100644 --- a/benchmark/scripts/templates/error.html +++ b/benchmark/scripts/templates/error.html @@ -1,23 +1,20 @@ + + Error + + + +
+ - - + \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html new file mode 100644 index 0000000..20f56da --- /dev/null +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -0,0 +1,83 @@ +
+
+
+
+ +

{{ data.title }}

+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} + + + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} + +
+
+
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html new file mode 100644 index 0000000..ea5d400 --- /dev/null +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -0,0 +1,89 @@ +
+
+
+
+
+ +

{{ data.title }}

+
+
+
+
+
+
+
+ + + + + + + + {% if data.duration > 7200 %} + {% set unit = "h" %} + {% set divider = 3600 %} + {% else %} + {% set unit = "min" %} + {% set divider = 60 %} + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+ + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
+ {% if summary|length > 0 %} +
+ + + + + + + + + {% include "partials/table_summary.html" %} +
SymbolMeaningCount
+
+ {% endif %} +

+ + Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} +

+
+
+
\ No newline at end of file diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index 82e7f5c..ce91983 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -8,180 +8,10 @@ {% if used_framework == "bootstrap" %} {% set center = "text-center" %} {% set right = "text-end" %} -
-
-
-
- -

{{ data.title }}

-
-
- - - - - - - - {% if data.duration > 7200 %} - {% set unit = "h" %} - {% set divider = 3600 %} - {% else %} - {% set unit = "min" %} - {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
- - - - - - - - - - - - - - - {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
- {% if summary|length > 0 %} -
- - - - - - - - - {% include "partials/table_summary.html" %} -
SymbolMeaningCount
-
- {% endif %} - - - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} - -
-
-
+ {% include "partials/table_report_bootstrap.html" %} {% else %} {% set center = "has-text-centered" %} {% set right = "has-text-right" %} -
-
-
-
-
- -

{{ data.title }}

-
-
-
-
-
-
-
- - - - - - - - {% if data.duration > 7200 %} - {% set unit = "h" %} - {% set divider = 3600 %} - {% else %} - {% set unit = "min" %} - {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
- - - - - - - - - - - - - - - {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
- {% if summary|length > 0 %} -
- - - - - - - - - {% include "partials/table_summary.html" %} -
SymbolMeaningCount
-
- {% endif %} -

- - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} -

-
-
-
+ {% include "partials/table_report_bulma.html" %} {% endif %} {% endblock %} From be62e38e772d9a29838836c64b9afd1761c6cf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 11:56:14 +0200 Subject: [PATCH 04/34] Add title and score to select page --- benchmark/Utils.py | 1 + benchmark/scripts/be_flask.py | 38 ++++++++------ benchmark/scripts/templates/base.html | 40 ++++++++++++++ .../scripts/templates/base_bootstrap.html | 25 --------- benchmark/scripts/templates/base_bulma.html | 21 -------- .../scripts/templates/partials/js_select.html | 3 +- .../templates/partials/table_report.html | 52 +++++++++---------- .../partials/table_report_bootstrap.html | 1 + .../partials/table_report_bulma.html | 1 + .../templates/partials/table_select.html | 32 +++++++----- .../partials/table_select_design.html | 3 +- benchmark/scripts/templates/report.html | 8 +-- benchmark/scripts/templates/select.html | 5 +- 13 files changed, 117 insertions(+), 113 deletions(-) create mode 100644 benchmark/scripts/templates/base.html delete mode 100644 benchmark/scripts/templates/base_bootstrap.html delete mode 100644 benchmark/scripts/templates/base_bulma.html diff --git a/benchmark/Utils.py b/benchmark/Utils.py index 229b187..33941de 100644 --- a/benchmark/Utils.py +++ b/benchmark/Utils.py @@ -1,5 +1,6 @@ import os import sys +import json import subprocess PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 56ba6c9..95774f8 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -2,7 +2,7 @@ import os import json import webbrowser -from benchmark.Utils import Files, Folders, Symbols +from benchmark.Utils import Files, Folders from benchmark.Arguments import Arguments, EnvData from benchmark.ResultsBase import StubReport from flask import Flask @@ -13,7 +13,6 @@ from flask import render_template, request, redirect, url_for app = Flask(__name__) FRAMEWORK = "framework" FRAMEWORKS = "frameworks" -HIDDEN = "hidden" def process_data(file_name, data): @@ -35,14 +34,23 @@ def process_data(file_name, data): @app.route("/") def index(): # 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.remove(app.config[FRAMEWORK]) return render_template( - f"select.html", + "select.html", files=files, - framework=candidate[0], - used_framework=app.config[FRAMEWORK], + candidate=candidate[0], + framework=app.config[FRAMEWORK], ) @@ -53,10 +61,10 @@ def show(): data = json.load(f) summary = process_data(selected_file, data) return render_template( - f"report.html", + "report.html", data=data, summary=summary, - used_framework=app.config[FRAMEWORK], + framework=app.config[FRAMEWORK], ) @@ -74,13 +82,13 @@ def config(framework): def main(args_test=None): - arguments = Arguments(prog="be_flask") - arguments.xset("model", required=False) - arguments.xset("score", required=False).xset("compare").xset("hidden") - arguments.xset("nan") - args = arguments.parse(args_test) - app.config[FRAMEWORK] = EnvData().load()[FRAMEWORK] - app.config[HIDDEN] = args.hidden + # arguments = Arguments(prog="be_flask") + # arguments.xset("model", required=False) + # arguments.xset("score", required=False).xset("compare") + # arguments.xset("nan") + # args = arguments.parse(args_test) + config = EnvData().load() + app.config[FRAMEWORK] = config[FRAMEWORK] app.config[FRAMEWORKS] = ["bootstrap", "bulma"] webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234) diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html new file mode 100644 index 0000000..44c7aca --- /dev/null +++ b/benchmark/scripts/templates/base.html @@ -0,0 +1,40 @@ + + + + {{ title }} + {% if framework == "bootstrap" %} + + + + {% else %} + + + + {% endif %} + + + {% block content %} + {% endblock %} + + {% if framework == "bootstrap" %} + + {% endif %} + \ No newline at end of file diff --git a/benchmark/scripts/templates/base_bootstrap.html b/benchmark/scripts/templates/base_bootstrap.html deleted file mode 100644 index cd6a841..0000000 --- a/benchmark/scripts/templates/base_bootstrap.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - {{ title }} - - - - - - - {% block content %} - {% endblock %} - - - diff --git a/benchmark/scripts/templates/base_bulma.html b/benchmark/scripts/templates/base_bulma.html deleted file mode 100644 index 927ea63..0000000 --- a/benchmark/scripts/templates/base_bulma.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - {{ title }} - - - - - - {% block content %} - {% endblock %} - - diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html index 4a76c38..96bb38a 100644 --- a/benchmark/scripts/templates/partials/js_select.html +++ b/benchmark/scripts/templates/partials/js_select.html @@ -6,8 +6,9 @@ "ordering": true, "info": true, "select.items": "row", + "pageLength": 25, "columnDefs": [{ - "targets": 6, + "targets": 8, "orderable": false }] }); diff --git a/benchmark/scripts/templates/partials/table_report.html b/benchmark/scripts/templates/partials/table_report.html index fa03681..47855d9 100644 --- a/benchmark/scripts/templates/partials/table_report.html +++ b/benchmark/scripts/templates/partials/table_report.html @@ -1,28 +1,28 @@ {% for item in data.results %} - - - {{item.dataset}} - - - {{'{:,}'.format(item.samples)}} - - - {{"%d" % item.features}} - - - {{"%d" % item.classes}} - - - {{'{:,.2f}'.format(item.nodes)}} - - - {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} - - - {{"%.6f±%.4f" % (item.time, item.time_std)}} - - - {{item.hyperparameters}} - - + + + {{item.dataset}} + + + {{'{:,}'.format(item.samples)}} + + + {{"%d" % item.features}} + + + {{"%d" % item.classes}} + + + {{'{:,.2f}'.format(item.nodes)}} + + + {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} + + + {{"%.6f±%.4f" % (item.time, item.time_std)}} + + + {{item.hyperparameters}} + + {% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index 20f56da..b3672b8 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -78,6 +78,7 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} + Number of files: {{ data.results | length }}
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index ea5d400..371fa65 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -84,6 +84,7 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} +

Number of files: {{ data.results | length }}

\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index d217c0f..a313e49 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -7,24 +7,28 @@ Date Time Stratified + Title + Score - {% for file in files %} - {% set parts = file.split('_') %} - {% set stratified = parts[6].split('.')[0] %} - - {{ parts[2] }} - {{ parts[1] }} - {{ parts[3] }} - {{ parts[4] }} - {{ parts[5] }} - {{ 'True' if stratified =='1' else 'False' }} - - {{ button_pre | safe }}{{ file }}{{ button_post | safe }} - - + {% for file, data in files.items() %} + {% set parts = file.split('_') %} + {% set stratified = parts[6].split('.')[0] %} + + {{ parts[2] }} + {{ parts[1] }} + {{ parts[3] }} + {{ parts[4] }} + {{ parts[5] }} + {{ 'True' if stratified =='1' else 'False' }} + {{ "%s" % data["title"] }} + {{ "%.6f" % data["score"] }} + + {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + + {% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 5c1589a..7c88002 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,8 +1,7 @@

Benchmark Results

- - {% include "partials/table_select.html" %}
diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index ce91983..23f47e8 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -1,11 +1,7 @@ {% set title = "Report Viewer" %} -{% if used_framework == "bootstrap" %} - {% extends "base_bootstrap.html" %} -{% else %} - {% extends "base_bulma.html" %} -{% endif%} +{% extends "base.html" %} {% block content%} - {% if used_framework == "bootstrap" %} + {% if framework == "bootstrap" %} {% set center = "text-center" %} {% set right = "text-end" %} {% include "partials/table_report_bootstrap.html" %} diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 7ab074c..74cfdb5 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -1,6 +1,6 @@ {% set title = "Benchmark Results" %} -{% if used_framework == "bootstrap" %} - {% extends "base_bootstrap.html" %} +{% extends "base.html" %} +{% if framework == "bootstrap" %} {% set button_class = "btn btn-primary bt-sm" %} {% set h1_class = "text-center" %} {% set table_class = "table table-striped table-hover" %} @@ -9,7 +9,6 @@ onclick="showFile(\''%} {% set button_post = '\')">View' %} {% else %} - {% extends "base_bulma.html" %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} {% set table_class = "table is-striped is-hoverable cell-border" %} From e17e7d4e006e15ed8c4ab5670f74701adfa1a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 18:03:20 +0200 Subject: [PATCH 05/34] Generate excel file from results --- benchmark/scripts/be_flask.py | 43 ++++++++++++++++--- .../scripts/templates/partials/js_select.html | 28 ++++++++++++ .../templates/partials/table_select.html | 1 + .../partials/table_select_design.html | 3 +- 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 95774f8..9af9c83 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -2,9 +2,11 @@ import os import json import webbrowser +import xlsxwriter from benchmark.Utils import Files, Folders from benchmark.Arguments import Arguments, EnvData from benchmark.ResultsBase import StubReport +from benchmark.ResultsFiles import Excel from flask import Flask from flask import render_template, request, redirect, url_for @@ -13,6 +15,8 @@ from flask import render_template, request, redirect, url_for app = Flask(__name__) FRAMEWORK = "framework" FRAMEWORKS = "frameworks" +COMPARE = "compare" +TEST = "test" def process_data(file_name, data): @@ -68,6 +72,34 @@ def show(): ) +@app.route("/excel", methods=["post"]) +def excel(): + if request.is_json: + selected_files = request.json + else: + selected_files = request.form["selected-files"] + book = None + for file_name in selected_files: + file_name_result = os.path.join(Folders.results, file_name) + if book is None: + file_excel = os.path.join(Folders.excel, Files.be_list_excel) + book = xlsxwriter.Workbook(file_excel, {"nan_inf_to_errors": True}) + excel = Excel( + file_name=file_name_result, + book=book, + compare=app.config[COMPARE], + ) + excel.report() + if book is not None: + book.close() + Files.open(file_excel, test=app.config[TEST]) + return ( + json.dumps({"success": True, "file": Files.be_list_excel}), + 200, + {"ContentType": "application/json"}, + ) + + @app.route("/config/") def config(framework): if not framework in app.config[FRAMEWORKS]: @@ -82,14 +114,15 @@ def config(framework): def main(args_test=None): - # arguments = Arguments(prog="be_flask") - # arguments.xset("model", required=False) - # arguments.xset("score", required=False).xset("compare") - # arguments.xset("nan") - # args = arguments.parse(args_test) + arguments = Arguments(prog="be_flask") + arguments.xset("model", required=False) + arguments.xset("score", required=False).xset("compare") + args = arguments.parse(args_test) config = EnvData().load() app.config[FRAMEWORK] = config[FRAMEWORK] + app.config[COMPARE] = args.compare app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + app.config[TEST] = args_test is not None webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234) diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html index 96bb38a..2593b27 100644 --- a/benchmark/scripts/templates/partials/js_select.html +++ b/benchmark/scripts/templates/partials/js_select.html @@ -28,4 +28,32 @@ $('body').append(form); form.submit(); } + function excel() { + var checkbox = document.getElementsByName("selected_files"); + var selectedFiles = []; + for (var i = 0; i < checkbox.length; i++) { + if (checkbox[i].checked) { + selectedFiles.push(checkbox[i].value); + } + } + if (selectedFiles.length == 0) { + alert("Select at least one file"); + return; + } + // send data to server with ajax post + $.ajax({ + type:'POST', + url:'/excel', + data: JSON.stringify(selectedFiles), + contentType: "application/json", + dataType: 'json', + success: function(data){ + alert("Se ha generado el archivo "+data.file); + }, + error: function (xhr, ajaxOptions, thrownError) { + var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}'); + alert(mensaje.mensaje); + } + }); + } \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index a313e49..40357f5 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -27,6 +27,7 @@ {{ "%.6f" % data["score"] }} {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + {% endfor %} diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 7c88002..8a71dd2 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,8 +1,9 @@

Benchmark Results

- {% include "partials/table_select.html" %} +
From 655c1db8896518c3bf42677391f3ed44e416c66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 18:09:11 +0200 Subject: [PATCH 06/34] Fix row selection in bootstrap --- benchmark/scripts/templates/partials/js_select.html | 1 + benchmark/scripts/templates/select.html | 1 + 2 files changed, 2 insertions(+) diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html index 2593b27..4a0feb5 100644 --- a/benchmark/scripts/templates/partials/js_select.html +++ b/benchmark/scripts/templates/partials/js_select.html @@ -12,6 +12,7 @@ "orderable": false }] }); + // Check if row is selected $('#file-table tbody').on('click', 'tr', function () { if ($(this).hasClass('{{ selected }}')) { $(this).removeClass('{{ selected }}'); diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 74cfdb5..228ce97 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -8,6 +8,7 @@ style="--bs-btn-padding-y: .25rem; --bs-btn-padding-x: .5rem; --bs-btn-font-size: .75rem;" onclick="showFile(\''%} {% set button_post = '\')">View' %} + {% set selected = "selected" %} {% else %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} From 663a0b025859b698e841e0095c7ab196525845bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 20:06:33 +0200 Subject: [PATCH 07/34] Add select row to report --- benchmark/scripts/templates/base.html | 11 ++-- .../scripts/templates/partials/js_report.js | 11 ++++ .../scripts/templates/partials/js_select.html | 60 ------------------- .../scripts/templates/partials/js_select.js | 58 ++++++++++++++++++ .../partials/table_report_bootstrap.html | 2 +- .../partials/table_report_bulma.html | 2 +- .../templates/partials/table_select.html | 2 +- .../partials/table_select_design.html | 6 +- benchmark/scripts/templates/report.html | 10 ++++ benchmark/scripts/templates/select.html | 15 ++++- 10 files changed, 103 insertions(+), 74 deletions(-) create mode 100644 benchmark/scripts/templates/partials/js_report.js delete mode 100644 benchmark/scripts/templates/partials/js_select.html create mode 100644 benchmark/scripts/templates/partials/js_select.js diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html index 44c7aca..1a4ce78 100644 --- a/benchmark/scripts/templates/base.html +++ b/benchmark/scripts/templates/base.html @@ -14,6 +14,10 @@ background-color: #0dcaf0; color:white; } + #report-table tbody tr.selected td{ + background-color: #0dcaf0; + color:white; + } {% else %} @@ -33,8 +37,7 @@ {% block content %} {% endblock %} - {% if framework == "bootstrap" %} - - {% endif %} + + {% block jscript %} + {% endblock %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/js_report.js b/benchmark/scripts/templates/partials/js_report.js new file mode 100644 index 0000000..4cbe71e --- /dev/null +++ b/benchmark/scripts/templates/partials/js_report.js @@ -0,0 +1,11 @@ +$(document).ready(function () { + // Check if row is selected + $('#report-table tbody').on('click', 'tr', function () { + if ($(this).hasClass('{{ selected }}')) { + $(this).removeClass('{{ selected }}'); + } else { + $('#report-table tbody tr.{{ selected }}').removeClass("{{ selected }}") + $(this).addClass('{{ selected }}'); + } + }); + }); \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html deleted file mode 100644 index 4a0feb5..0000000 --- a/benchmark/scripts/templates/partials/js_select.html +++ /dev/null @@ -1,60 +0,0 @@ - \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/js_select.js b/benchmark/scripts/templates/partials/js_select.js new file mode 100644 index 0000000..011b927 --- /dev/null +++ b/benchmark/scripts/templates/partials/js_select.js @@ -0,0 +1,58 @@ +$(document).ready(function () { + var table = $('#file-table').DataTable({ + "paging": true, + "searching": true, + "ordering": true, + "info": true, + "select.items": "row", + "pageLength": 25, + "columnDefs": [{ + "targets": 8, + "orderable": false + }] + }); + // Check if row is selected + $('#file-table tbody').on('click', 'tr', function () { + if ($(this).hasClass('{{ selected }}')) { + $(this).removeClass('{{ selected }}'); + } else { + table.$('tr.{{ selected }}').removeClass('{{ selected }}'); + $(this).addClass('{{ selected }}'); + } + }); +}); +function showFile(selectedFile) { + var form = $('
' + + '' + + '
'); + $('body').append(form); + form.submit(); +} +function excel() { + var checkbox = document.getElementsByName("selected_files"); + var selectedFiles = []; + for (var i = 0; i < checkbox.length; i++) { + if (checkbox[i].checked) { + selectedFiles.push(checkbox[i].value); + } + } + if (selectedFiles.length == 0) { + alert("Select at least one file"); + return; + } + // send data to server with ajax post + $.ajax({ + type:'POST', + url:'/excel', + data: JSON.stringify(selectedFiles), + contentType: "application/json", + dataType: 'json', + success: function(data){ + alert("Se ha generado el archivo "+data.file); + }, + error: function (xhr, ajaxOptions, thrownError) { + var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}'); + alert(mensaje.mensaje); + } + }); +} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index b3672b8..c434c5d 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -43,7 +43,7 @@ - +
diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index 371fa65..f126a8d 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -49,7 +49,7 @@
Dataset
- +
diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 40357f5..5fbe858 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -1,4 +1,4 @@ -
Dataset
+
diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 8a71dd2..7d6b5fb 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -4,8 +4,4 @@ }} {% include "partials/table_select.html" %} - - - - -{% include "partials/js_select.html" %} \ No newline at end of file + \ No newline at end of file diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index 23f47e8..50d768c 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -11,3 +11,13 @@ {% include "partials/table_report_bulma.html" %} {% endif %} {% endblock %} +{% block jscript %} + {% if framework == "bootstrap" %} + {% set selected = "selected" %} + {% else %} + {% set selected = "is-selected" %} + {% endif %} + +{% endblock %} diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 228ce97..107eaed 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -3,7 +3,7 @@ {% if framework == "bootstrap" %} {% set button_class = "btn btn-primary bt-sm" %} {% set h1_class = "text-center" %} - {% set table_class = "table table-striped table-hover" %} + {% set table_class = "table table-striped table-hover table-bordered" %} {% set button_pre = ' +
+
+ +
+ {% if config.compare %} +
+ Comparing with best results +
+ {% endif %} +
{% include "partials/table_select.html" %} \ No newline at end of file diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 107eaed..6af6750 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -9,13 +9,22 @@ onclick="showFile(\''%} {% set button_post = '\')">View' %} {% set selected = "selected" %} -{% else %} + {% set tag_class = "badge bg-primary bg-small" %} + {% set frbutton_position = "float-left" %} + {% set frtag_position = "float-right" %} + {% set level = "navbar" %} + "tag is-primary" + {% else %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} {% set button_pre = 'View' %} {% set selected = "is-selected" %} + {% set tag_class = "tag is-primary is-normal" %} + {% set frbutton_position = "level-left" %} + {% set frtag_position = "level-right" %} + {% set level = "level" %} {% endif %} {% block content %} {% include "partials/table_select_design.html" %} From 60086b3925b73af0ba0f4139b233de419aeef635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 29 May 2023 12:06:44 +0200 Subject: [PATCH 10/34] container-fluid and error tolerance in compare --- benchmark/scripts/be_flask.py | 5 +- .../partials/table_report_bootstrap.html | 2 +- .../partials/table_report_bulma.html | 4 +- .../templates/partials/table_select.html | 72 ++++++++++--------- .../partials/table_select_design.html | 2 +- benchmark/scripts/templates/select.html | 67 +++++++++-------- requirements.txt | 1 + 7 files changed, 80 insertions(+), 73 deletions(-) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index fc639b7..ebed0fe 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -65,7 +65,10 @@ def show(): selected_file = request.form["selected-file"] with open(os.path.join(Folders.results, selected_file)) as f: data = json.load(f) - summary = process_data(selected_file, data) + try: + summary = process_data(selected_file, data) + except Exception as e: + return render_template("error.html", message=str(e)) return render_template( "report.html", data=data, diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index f88210d..12b6afb 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -1,6 +1,6 @@
-
+

{{ data.title }}

diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index 3b2c556..cd72099 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -1,6 +1,6 @@
-
+
@@ -10,7 +10,7 @@
-
+
Model
diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 5fbe858..0435f6f 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -1,35 +1,39 @@
- - - - - - - - - - - - - - - {% for file, data in files.items() %} - {% set parts = file.split('_') %} - {% set stratified = parts[6].split('.')[0] %} - - - - - - - - - - - - {% endfor %} - -
ModelMetricPlatformDateTimeStratifiedTitleScore
{{ parts[2] }}{{ parts[1] }}{{ parts[3] }}{{ parts[4] }}{{ parts[5] }}{{ 'True' if stratified =='1' else 'False' }}{{ "%s" % data["title"] }}{{ "%.6f" % data["score"] }} - {{ button_pre | safe }}{{ file }}{{ button_post | safe }} - -
\ No newline at end of file + + + Model + Metric + Platform + Date + Time + Stratified + Title + Score + + + + + {% for file, data in files.items() %} {% set parts = file.split('_') %} {% + set stratified = parts[6].split('.')[0] %} + + {{ parts[2] }} + {{ parts[1] }} + {{ parts[3] }} + {{ parts[4] }} + {{ parts[5] }} + {{ 'True' if stratified =='1' else 'False' }} + {{ "%s" % data["title"] }} + {{ "%.6f" % data["score"] }} + + {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + + + + {% endfor %} + + diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 6c01aae..70eb31f 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,4 +1,4 @@ -
+

Benchmark Results

diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 6af6750..12cd42f 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -1,42 +1,41 @@ {% set title = "Benchmark Results" %} {% extends "base.html" %} {% if framework == "bootstrap" %} - {% set button_class = "btn btn-primary bt-sm" %} - {% set h1_class = "text-center" %} - {% set table_class = "table table-striped table-hover table-bordered" %} - {% set button_pre = '' %} - {% set selected = "selected" %} - {% set tag_class = "badge bg-primary bg-small" %} - {% set frbutton_position = "float-left" %} - {% set frtag_position = "float-right" %} - {% set level = "navbar" %} - "tag is-primary" - {% else %} - {% set button_class = "button is-primary is-small" %} - {% set h1_class = "title is-1 has-text-centered" %} - {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} - {% set button_pre = 'View' %} - {% set selected = "is-selected" %} - {% set tag_class = "tag is-primary is-normal" %} - {% set frbutton_position = "level-left" %} - {% set frtag_position = "level-right" %} - {% set level = "level" %} + {% set button_class = "btn btn-primary bt-sm" %} + {% set h1_class = "text-center" %} + {% set table_class = "table table-striped table-hover table-bordered" %} + {% set button_pre = '' %} + {% set selected = "selected" %} + {% set tag_class = "badge bg-primary bg-small" %} + {% set frbutton_position = "float-left" %} + {% set frtag_position = "float-right" %} + {% set level = "navbar" %} + {% set align_right = "text-end" %} + {% set container = "container-fluid" %} +{% else %} + {% set button_class = "button is-primary is-small" %} + {% set h1_class = "title is-1 has-text-centered" %} + {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} + {% set button_pre = 'View' %} + {% set selected = "is-selected" %} + {% set align_right = "text-end" %} + {% set container = "container is-fluid" %} {% endif %} {% block content %} - {% include "partials/table_select_design.html" %} + {% include "partials/table_select_design.html" %} {% endblock %} {% block jscript %} - - {% if framework == "bootstrap" %} - - {% endif %} - -{% endblock %} \ No newline at end of file + + {% if framework == "bootstrap" %} + + {% endif %} + +{% endblock %} diff --git a/requirements.txt b/requirements.txt index 32065e2..eb705fe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ xgboost graphviz Wodt @ git+ssh://git@github.com/doctorado-ml/Wodt.git#egg=Wodt unittest-xml-reporting +flask From 8fe4b888b8393cc7891e6e12836cc3c0b5b7d6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 29 May 2023 16:47:03 +0200 Subject: [PATCH 11/34] Add icons to actions --- benchmark/scripts/templates/base.html | 90 +++++++++++-------- .../partials/table_report_bootstrap.html | 2 +- .../partials/table_report_bulma.html | 2 +- .../partials/table_select_design.html | 9 +- benchmark/scripts/templates/select.html | 8 +- 5 files changed, 66 insertions(+), 45 deletions(-) diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html index 1a4ce78..78c82d6 100644 --- a/benchmark/scripts/templates/base.html +++ b/benchmark/scripts/templates/base.html @@ -1,43 +1,57 @@ - - {{ title }} - {% if framework == "bootstrap" %} - - - - {% else %} - - - - {% endif %} - - - {% block content %} - {% endblock %} - - - {% block jscript %} - {% endblock %} - \ No newline at end of file + {% endif %} + + + + + {% block content %} {% endblock %} + + + {% block jscript %} {% endblock %} + diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index 12b6afb..5a61252 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -80,7 +80,7 @@ Number of files: {{ data.results | length }}
- +
diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index cd72099..913e315 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -86,7 +86,7 @@

Number of files: {{ data.results | length }}

- +
diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 70eb31f..824c7df 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -2,8 +2,12 @@

Benchmark Results

- + + +
+
+
{% if config.compare %}
@@ -12,5 +16,4 @@ {% endif %}
{% include "partials/table_select.html" %} -
\ No newline at end of file diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 12cd42f..e4497af 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -7,7 +7,7 @@ {% set button_pre = '' %} + {% set button_post = '\')">' %} {% set selected = "selected" %} {% set tag_class = "badge bg-primary bg-small" %} {% set frbutton_position = "float-left" %} @@ -20,9 +20,11 @@ {% set h1_class = "title is-1 has-text-centered" %} {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} {% set button_pre = 'View' %} + {% set button_post = '\')">' %} {% set selected = "is-selected" %} {% set align_right = "text-end" %} + {% set level = "level" %} + {% set tag_class = "tag is-primary is-small" %} {% set container = "container is-fluid" %} {% endif %} {% block content %} @@ -39,3 +41,5 @@ {% include "partials/js_select.js" %} {% endblock %} + + \ No newline at end of file From 395a64abb7ff8d53543b2f36607bfcfd0e432ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 29 May 2023 18:53:08 +0200 Subject: [PATCH 12/34] Add button reset and refactor buttons in select Change position of excel button in report --- benchmark/scripts/templates/base.html | 26 +++++++++++-------- .../scripts/templates/partials/js_report.js | 2 +- .../scripts/templates/partials/js_select.js | 11 +++++++- .../partials/table_report_bootstrap.html | 6 ++--- .../partials/table_report_bulma.html | 6 ++--- .../templates/partials/table_select.html | 2 +- .../partials/table_select_design.html | 5 +--- benchmark/scripts/templates/select.html | 8 +++--- 8 files changed, 39 insertions(+), 27 deletions(-) diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html index 78c82d6..89a82e3 100644 --- a/benchmark/scripts/templates/base.html +++ b/benchmark/scripts/templates/base.html @@ -10,17 +10,21 @@ crossorigin="anonymous" /> {% else %} +
+ +
@@ -79,9 +82,6 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} Number of files: {{ data.results | length }} -
- -
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index 913e315..f320c2c 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -49,6 +49,9 @@
+
+ +
@@ -85,9 +88,6 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}

Number of files: {{ data.results | length }}

-
- -
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 0435f6f..7061640 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -9,7 +9,7 @@ - + diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 824c7df..707cc2d 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -4,10 +4,7 @@
- -
-
- +
{% if config.compare %}
diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index e4497af..c217ede 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -1,11 +1,11 @@ {% set title = "Benchmark Results" %} {% extends "base.html" %} {% if framework == "bootstrap" %} - {% set button_class = "btn btn-primary bt-sm" %} + {% set button_class = "btn btn-primary btn-small" %} {% set h1_class = "text-center" %} {% set table_class = "table table-striped table-hover table-bordered" %} - {% set button_pre = '' %} {% set selected = "selected" %} @@ -15,6 +15,7 @@ {% set level = "navbar" %} {% set align_right = "text-end" %} {% set container = "container-fluid" %} + {% set button_reset = '' %} {% else %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} @@ -26,6 +27,7 @@ {% set level = "level" %} {% set tag_class = "tag is-primary is-small" %} {% set container = "container is-fluid" %} + {% set button_reset = '' %} {% endif %} {% block content %} {% include "partials/table_select_design.html" %} From 2df055334ceced214f2f2aae35ce904cb9a94f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 29 May 2023 19:35:54 +0200 Subject: [PATCH 13/34] Add select all/none buttons with icons --- benchmark/scripts/templates/partials/js_select.js | 4 ++-- benchmark/scripts/templates/partials/table_select.html | 2 +- benchmark/scripts/templates/select.html | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/benchmark/scripts/templates/partials/js_select.js b/benchmark/scripts/templates/partials/js_select.js index e0ce176..13f6216 100644 --- a/benchmark/scripts/templates/partials/js_select.js +++ b/benchmark/scripts/templates/partials/js_select.js @@ -59,9 +59,9 @@ function excel() { } }); } -function clearCheckBoxes() { +function setCheckBoxes(value) { var checkbox = document.getElementsByName("selected_files"); for (i = 0; i < checkbox.length; i++) { - checkbox[i].checked=false; + checkbox[i].checked=value; } } \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 7061640..68bbf2b 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -9,7 +9,7 @@
- + diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index c217ede..757c5f0 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -9,13 +9,14 @@ onclick="showFile(\''%} {% set button_post = '\')">' %} {% set selected = "selected" %} - {% set tag_class = "badge bg-primary bg-small" %} + {% set tag_class = "badge bg-info bg-small" %} {% set frbutton_position = "float-left" %} {% set frtag_position = "float-right" %} {% set level = "navbar" %} {% set align_right = "text-end" %} {% set container = "container-fluid" %} - {% set button_reset = '' %} + {% set button_reset = '' %} + {% set button_all = '' %} {% else %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} @@ -25,9 +26,10 @@ {% set selected = "is-selected" %} {% set align_right = "text-end" %} {% set level = "level" %} - {% set tag_class = "tag is-primary is-small" %} + {% set tag_class = "tag is-info is-small" %} {% set container = "container is-fluid" %} - {% set button_reset = '' %} + {% set button_reset = '' %} + {% set button_all = '' %} {% endif %} {% block content %} {% include "partials/table_select_design.html" %} From 007c419979760d1b528c5634c124baaf13f15233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 29 May 2023 20:07:00 +0200 Subject: [PATCH 14/34] Add generate excel fault tolerance with compare --- benchmark/scripts/be_flask.py | 36 +++++++++++++------ .../scripts/templates/partials/js_select.js | 10 ++++-- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index ebed0fe..7829d78 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -85,17 +85,33 @@ def excel(): else: selected_files = request.form["selected-files"] book = None - for file_name in selected_files: - file_name_result = os.path.join(Folders.results, file_name) - if book is None: - file_excel = os.path.join(Folders.excel, Files.be_list_excel) - book = xlsxwriter.Workbook(file_excel, {"nan_inf_to_errors": True}) - excel = Excel( - file_name=file_name_result, - book=book, - compare=app.config[COMPARE], + try: + for file_name in selected_files: + file_name_result = os.path.join(Folders.results, file_name) + if book is None: + file_excel = os.path.join(Folders.excel, Files.be_list_excel) + book = xlsxwriter.Workbook( + file_excel, {"nan_inf_to_errors": True} + ) + excel = Excel( + file_name=file_name_result, + book=book, + compare=app.config[COMPARE], + ) + excel.report() + except Exception as e: + if book is not None: + book.close() + return ( + json.dumps( + { + "success": False, + "error": "Could not create excel file, " + str(e), + } + ), + 200, + {"ContentType": "application/json"}, ) - excel.report() if book is not None: book.close() Files.open(file_excel, test=app.config[TEST]) diff --git a/benchmark/scripts/templates/partials/js_select.js b/benchmark/scripts/templates/partials/js_select.js index 13f6216..620558f 100644 --- a/benchmark/scripts/templates/partials/js_select.js +++ b/benchmark/scripts/templates/partials/js_select.js @@ -51,11 +51,15 @@ function excel() { contentType: "application/json", dataType: 'json', success: function(data){ - alert("Se ha generado el archivo "+data.file); + if (data.success) { + alert("Se ha generado el archivo "+data.file); + } else { + alert(data.error); + } }, error: function (xhr, ajaxOptions, thrownError) { - var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}'); - alert(mensaje.mensaje); + var mensaje = JSON.parse(xhr.responseText || '{\"message\": \"Error indeterminado\"}'); + alert(mensaje.message); } }); } From 1b362f21103b9c824390573636b0e85b80227a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 29 May 2023 22:37:05 +0200 Subject: [PATCH 15/34] Add wait cursor during ajax --- benchmark/scripts/templates/base.html | 36 +++++++++++-------- .../scripts/templates/partials/js_report.js | 6 ++++ .../scripts/templates/partials/js_select.js | 6 ++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html index 89a82e3..c9c25a4 100644 --- a/benchmark/scripts/templates/base.html +++ b/benchmark/scripts/templates/base.html @@ -10,21 +10,24 @@ crossorigin="anonymous" /> {% else %} {% endif %} ' + From 10c352fdb52eaf10af6afe180c6c4e82b7b84ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 29 May 2023 23:07:10 +0200 Subject: [PATCH 16/34] Add double click to show file --- .../scripts/templates/partials/js_select.js | 4 ++ .../templates/partials/table_select.html | 43 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/benchmark/scripts/templates/partials/js_select.js b/benchmark/scripts/templates/partials/js_select.js index 4dc01d6..2f22aed 100644 --- a/benchmark/scripts/templates/partials/js_select.js +++ b/benchmark/scripts/templates/partials/js_select.js @@ -23,6 +23,10 @@ $(document).ready(function () { $(this).addClass('{{ selected }}'); } }); + // Show file with doubleclick + $('#file-table tbody').on('dblclick', 'tr', function () { + showFile($(this).attr("id")); + }); $(document).ajaxStart(function(){ $("body").addClass('ajaxLoading'); }); diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 68bbf2b..7fac6bb 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -13,27 +13,28 @@ - {% for file, data in files.items() %} {% set parts = file.split('_') %} {% - set stratified = parts[6].split('.')[0] %} - - - - - - - - - - - + {% for file, data in files.items() %} + {% set parts = file.split('_') %} + {% set stratified = parts[6].split('.')[0] %} + + + + + + + + + + + {% endfor %}
Stratified Title Score{{ button_reset|safe }}
Stratified Title Score{{ button_reset|safe }}{{ button_reset|safe }} {{ button_all|safe }}
{{ parts[2] }}{{ parts[1] }}{{ parts[3] }}{{ parts[4] }}{{ parts[5] }}{{ 'True' if stratified =='1' else 'False' }}{{ "%s" % data["title"] }}{{ "%.6f" % data["score"] }} - {{ button_pre | safe }}{{ file }}{{ button_post | safe }} - -
{{ parts[2] }}{{ parts[1] }}{{ parts[3] }}{{ parts[4] }}{{ parts[5] }}{{ 'True' if stratified =='1' else 'False' }}{{ "%s" % data["title"] }}{{ "%.6f" % data["score"] }} + {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + +
From 40af738ed9930c5127e4a037fd8e858f71d56f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Tue, 30 May 2023 00:08:36 +0200 Subject: [PATCH 17/34] Add persistence of checkbox compare on app --- benchmark/scripts/be_flask.py | 39 ++++++++----------- benchmark/scripts/templates/error.html | 2 +- .../scripts/templates/partials/js_select.js | 4 ++ .../partials/table_report_bootstrap.html | 4 +- .../partials/table_report_bulma.html | 4 +- .../partials/table_select_design.html | 11 +++--- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 7829d78..ae83515 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -4,7 +4,7 @@ import json import webbrowser import xlsxwriter from benchmark.Utils import Files, Folders -from benchmark.Arguments import Arguments, EnvData +from benchmark.Arguments import EnvData from benchmark.ResultsBase import StubReport from benchmark.ResultsFiles import Excel from flask import Flask @@ -15,13 +15,12 @@ from flask import render_template, request, redirect, url_for app = Flask(__name__) FRAMEWORK = "framework" FRAMEWORKS = "frameworks" -COMPARE = "compare" TEST = "test" -def process_data(file_name, data): +def process_data(file_name, compare, data): report = StubReport( - os.path.join(Folders.results, file_name), compare=app.config[COMPARE] + os.path.join(Folders.results, file_name), compare=compare ) new_list = [] for result in data["results"]: @@ -36,9 +35,9 @@ def process_data(file_name, data): return summary -@app.route("/index") +@app.route("/index/") @app.route("/") -def index(): +def index(compare="False"): # Get a list of files in a directory files = {} names = Files.get_all_results(hidden=False) @@ -57,33 +56,34 @@ def index(): files=files, candidate=candidate[0], framework=app.config[FRAMEWORK], + compare=compare.capitalize() == "True", ) @app.route("/show", methods=["post"]) def show(): selected_file = request.form["selected-file"] + compare = request.form["compare"] == "true" with open(os.path.join(Folders.results, selected_file)) as f: data = json.load(f) try: - summary = process_data(selected_file, data) + summary = process_data(selected_file, compare, data) except Exception as e: - return render_template("error.html", message=str(e)) + return render_template("error.html", message=str(e), compare=compare) return render_template( "report.html", data=data, file=selected_file, summary=summary, framework=app.config[FRAMEWORK], + compare=compare, ) @app.route("/excel", methods=["post"]) def excel(): - if request.is_json: - selected_files = request.json - else: - selected_files = request.form["selected-files"] + selected_files = request.json["selected-files"] + compare = request.json["compare"] == "true" book = None try: for file_name in selected_files: @@ -96,7 +96,7 @@ def excel(): excel = Excel( file_name=file_name_result, book=book, - compare=app.config[COMPARE], + compare=compare, ) excel.report() except Exception as e: @@ -122,8 +122,8 @@ def excel(): ) -@app.route("/config/") -def config(framework): +@app.route("/config//") +def config(framework, compare): if not framework in app.config[FRAMEWORKS]: message = f"framework {framework} not supported" return render_template("error.html", message=message) @@ -132,20 +132,13 @@ def config(framework): env.args[FRAMEWORK] = framework env.save() app.config[FRAMEWORK] = framework - return redirect(url_for("index")) + return redirect(url_for("index", compare=compare)) def main(args_test=None): - arguments = Arguments(prog="be_flask") - arguments.xset("compare") - args = arguments.parse(args_test) config = EnvData().load() app.config[FRAMEWORK] = config[FRAMEWORK] - app.config[COMPARE] = args.compare app.config[FRAMEWORKS] = ["bootstrap", "bulma"] app.config[TEST] = args_test is not None webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234) - - # Poner checkboxes para seleccionar resultados y poner un botón abajo para hacer un excel con los seleccionados - # Calcular símbolo igual que en list, o bien si ha puesto el parámetro de compare, con best o con zeror diff --git a/benchmark/scripts/templates/error.html b/benchmark/scripts/templates/error.html index a809305..999cb09 100644 --- a/benchmark/scripts/templates/error.html +++ b/benchmark/scripts/templates/error.html @@ -10,7 +10,7 @@
diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index 6ab0303..238660b 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -20,6 +20,7 @@ {% set selected = "is-selected" %} {% endif %} {% endblock %} diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 757c5f0..1787b07 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -24,7 +24,7 @@ {% set button_pre = '' %} {% set selected = "is-selected" %} - {% set align_right = "text-end" %} + {% set align_right = "has-text-right" %} {% set level = "level" %} {% set tag_class = "tag is-info is-small" %} {% set container = "container is-fluid" %} @@ -42,7 +42,8 @@ crossorigin="anonymous"> {% endif %} {% endblock %} From d8285eb2bb8bfdffaf97131ab9b12f8c9ce2758e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 31 May 2023 01:35:40 +0200 Subject: [PATCH 20/34] Add excel to report datasets --- benchmark/ResultsFiles.py | 4 +-- benchmark/scripts/be_flask.py | 8 ++++-- benchmark/scripts/templates/datasets.html | 27 ++++++++++++++++--- .../templates/partials/datasets_table.html | 4 +-- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/benchmark/ResultsFiles.py b/benchmark/ResultsFiles.py index cfa8fde..8499cc4 100644 --- a/benchmark/ResultsFiles.py +++ b/benchmark/ResultsFiles.py @@ -299,11 +299,11 @@ class ReportDatasets: color2 = "#FDE9D9" color3 = "#B1A0C7" - def __init__(self, excel=False, book=None): + def __init__(self, excel=False, book=None, output=True): self.excel = excel self.env = EnvData().load() self.close = False - self.output = True + self.output = output self.header_text = f"Datasets used in benchmark ver. {__version__}" if excel: self.max_length = 0 diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 653cf72..721c8fe 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -6,7 +6,7 @@ import xlsxwriter from benchmark.Utils import Files, Folders from benchmark.Arguments import EnvData from benchmark.ResultsBase import StubReport -from benchmark.ResultsFiles import Excel +from benchmark.ResultsFiles import Excel, ReportDatasets from benchmark.Datasets import Datasets from flask import Flask from flask import render_template, request, redirect, url_for @@ -121,7 +121,11 @@ def excel(): book = None if selected_files[0] == "datasets": # Create a list of datasets - return AjaxResponse(True, "datasets").to_string() + report = ReportDatasets(excel=True, output=False) + report.report() + excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) + Files.open(excel_name, test=app.config[TEST]) + return AjaxResponse(True, Files.datasets_report_excel).to_string() try: for file_name in selected_files: file_name_result = os.path.join(Folders.results, file_name) diff --git a/benchmark/scripts/templates/datasets.html b/benchmark/scripts/templates/datasets.html index 84063ab..809bbf0 100644 --- a/benchmark/scripts/templates/datasets.html +++ b/benchmark/scripts/templates/datasets.html @@ -6,7 +6,8 @@ {% set table_class = "table table-striped table-hover table-bordered" %} {% set head_class = "bg-primary text-white" %} {% set text_right = "text-end" %} - {% set container = "container-fluid" %} + {% set container = "container" %} + {% set selected = "selected" %} {% else %} {% set close_button = '' %} {% set button_class = "button is-primary is-small" %} @@ -14,17 +15,35 @@ {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} {% set head_class = "is-selected" %} {% set text_right = "has-text-right" %} - {% set container = "container is-fluid" %} + {% set container = "container" %} + {% set selected = "is-selected" %} {% endif %} {% block content %}
-

{{ close_button|safe }} Datasets Report

- +

{{ close_button|safe }} Benchmark Datasets Report

+ {% include "partials/datasets_table.html" %}
{% endblock %} {% block jscript %} {% endblock %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/datasets_table.html b/benchmark/scripts/templates/partials/datasets_table.html index 4bd13ab..1130914 100644 --- a/benchmark/scripts/templates/partials/datasets_table.html +++ b/benchmark/scripts/templates/partials/datasets_table.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% block content %} - +
@@ -20,7 +20,7 @@ - + {% endfor %}
Dataset{{ dataset.cont_features }} {{ dataset.classes }} {{ dataset.balance }}
From 04ea568c7108d4821c96cb1ac8b4e8808e680b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 31 May 2023 14:29:25 +0200 Subject: [PATCH 21/34] Refactor macros and font family --- benchmark/scripts/templates/base.html | 67 ------------------- .../scripts/templates/base_bootstrap.html | 55 +++++++++++++++ benchmark/scripts/templates/base_bulma.html | 42 ++++++++++++ benchmark/scripts/templates/datasets.html | 2 +- .../partials/cfg_select_bootstrap.jinja | 47 +++++++++++++ .../templates/partials/cfg_select_bulma.jinja | 46 +++++++++++++ .../templates/partials/datasets_table.html | 2 +- .../scripts/templates/partials/select.js | 8 +-- .../templates/partials/table_select.html | 9 ++- .../partials/table_select_design.html | 19 +++--- benchmark/scripts/templates/report.html | 2 +- benchmark/scripts/templates/select.html | 34 +--------- 12 files changed, 212 insertions(+), 121 deletions(-) delete mode 100644 benchmark/scripts/templates/base.html create mode 100644 benchmark/scripts/templates/base_bootstrap.html create mode 100644 benchmark/scripts/templates/base_bulma.html create mode 100644 benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja create mode 100644 benchmark/scripts/templates/partials/cfg_select_bulma.jinja diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html deleted file mode 100644 index c9c25a4..0000000 --- a/benchmark/scripts/templates/base.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - {{ title }} - {% if framework == "bootstrap" %} - - - {% else %} - - - {% endif %} - - - - - {% block content %} {% endblock %} - - - {% block jscript %} {% endblock %} - diff --git a/benchmark/scripts/templates/base_bootstrap.html b/benchmark/scripts/templates/base_bootstrap.html new file mode 100644 index 0000000..fc61da9 --- /dev/null +++ b/benchmark/scripts/templates/base_bootstrap.html @@ -0,0 +1,55 @@ + + + + {{ title }} + + + + + + + + + + + {% block content %} {% endblock %} + + + {% block jscript %} {% endblock %} + diff --git a/benchmark/scripts/templates/base_bulma.html b/benchmark/scripts/templates/base_bulma.html new file mode 100644 index 0000000..cc27f4f --- /dev/null +++ b/benchmark/scripts/templates/base_bulma.html @@ -0,0 +1,42 @@ + + + + {{ title }} + + + + + + + + {% block content %} {% endblock %} + + + {% block jscript %} {% endblock %} + diff --git a/benchmark/scripts/templates/datasets.html b/benchmark/scripts/templates/datasets.html index 809bbf0..207bde3 100644 --- a/benchmark/scripts/templates/datasets.html +++ b/benchmark/scripts/templates/datasets.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base_" ~ framework ~ ".html" %} {% if framework == "bootstrap" %} {% set close_button = '' %} {% set button_class = "btn btn-primary btn-small" %} diff --git a/benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja b/benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja new file mode 100644 index 0000000..b7e33ed --- /dev/null +++ b/benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja @@ -0,0 +1,47 @@ +{%- macro header(title) -%} +
+

{{ title }}

+
+{%- endmacro -%} +{%- macro get_table_class() -%} +table table-striped table-hover table-bordered +{%- endmacro -%} +{%- macro icon(icon) -%} + +{%- endmacro -%} +{%- macro get_button(text, action) -%} + +{%- endmacro -%} +{%- macro get_button_class() -%} + button btn-primary btn-small +{%- endmacro %} +{%- macro get_button_view(file) -%} + +{%- endmacro -%} +{%- macro get_button_reset() -%} + +{%- endmacro -%} +{%- macro get_button_all() -%} + +{%- endmacro -%} +{%- macro get_tag_class() -%} +badge bg-info bg-small +{%- endmacro -%} +{%- macro get_container_class() -%} +container-fluid +{%- endmacro -%} +{%- macro selected() -%} +selected +{%- endmacro -%} +{%- macro get_level_class() -%} +navbar +{%- endmacro -%} +{%- macro get_align_right() -%} +text-end +{%- endmacro -%} +{%- macro get_left_position() -%} +float-left +{%- endmacro -%} +{%- macro get_right_position() -%} +float-right +{%- endmacro -%} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/cfg_select_bulma.jinja b/benchmark/scripts/templates/partials/cfg_select_bulma.jinja new file mode 100644 index 0000000..47fdd89 --- /dev/null +++ b/benchmark/scripts/templates/partials/cfg_select_bulma.jinja @@ -0,0 +1,46 @@ +{%- macro header(title) -%} +
+
+

{{ title }}

+
+
+{%- endmacro -%} +{%- macro get_table_class() -%} +table is-striped is-hoverable cell-border is-bordered +{%- endmacro -%} +{%- macro icon(icon) -%} + +{%- endmacro -%} +{%- macro get_button(text, action) -%} + +{%- endmacro -%} +{%- macro get_button_view(file) -%} + +{%- endmacro -%} +{%- macro get_button_reset() -%} + +{%- endmacro -%} +{%- macro get_button_all() -%} + +{%- endmacro -%} +{%- macro get_tag_class() -%} +tag is-info is-small +{%- endmacro -%} +{%- macro get_container_class() -%} +container is-fluid +{%- endmacro -%} +{%- macro selected() -%} +is-selected +{%- endmacro -%} +{%- macro get_level_class() -%} +level +{%- endmacro -%} +{%- macro get_align_right() -%} +has-text-right +{%- endmacro -%} +{%- macro get_left_position() -%} +float-left +{%- endmacro -%} +{%- macro get_right_position() -%} +float-right +{%- endmacro -%} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/datasets_table.html b/benchmark/scripts/templates/partials/datasets_table.html index 1130914..234ac23 100644 --- a/benchmark/scripts/templates/partials/datasets_table.html +++ b/benchmark/scripts/templates/partials/datasets_table.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base_" ~ framework ~ ".html" %} {% block content %} diff --git a/benchmark/scripts/templates/partials/select.js b/benchmark/scripts/templates/partials/select.js index f4eb84f..ab76399 100644 --- a/benchmark/scripts/templates/partials/select.js +++ b/benchmark/scripts/templates/partials/select.js @@ -16,11 +16,11 @@ $(document).ready(function () { }); // Check if row is selected $('#file-table tbody').on('click', 'tr', function () { - if ($(this).hasClass('{{ selected }}')) { - $(this).removeClass('{{ selected }}'); + if ($(this).hasClass('{{ select.selected() }}')) { + $(this).removeClass('{{ select.selected() }}'); } else { - table.$('tr.{{ selected }}').removeClass('{{ selected }}'); - $(this).addClass('{{ selected }}'); + table.$('tr.{{ select.selected() }}').removeClass('{{ select.selected() }}'); + $(this).addClass('{{ select.selected() }}'); } }); // Show file with doubleclick diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index 7fac6bb..dfa1649 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -1,4 +1,4 @@ -
+
@@ -9,7 +9,7 @@ - + @@ -24,12 +24,11 @@ - + - - - - - - - - - {% for dataset, info in data.items() %} - - - - - - - {% endfor %} - -
ModelStratified Title Score{{ button_reset|safe }} {{ button_all|safe }}{{ select.get_button_reset()|safe }} {{ select.get_button_all()|safe }}
{{ parts[5] }} {{ 'True' if stratified =='1' else 'False' }} {{ "%s" % data["title"] }}{{ "%.6f" % data["score"] }}{{ "%.6f" % data["score"] }} - {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + {{ select.get_button_view(file) | safe }} diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index ad0d97e..e598d74 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,15 +1,14 @@ -
-

Benchmark Results

-
-
- - - +
+ {{ select.header("Benchmark Results") }} +
+
+ {{ select.get_button("Use " ~ candidate, "redirectIndex('" ~ candidate ~ "')")|safe }} + {{ select.get_button(select.icon("excel") ~ " Excel", "excel()")|safe }} + {{ select.get_button(select.icon("database-eye") ~ " Datasets", "redirectDatasets()")|safe }}
-
+
- Comparing with best results + Comparing with best results
{% include "partials/table_select.html" %} diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index 238660b..6c16165 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -1,5 +1,5 @@ {% set title = "Report Viewer" %} -{% extends "base.html" %} +{% extends "base_" ~ framework ~ ".html" %} {% block content%} {% if framework == "bootstrap" %} {% set center = "text-center" %} diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 1787b07..2fcd44c 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -1,36 +1,6 @@ {% set title = "Benchmark Results" %} -{% extends "base.html" %} -{% if framework == "bootstrap" %} - {% set button_class = "btn btn-primary btn-small" %} - {% set h1_class = "text-center" %} - {% set table_class = "table table-striped table-hover table-bordered" %} - {% set button_pre = '' %} - {% set selected = "selected" %} - {% set tag_class = "badge bg-info bg-small" %} - {% set frbutton_position = "float-left" %} - {% set frtag_position = "float-right" %} - {% set level = "navbar" %} - {% set align_right = "text-end" %} - {% set container = "container-fluid" %} - {% set button_reset = '' %} - {% set button_all = '' %} -{% else %} - {% set button_class = "button is-primary is-small" %} - {% set h1_class = "title is-1 has-text-centered" %} - {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} - {% set button_pre = '' %} - {% set selected = "is-selected" %} - {% set align_right = "has-text-right" %} - {% set level = "level" %} - {% set tag_class = "tag is-info is-small" %} - {% set container = "container is-fluid" %} - {% set button_reset = '' %} - {% set button_all = '' %} -{% endif %} +{% extends "base_" ~ framework ~ ".html" %} +{% import "partials/cfg_select_" ~ framework ~ ".jinja" as select %} {% block content %} {% include "partials/table_select_design.html" %} {% endblock %} From 54d141e861864dd4d0bb3b556196201e953753c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 31 May 2023 17:00:48 +0200 Subject: [PATCH 22/34] Create separate app --- benchmark/scripts/app/__init__.py | 0 benchmark/scripts/app/app.py | 174 +++++++++++++++++ benchmark/scripts/app/main.py | 175 ++++++++++++++++++ .../{ => app}/templates/base_bootstrap.html | 0 .../{ => app}/templates/base_bulma.html | 0 .../scripts/{ => app}/templates/datasets.html | 0 .../scripts/{ => app}/templates/error.html | 0 .../partials/cfg_select_bootstrap.jinja | 0 .../templates/partials/cfg_select_bulma.jinja | 0 .../templates/partials/datasets_table.html | 0 .../templates/partials/excelFiles.js | 0 .../{ => app}/templates/partials/report.js | 0 .../{ => app}/templates/partials/select.js | 0 .../templates/partials/table_report.html | 0 .../partials/table_report_bootstrap.html | 0 .../partials/table_report_bulma.html | 0 .../templates/partials/table_select.html | 0 .../partials/table_select_design.html | 1 + .../templates/partials/table_summary.html | 0 .../scripts/{ => app}/templates/report.html | 0 .../scripts/{ => app}/templates/select.html | 0 benchmark/scripts/be_flask.py | 167 +---------------- 22 files changed, 352 insertions(+), 165 deletions(-) create mode 100644 benchmark/scripts/app/__init__.py create mode 100755 benchmark/scripts/app/app.py create mode 100755 benchmark/scripts/app/main.py rename benchmark/scripts/{ => app}/templates/base_bootstrap.html (100%) rename benchmark/scripts/{ => app}/templates/base_bulma.html (100%) rename benchmark/scripts/{ => app}/templates/datasets.html (100%) rename benchmark/scripts/{ => app}/templates/error.html (100%) rename benchmark/scripts/{ => app}/templates/partials/cfg_select_bootstrap.jinja (100%) rename benchmark/scripts/{ => app}/templates/partials/cfg_select_bulma.jinja (100%) rename benchmark/scripts/{ => app}/templates/partials/datasets_table.html (100%) rename benchmark/scripts/{ => app}/templates/partials/excelFiles.js (100%) rename benchmark/scripts/{ => app}/templates/partials/report.js (100%) rename benchmark/scripts/{ => app}/templates/partials/select.js (100%) rename benchmark/scripts/{ => app}/templates/partials/table_report.html (100%) rename benchmark/scripts/{ => app}/templates/partials/table_report_bootstrap.html (100%) rename benchmark/scripts/{ => app}/templates/partials/table_report_bulma.html (100%) rename benchmark/scripts/{ => app}/templates/partials/table_select.html (100%) rename benchmark/scripts/{ => app}/templates/partials/table_select_design.html (87%) rename benchmark/scripts/{ => app}/templates/partials/table_summary.html (100%) rename benchmark/scripts/{ => app}/templates/report.html (100%) rename benchmark/scripts/{ => app}/templates/select.html (100%) diff --git a/benchmark/scripts/app/__init__.py b/benchmark/scripts/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/benchmark/scripts/app/app.py b/benchmark/scripts/app/app.py new file mode 100755 index 0000000..5d85890 --- /dev/null +++ b/benchmark/scripts/app/app.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python +import os +import json +import xlsxwriter +from benchmark.Utils import Files, Folders +from benchmark.Arguments import EnvData +from benchmark.ResultsBase import StubReport +from benchmark.ResultsFiles import Excel, ReportDatasets +from benchmark.Datasets import Datasets +from flask import Flask, render_template, request, redirect, url_for + + +app = Flask(__name__) +FRAMEWORK = "framework" +FRAMEWORKS = "frameworks" +TEST = "test" + + +class AjaxResponse: + def __init__(self, success, file_name, code=200): + self.success = success + self.file_name = file_name + self.code = code + + def to_string(self): + return ( + json.dumps( + { + "success": self.success, + "file": self.file_name, + } + ), + self.code, + {"ContentType": "application/json"}, + ) + + +def process_data(file_name, compare, data): + report = StubReport( + os.path.join(Folders.results, file_name), compare=compare + ) + new_list = [] + for result in data["results"]: + symbol = report._compute_status(result["dataset"], result["score"]) + result["symbol"] = symbol if symbol != " " else " " + new_list.append(result) + data["results"] = new_list + # Compute summary with explanation of symbols + summary = {} + for key, value in report._compare_totals.items(): + summary[key] = (report._status_meaning(key), value) + return summary + + +@app.route("/index/") +@app.route("/") +def index(compare="False"): + # Get a list of files in a directory + 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.remove(app.config[FRAMEWORK]) + return render_template( + "select.html", + files=files, + candidate=candidate[0], + framework=app.config[FRAMEWORK], + compare=compare.capitalize() == "True", + ) + + +@app.route("/datasets/") +def datasets(compare): + dt = Datasets() + datos = [] + for dataset in dt: + datos.append(dt.get_attributes(dataset)) + return render_template( + "datasets.html", + datasets=datos, + compare=compare, + framework=app.config[FRAMEWORK], + ) + +@app.route("/showfile//") +def showfile(file_name, compare): + compare = compare.capitalize() == "True" + with open(os.path.join(Folders.results, file_name)) as f: + data = json.load(f) + try: + summary = process_data(file_name, compare, data) + except Exception as e: + return render_template("error.html", message=str(e), compare=compare) + return render_template( + "report.html", + data=data, + file=file_name, + summary=summary, + framework=app.config[FRAMEWORK], + compare=compare, + ) + +@app.route("/show", methods=["post"]) +def show(): + selected_file = request.form["selected-file"] + compare = request.form["compare"] + return showfile(selected_file, compare) + + + +@app.route("/excel", methods=["post"]) +def excel(): + selected_files = request.json["selectedFiles"] + compare = request.json["compare"] + book = None + if selected_files[0] == "datasets": + # Create a list of datasets + report = ReportDatasets(excel=True, output=False) + report.report() + excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) + Files.open(excel_name, test=app.config[TEST]) + return AjaxResponse(True, Files.datasets_report_excel).to_string() + try: + for file_name in selected_files: + file_name_result = os.path.join(Folders.results, file_name) + if book is None: + file_excel = os.path.join(Folders.excel, Files.be_list_excel) + book = xlsxwriter.Workbook( + file_excel, {"nan_inf_to_errors": True} + ) + excel = Excel( + file_name=file_name_result, + book=book, + compare=compare, + ) + excel.report() + except Exception as e: + if book is not None: + book.close() + return AjaxResponse( + False, "Could not create excel file, " + str(e) + ).to_string() + if book is not None: + book.close() + Files.open(file_excel, test=app.config[TEST]) + return AjaxResponse(True, Files.be_list_excel).to_string() + + +@app.route("/config//") +def config(framework, compare): + if not framework in app.config[FRAMEWORKS]: + message = f"framework {framework} not supported" + return render_template("error.html", message=message) + env = EnvData() + env.load() + env.args[FRAMEWORK] = framework + env.save() + app.config[FRAMEWORK] = framework + return redirect(url_for("index", compare=compare)) + + +def create_app(): + config = EnvData().load() + app.config[FRAMEWORK] = config[FRAMEWORK] + app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + return app diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py new file mode 100755 index 0000000..8486cef --- /dev/null +++ b/benchmark/scripts/app/main.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python +import os +import json +import xlsxwriter +from benchmark.Utils import Files, Folders +from benchmark.Arguments import EnvData +from benchmark.ResultsBase import StubReport +from benchmark.ResultsFiles import Excel, ReportDatasets +from benchmark.Datasets import Datasets +from flask import Blueprint +from flask import render_template, request, redirect, url_for + + +main = Blueprint("main", __name__) +FRAMEWORK = "framework" +FRAMEWORKS = "frameworks" +TEST = "test" + + +class AjaxResponse: + def __init__(self, success, file_name, code=200): + self.success = success + self.file_name = file_name + self.code = code + + def to_string(self): + return ( + json.dumps( + { + "success": self.success, + "file": self.file_name, + } + ), + self.code, + {"ContentType": "application/json"}, + ) + + +def process_data(file_name, compare, data): + report = StubReport( + os.path.join(Folders.results, file_name), compare=compare + ) + new_list = [] + for result in data["results"]: + symbol = report._compute_status(result["dataset"], result["score"]) + result["symbol"] = symbol if symbol != " " else " " + new_list.append(result) + data["results"] = new_list + # Compute summary with explanation of symbols + summary = {} + for key, value in report._compare_totals.items(): + summary[key] = (report._status_meaning(key), value) + return summary + + +@main.route("/index/") +@main.route("/") +def index(compare="False"): + # Get a list of files in a directory + 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.remove(app.config[FRAMEWORK]) + return render_template( + "select.html", + files=files, + candidate=candidate[0], + framework=app.config[FRAMEWORK], + compare=compare.capitalize() == "True", + ) + + +@main.route("/datasets/") +def datasets(compare): + dt = Datasets() + datos = [] + for dataset in dt: + datos.append(dt.get_attributes(dataset)) + return render_template( + "datasets.html", + datasets=datos, + compare=compare, + framework=app.config[FRAMEWORK], + ) + +@main.route("/showfile//") +def showfile(file_name, compare): + compare = compare.capitalize() == "True" + with open(os.path.join(Folders.results, file_name)) as f: + data = json.load(f) + try: + summary = process_data(file_name, compare, data) + except Exception as e: + return render_template("error.html", message=str(e), compare=compare) + return render_template( + "report.html", + data=data, + file=file_name, + summary=summary, + framework=app.config[FRAMEWORK], + compare=compare, + ) + +@main.route("/show", methods=["post"]) +def show(): + selected_file = request.form["selected-file"] + compare = request.form["compare"] + return showfile(selected_file, compare) + + + +@main.route("/excel", methods=["post"]) +def excel(): + selected_files = request.json["selectedFiles"] + compare = request.json["compare"] + book = None + if selected_files[0] == "datasets": + # Create a list of datasets + report = ReportDatasets(excel=True, output=False) + report.report() + excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) + Files.open(excel_name, test=app.config[TEST]) + return AjaxResponse(True, Files.datasets_report_excel).to_string() + try: + for file_name in selected_files: + file_name_result = os.path.join(Folders.results, file_name) + if book is None: + file_excel = os.path.join(Folders.excel, Files.be_list_excel) + book = xlsxwriter.Workbook( + file_excel, {"nan_inf_to_errors": True} + ) + excel = Excel( + file_name=file_name_result, + book=book, + compare=compare, + ) + excel.report() + except Exception as e: + if book is not None: + book.close() + return AjaxResponse( + False, "Could not create excel file, " + str(e) + ).to_string() + if book is not None: + book.close() + Files.open(file_excel, test=app.config[TEST]) + return AjaxResponse(True, Files.be_list_excel).to_string() + + +@main.route("/config//") +def config(framework, compare): + if not framework in app.config[FRAMEWORKS]: + message = f"framework {framework} not supported" + return render_template("error.html", message=message) + env = EnvData() + env.load() + env.args[FRAMEWORK] = framework + env.save() + app.config[FRAMEWORK] = framework + return redirect(url_for("index", compare=compare)) + + +def create_app(): + config = EnvData().load() + app.config[FRAMEWORK] = config[FRAMEWORK] + app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + return app diff --git a/benchmark/scripts/templates/base_bootstrap.html b/benchmark/scripts/app/templates/base_bootstrap.html similarity index 100% rename from benchmark/scripts/templates/base_bootstrap.html rename to benchmark/scripts/app/templates/base_bootstrap.html diff --git a/benchmark/scripts/templates/base_bulma.html b/benchmark/scripts/app/templates/base_bulma.html similarity index 100% rename from benchmark/scripts/templates/base_bulma.html rename to benchmark/scripts/app/templates/base_bulma.html diff --git a/benchmark/scripts/templates/datasets.html b/benchmark/scripts/app/templates/datasets.html similarity index 100% rename from benchmark/scripts/templates/datasets.html rename to benchmark/scripts/app/templates/datasets.html diff --git a/benchmark/scripts/templates/error.html b/benchmark/scripts/app/templates/error.html similarity index 100% rename from benchmark/scripts/templates/error.html rename to benchmark/scripts/app/templates/error.html diff --git a/benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja similarity index 100% rename from benchmark/scripts/templates/partials/cfg_select_bootstrap.jinja rename to benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja diff --git a/benchmark/scripts/templates/partials/cfg_select_bulma.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja similarity index 100% rename from benchmark/scripts/templates/partials/cfg_select_bulma.jinja rename to benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja diff --git a/benchmark/scripts/templates/partials/datasets_table.html b/benchmark/scripts/app/templates/partials/datasets_table.html similarity index 100% rename from benchmark/scripts/templates/partials/datasets_table.html rename to benchmark/scripts/app/templates/partials/datasets_table.html diff --git a/benchmark/scripts/templates/partials/excelFiles.js b/benchmark/scripts/app/templates/partials/excelFiles.js similarity index 100% rename from benchmark/scripts/templates/partials/excelFiles.js rename to benchmark/scripts/app/templates/partials/excelFiles.js diff --git a/benchmark/scripts/templates/partials/report.js b/benchmark/scripts/app/templates/partials/report.js similarity index 100% rename from benchmark/scripts/templates/partials/report.js rename to benchmark/scripts/app/templates/partials/report.js diff --git a/benchmark/scripts/templates/partials/select.js b/benchmark/scripts/app/templates/partials/select.js similarity index 100% rename from benchmark/scripts/templates/partials/select.js rename to benchmark/scripts/app/templates/partials/select.js diff --git a/benchmark/scripts/templates/partials/table_report.html b/benchmark/scripts/app/templates/partials/table_report.html similarity index 100% rename from benchmark/scripts/templates/partials/table_report.html rename to benchmark/scripts/app/templates/partials/table_report.html diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/app/templates/partials/table_report_bootstrap.html similarity index 100% rename from benchmark/scripts/templates/partials/table_report_bootstrap.html rename to benchmark/scripts/app/templates/partials/table_report_bootstrap.html diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/app/templates/partials/table_report_bulma.html similarity index 100% rename from benchmark/scripts/templates/partials/table_report_bulma.html rename to benchmark/scripts/app/templates/partials/table_report_bulma.html diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/app/templates/partials/table_select.html similarity index 100% rename from benchmark/scripts/templates/partials/table_select.html rename to benchmark/scripts/app/templates/partials/table_select.html diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/app/templates/partials/table_select_design.html similarity index 87% rename from benchmark/scripts/templates/partials/table_select_design.html rename to benchmark/scripts/app/templates/partials/table_select_design.html index e598d74..c4714ed 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/app/templates/partials/table_select_design.html @@ -5,6 +5,7 @@ {{ select.get_button("Use " ~ candidate, "redirectIndex('" ~ candidate ~ "')")|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("star-circle-outline") ~ " Best results", "{{ url_for('best_results')}}")}}
diff --git a/benchmark/scripts/templates/partials/table_summary.html b/benchmark/scripts/app/templates/partials/table_summary.html similarity index 100% rename from benchmark/scripts/templates/partials/table_summary.html rename to benchmark/scripts/app/templates/partials/table_summary.html diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/app/templates/report.html similarity index 100% rename from benchmark/scripts/templates/report.html rename to benchmark/scripts/app/templates/report.html diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/app/templates/select.html similarity index 100% rename from benchmark/scripts/templates/select.html rename to benchmark/scripts/app/templates/select.html diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 721c8fe..5573241 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -1,174 +1,11 @@ #!/usr/bin/env python -import os -import json import webbrowser -import xlsxwriter -from benchmark.Utils import Files, Folders -from benchmark.Arguments import EnvData -from benchmark.ResultsBase import StubReport -from benchmark.ResultsFiles import Excel, ReportDatasets -from benchmark.Datasets import Datasets -from flask import Flask -from flask import render_template, request, redirect, url_for - +from benchmark.scripts.app.app import create_app, TEST # Launch a flask server to serve the results -app = Flask(__name__) -FRAMEWORK = "framework" -FRAMEWORKS = "frameworks" -TEST = "test" - - -class AjaxResponse: - def __init__(self, success, file_name, code=200): - self.success = success - self.file_name = file_name - self.code = code - - def to_string(self): - return ( - json.dumps( - { - "success": self.success, - "file": self.file_name, - } - ), - self.code, - {"ContentType": "application/json"}, - ) - - -def process_data(file_name, compare, data): - report = StubReport( - os.path.join(Folders.results, file_name), compare=compare - ) - new_list = [] - for result in data["results"]: - symbol = report._compute_status(result["dataset"], result["score"]) - result["symbol"] = symbol if symbol != " " else " " - new_list.append(result) - data["results"] = new_list - # Compute summary with explanation of symbols - summary = {} - for key, value in report._compare_totals.items(): - summary[key] = (report._status_meaning(key), value) - return summary - - -@app.route("/index/") -@app.route("/") -def index(compare="False"): - # Get a list of files in a directory - 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.remove(app.config[FRAMEWORK]) - return render_template( - "select.html", - files=files, - candidate=candidate[0], - framework=app.config[FRAMEWORK], - compare=compare.capitalize() == "True", - ) - - -@app.route("/datasets/") -def datasets(compare): - dt = Datasets() - datos = [] - for dataset in dt: - datos.append(dt.get_attributes(dataset)) - return render_template( - "datasets.html", - datasets=datos, - compare=compare, - framework=app.config[FRAMEWORK], - ) - - -@app.route("/show", methods=["post"]) -def show(): - selected_file = request.form["selected-file"] - compare = request.form["compare"].capitalize() == "True" - with open(os.path.join(Folders.results, selected_file)) as f: - data = json.load(f) - try: - summary = process_data(selected_file, compare, data) - except Exception as e: - return render_template("error.html", message=str(e), compare=compare) - return render_template( - "report.html", - data=data, - file=selected_file, - summary=summary, - framework=app.config[FRAMEWORK], - compare=compare, - ) - - -@app.route("/excel", methods=["post"]) -def excel(): - selected_files = request.json["selectedFiles"] - compare = request.json["compare"] - book = None - if selected_files[0] == "datasets": - # Create a list of datasets - report = ReportDatasets(excel=True, output=False) - report.report() - excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) - Files.open(excel_name, test=app.config[TEST]) - return AjaxResponse(True, Files.datasets_report_excel).to_string() - try: - for file_name in selected_files: - file_name_result = os.path.join(Folders.results, file_name) - if book is None: - file_excel = os.path.join(Folders.excel, Files.be_list_excel) - book = xlsxwriter.Workbook( - file_excel, {"nan_inf_to_errors": True} - ) - excel = Excel( - file_name=file_name_result, - book=book, - compare=compare, - ) - excel.report() - except Exception as e: - if book is not None: - book.close() - return AjaxResponse( - False, "Could not create excel file, " + str(e) - ).to_string() - if book is not None: - book.close() - Files.open(file_excel, test=app.config[TEST]) - return AjaxResponse(True, Files.be_list_excel).to_string() - - -@app.route("/config//") -def config(framework, compare): - if not framework in app.config[FRAMEWORKS]: - message = f"framework {framework} not supported" - return render_template("error.html", message=message) - env = EnvData() - env.load() - env.args[FRAMEWORK] = framework - env.save() - app.config[FRAMEWORK] = framework - return redirect(url_for("index", compare=compare)) - def main(args_test=None): - config = EnvData().load() - app.config[FRAMEWORK] = config[FRAMEWORK] - app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + app = create_app() app.config[TEST] = args_test is not None webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234) From 7d5f3058c354683be0125f602870a8078c710ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 31 May 2023 17:21:35 +0200 Subject: [PATCH 23/34] add blueprint to app --- benchmark/scripts/app/app.py | 165 +--------------------------------- benchmark/scripts/app/main.py | 30 +++---- 2 files changed, 16 insertions(+), 179 deletions(-) diff --git a/benchmark/scripts/app/app.py b/benchmark/scripts/app/app.py index 5d85890..46258da 100755 --- a/benchmark/scripts/app/app.py +++ b/benchmark/scripts/app/app.py @@ -1,174 +1,17 @@ #!/usr/bin/env python -import os -import json -import xlsxwriter -from benchmark.Utils import Files, Folders from benchmark.Arguments import EnvData -from benchmark.ResultsBase import StubReport -from benchmark.ResultsFiles import Excel, ReportDatasets -from benchmark.Datasets import Datasets -from flask import Flask, render_template, request, redirect, url_for +from flask import Flask +from .main import main - -app = Flask(__name__) FRAMEWORK = "framework" FRAMEWORKS = "frameworks" TEST = "test" -class AjaxResponse: - def __init__(self, success, file_name, code=200): - self.success = success - self.file_name = file_name - self.code = code - - def to_string(self): - return ( - json.dumps( - { - "success": self.success, - "file": self.file_name, - } - ), - self.code, - {"ContentType": "application/json"}, - ) - - -def process_data(file_name, compare, data): - report = StubReport( - os.path.join(Folders.results, file_name), compare=compare - ) - new_list = [] - for result in data["results"]: - symbol = report._compute_status(result["dataset"], result["score"]) - result["symbol"] = symbol if symbol != " " else " " - new_list.append(result) - data["results"] = new_list - # Compute summary with explanation of symbols - summary = {} - for key, value in report._compare_totals.items(): - summary[key] = (report._status_meaning(key), value) - return summary - - -@app.route("/index/") -@app.route("/") -def index(compare="False"): - # Get a list of files in a directory - 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.remove(app.config[FRAMEWORK]) - return render_template( - "select.html", - files=files, - candidate=candidate[0], - framework=app.config[FRAMEWORK], - compare=compare.capitalize() == "True", - ) - - -@app.route("/datasets/") -def datasets(compare): - dt = Datasets() - datos = [] - for dataset in dt: - datos.append(dt.get_attributes(dataset)) - return render_template( - "datasets.html", - datasets=datos, - compare=compare, - framework=app.config[FRAMEWORK], - ) - -@app.route("/showfile//") -def showfile(file_name, compare): - compare = compare.capitalize() == "True" - with open(os.path.join(Folders.results, file_name)) as f: - data = json.load(f) - try: - summary = process_data(file_name, compare, data) - except Exception as e: - return render_template("error.html", message=str(e), compare=compare) - return render_template( - "report.html", - data=data, - file=file_name, - summary=summary, - framework=app.config[FRAMEWORK], - compare=compare, - ) - -@app.route("/show", methods=["post"]) -def show(): - selected_file = request.form["selected-file"] - compare = request.form["compare"] - return showfile(selected_file, compare) - - - -@app.route("/excel", methods=["post"]) -def excel(): - selected_files = request.json["selectedFiles"] - compare = request.json["compare"] - book = None - if selected_files[0] == "datasets": - # Create a list of datasets - report = ReportDatasets(excel=True, output=False) - report.report() - excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) - Files.open(excel_name, test=app.config[TEST]) - return AjaxResponse(True, Files.datasets_report_excel).to_string() - try: - for file_name in selected_files: - file_name_result = os.path.join(Folders.results, file_name) - if book is None: - file_excel = os.path.join(Folders.excel, Files.be_list_excel) - book = xlsxwriter.Workbook( - file_excel, {"nan_inf_to_errors": True} - ) - excel = Excel( - file_name=file_name_result, - book=book, - compare=compare, - ) - excel.report() - except Exception as e: - if book is not None: - book.close() - return AjaxResponse( - False, "Could not create excel file, " + str(e) - ).to_string() - if book is not None: - book.close() - Files.open(file_excel, test=app.config[TEST]) - return AjaxResponse(True, Files.be_list_excel).to_string() - - -@app.route("/config//") -def config(framework, compare): - if not framework in app.config[FRAMEWORKS]: - message = f"framework {framework} not supported" - return render_template("error.html", message=message) - env = EnvData() - env.load() - env.args[FRAMEWORK] = framework - env.save() - app.config[FRAMEWORK] = framework - return redirect(url_for("index", compare=compare)) - - def create_app(): + app = Flask(__name__) config = EnvData().load() + app.register_blueprint(main) app.config[FRAMEWORK] = config[FRAMEWORK] app.config[FRAMEWORKS] = ["bootstrap", "bulma"] return app diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py index 8486cef..c858c0e 100755 --- a/benchmark/scripts/app/main.py +++ b/benchmark/scripts/app/main.py @@ -7,7 +7,7 @@ from benchmark.Arguments import EnvData from benchmark.ResultsBase import StubReport from benchmark.ResultsFiles import Excel, ReportDatasets from benchmark.Datasets import Datasets -from flask import Blueprint +from flask import Blueprint, current_app from flask import render_template, request, redirect, url_for @@ -67,13 +67,13 @@ def index(compare="False"): "score": report.score, "title": report.title, } - candidate = app.config[FRAMEWORKS].copy() - candidate.remove(app.config[FRAMEWORK]) + candidate = current_app.config[FRAMEWORKS].copy() + candidate.remove(current_app.config[FRAMEWORK]) return render_template( "select.html", files=files, candidate=candidate[0], - framework=app.config[FRAMEWORK], + framework=current_app.config[FRAMEWORK], compare=compare.capitalize() == "True", ) @@ -88,12 +88,12 @@ def datasets(compare): "datasets.html", datasets=datos, compare=compare, - framework=app.config[FRAMEWORK], + framework=current_app.config[FRAMEWORK], ) @main.route("/showfile//") def showfile(file_name, compare): - compare = compare.capitalize() == "True" + compare = compare.capitalize() == "True" with open(os.path.join(Folders.results, file_name)) as f: data = json.load(f) try: @@ -105,7 +105,7 @@ def showfile(file_name, compare): data=data, file=file_name, summary=summary, - framework=app.config[FRAMEWORK], + framework=current_app.config[FRAMEWORK], compare=compare, ) @@ -127,7 +127,7 @@ def excel(): report = ReportDatasets(excel=True, output=False) report.report() excel_name = os.path.join(Folders.excel, Files.datasets_report_excel) - Files.open(excel_name, test=app.config[TEST]) + Files.open(excel_name, test=current_app.config[TEST]) return AjaxResponse(True, Files.datasets_report_excel).to_string() try: for file_name in selected_files: @@ -151,25 +151,19 @@ def excel(): ).to_string() if book is not None: book.close() - Files.open(file_excel, test=app.config[TEST]) + Files.open(file_excel, test=current_app.config[TEST]) return AjaxResponse(True, Files.be_list_excel).to_string() @main.route("/config//") def config(framework, compare): - if not framework in app.config[FRAMEWORKS]: + if not framework in current_app.config[FRAMEWORKS]: message = f"framework {framework} not supported" return render_template("error.html", message=message) env = EnvData() env.load() env.args[FRAMEWORK] = framework env.save() - app.config[FRAMEWORK] = framework - return redirect(url_for("index", compare=compare)) + current_app.config[FRAMEWORK] = framework + return redirect(url_for("main.index", compare=compare)) - -def create_app(): - config = EnvData().load() - app.config[FRAMEWORK] = config[FRAMEWORK] - app.config[FRAMEWORKS] = ["bootstrap", "bulma"] - return app From a51fed6281e19bd22ede43ac37e96a43fe35cb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 31 May 2023 23:30:51 +0200 Subject: [PATCH 24/34] Begin best results report --- benchmark/scripts/app/app.py | 2 + benchmark/scripts/app/main.py | 25 ++- .../partials/cfg_select_bootstrap.jinja | 8 +- .../templates/partials/cfg_select_bulma.jinja | 8 +- .../scripts/app/templates/partials/select.js | 148 ++++++++++-------- .../partials/table_report_bootstrap.html | 2 +- .../partials/table_report_bulma.html | 2 +- .../app/templates/partials/table_select.html | 4 +- .../partials/table_select_design.html | 7 +- .../scripts/app/templates/report_best.html | 23 +++ 10 files changed, 149 insertions(+), 80 deletions(-) create mode 100644 benchmark/scripts/app/templates/report_best.html diff --git a/benchmark/scripts/app/app.py b/benchmark/scripts/app/app.py index 46258da..8b286cb 100755 --- a/benchmark/scripts/app/app.py +++ b/benchmark/scripts/app/app.py @@ -14,4 +14,6 @@ def create_app(): app.register_blueprint(main) app.config[FRAMEWORK] = config[FRAMEWORK] app.config[FRAMEWORKS] = ["bootstrap", "bulma"] + app.jinja_env.auto_reload = True + app.config["TEMPLATES_AUTO_RELOAD"] = True return app diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py index c858c0e..3c71260 100755 --- a/benchmark/scripts/app/main.py +++ b/benchmark/scripts/app/main.py @@ -91,9 +91,12 @@ def datasets(compare): framework=current_app.config[FRAMEWORK], ) + @main.route("/showfile//") -def showfile(file_name, compare): +def showfile(file_name, compare, back=None): 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: data = json.load(f) try: @@ -106,15 +109,19 @@ def showfile(file_name, compare): file=file_name, summary=summary, framework=current_app.config[FRAMEWORK], - compare=compare, + back=back, ) + @main.route("/show", methods=["post"]) def show(): selected_file = request.form["selected-file"] 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"]) @@ -167,3 +174,13 @@ def config(framework, compare): current_app.config[FRAMEWORK] = framework return redirect(url_for("main.index", compare=compare)) + +@main.route("/best_results//") +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) diff --git a/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja index b7e33ed..f530810 100644 --- a/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja +++ b/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja @@ -6,8 +6,8 @@ {%- macro get_table_class() -%} table table-striped table-hover table-bordered {%- endmacro -%} -{%- macro icon(icon) -%} - +{%- macro icon(icon_name) -%} + {%- endmacro -%} {%- macro get_button(text, action) -%} @@ -15,8 +15,8 @@ table table-striped table-hover table-bordered {%- macro get_button_class() -%} button btn-primary btn-small {%- endmacro %} -{%- macro get_button_view(file) -%} - +{%- macro get_button_tag(icon_name, method, visible=True, name="") -%} + {%- endmacro -%} {%- macro get_button_reset() -%} diff --git a/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja index 47fdd89..862074a 100644 --- a/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja +++ b/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja @@ -8,14 +8,14 @@ {%- macro get_table_class() -%} table is-striped is-hoverable cell-border is-bordered {%- endmacro -%} -{%- macro icon(icon) -%} - +{%- macro icon(icon_name) -%} + {%- endmacro -%} {%- macro get_button(text, action) -%} {%- endmacro -%} -{%- macro get_button_view(file) -%} - +{%- macro get_button_tag(icon_name, method, visible=True, name="") -%} + {{icon(icon_name)}} {%- endmacro -%} {%- macro get_button_reset() -%} diff --git a/benchmark/scripts/app/templates/partials/select.js b/benchmark/scripts/app/templates/partials/select.js index ab76399..4baf072 100644 --- a/benchmark/scripts/app/templates/partials/select.js +++ b/benchmark/scripts/app/templates/partials/select.js @@ -1,71 +1,97 @@ $(document).ready(function () { - var table = $('#file-table').DataTable({ - "paging": true, - "searching": true, - "ordering": true, - "info": true, - "select.items": "row", - "pageLength": 25, - "columnDefs": [{ - "targets": 8, - "orderable": false - }], - //"language": { - // "lengthMenu": "_MENU_" - //} - }); - // Check if row is selected - $('#file-table tbody').on('click', 'tr', function () { - if ($(this).hasClass('{{ select.selected() }}')) { - $(this).removeClass('{{ select.selected() }}'); - } else { - table.$('tr.{{ select.selected() }}').removeClass('{{ select.selected() }}'); - $(this).addClass('{{ select.selected() }}'); - } - }); - // Show file with doubleclick - $('#file-table tbody').on('dblclick', 'tr', function () { - showFile($(this).attr("id")); - }); - $(document).ajaxStart(function(){ - $("body").addClass('ajaxLoading'); - }); - $(document).ajaxStop(function(){ - $("body").removeClass('ajaxLoading'); - }); + var table = $("#file-table").DataTable({ + paging: true, + searching: true, + ordering: true, + info: true, + "select.items": "row", + pageLength: 25, + columnDefs: [ + { + targets: 8, + orderable: false, + }, + ], + //"language": { + // "lengthMenu": "_MENU_" + //} + }); + // Check if row is selected + $("#file-table tbody").on("click", "tr", function () { + if ($(this).hasClass("{{ select.selected() }}")) { + $(this).removeClass("{{ select.selected() }}"); + } else { + table + .$("tr.{{ select.selected() }}") + .removeClass("{{ select.selected() }}"); + $(this).addClass("{{ select.selected() }}"); + } + }); + // Show file with doubleclick + $("#file-table tbody").on("dblclick", "tr", function () { + showFile($(this).attr("id")); + }); + $(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) { - var form = $('
' + - '' + - '' + - '
'); - $('body').append(form); - form.submit(); + var form = $( + '
' + + '' + + '
- +

{{ data.title }}

diff --git a/benchmark/scripts/app/templates/partials/table_report_bulma.html b/benchmark/scripts/app/templates/partials/table_report_bulma.html index 886f184..86859e7 100644 --- a/benchmark/scripts/app/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/app/templates/partials/table_report_bulma.html @@ -3,7 +3,7 @@
- +

{{ data.title }}

diff --git a/benchmark/scripts/app/templates/partials/table_select.html b/benchmark/scripts/app/templates/partials/table_select.html index dfa1649..f74e4b4 100644 --- a/benchmark/scripts/app/templates/partials/table_select.html +++ b/benchmark/scripts/app/templates/partials/table_select.html @@ -26,7 +26,9 @@
{{ "%s" % data["title"] }} {{ "%.6f" % data["score"] }} - {{ 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 }}
- {{ 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("database-eye") ~ " Datasets", "redirectDatasets()")|safe }} - {{ select.get_button(select.icon("star-circle-outline") ~ " Best results", "{{ url_for('best_results')}}")}} + {{ select.get_button(select.icon("database-eye") ~ " Datasets", "redirectSimple('datasets')")|safe }}
-
+
Comparing with best results
diff --git a/benchmark/scripts/app/templates/report_best.html b/benchmark/scripts/app/templates/report_best.html new file mode 100644 index 0000000..b4092ab --- /dev/null +++ b/benchmark/scripts/app/templates/report_best.html @@ -0,0 +1,23 @@ + + + + + + + + + + + {% for dataset, info in data.items() %} + + + + + + + {% endfor %} + +
DatasetScoreHyperparametersFile
{{ dataset }}{{ '%9.7f' % info[0] }}{{ info[1] }} + {% set url = url_for(request.endpoint, **request.view_args)|urlencode %} + {{ info[2] }} +
From f7ed11562b19a2e0a4753e6bea6f4c52bbcd48dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 1 Jun 2023 01:11:06 +0200 Subject: [PATCH 25/34] Add format to report_best --- benchmark/scripts/app/main.py | 7 +- .../partials/cfg_select_bootstrap.jinja | 11 ++- .../templates/partials/cfg_select_bulma.jinja | 14 +++- .../app/templates/partials/table_select.html | 2 +- .../scripts/app/templates/report_best.html | 70 +++++++++++++------ 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py index 3c71260..5032cc1 100755 --- a/benchmark/scripts/app/main.py +++ b/benchmark/scripts/app/main.py @@ -183,4 +183,9 @@ def best_results(file, compare): 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) + return render_template( + "report_best.html", + data=data, + compare=compare, + framework=current_app.config[FRAMEWORK], + ) diff --git a/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja index f530810..a4ceef5 100644 --- a/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja +++ b/benchmark/scripts/app/templates/partials/cfg_select_bootstrap.jinja @@ -1,5 +1,8 @@ -{%- macro header(title) -%} +{%- macro header(title, close=False, url="") -%}
+{%- if close -%} + +{%- endif -%}

{{ title }}

{%- endmacro -%} @@ -44,4 +47,10 @@ float-left {%- endmacro -%} {%- macro get_right_position() -%} float-right +{%- endmacro -%} +{%- macro get_row_head_class() -%} +bg-primary text-white +{%- endmacro -%} +{%- macro get_align_center() -%} +text-center {%- endmacro -%} \ No newline at end of file diff --git a/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja b/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja index 862074a..9c75baf 100644 --- a/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja +++ b/benchmark/scripts/app/templates/partials/cfg_select_bulma.jinja @@ -1,6 +1,9 @@ -{%- macro header(title) -%} +{%- macro header(title, close=False, url="") -%}
+ {%- if close -%} + + {%- endif -%}

{{ title }}

@@ -38,9 +41,18 @@ level {%- macro get_align_right() -%} has-text-right {%- endmacro -%} +{%- macro get_align_center() -%} +has-text-center +{%- endmacro -%} {%- macro get_left_position() -%} float-left {%- endmacro -%} {%- macro get_right_position() -%} float-right +{%- endmacro -%} +{%- macro get_row_head_class() -%} +is-selected +{%- endmacro -%} +{%- macro get_align_center() -%} +has-text-center {%- endmacro -%} \ No newline at end of file diff --git a/benchmark/scripts/app/templates/partials/table_select.html b/benchmark/scripts/app/templates/partials/table_select.html index f74e4b4..9c74d04 100644 --- a/benchmark/scripts/app/templates/partials/table_select.html +++ b/benchmark/scripts/app/templates/partials/table_select.html @@ -26,7 +26,7 @@
{{ "%s" % data["title"] }} {{ "%.6f" % data["score"] }} - {{ select.get_button_tag("eye", "showFile('" ~ file ~ "')") | safe }} + {{ select.get_button_tag("table-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 }} -
DatasetScoreHyperparametersFile
{{ dataset }}{{ '%9.7f' % info[0] }}{{ info[1] }} - {% set url = url_for(request.endpoint, **request.view_args)|urlencode %} - {{ info[2] }} -
+{% set title = "Best Results" %} +{% extends "base_" ~ framework ~ ".html" %} +{% import "partials/cfg_select_" ~ framework ~ ".jinja" as select %} +{% block content %} + {{ select.header(title, True, url_for("main.index", compare=compare)) }} + + + + + + + + + + + + {% for dataset, info in data.items() %} + + + + + + + {% endfor %} + +
DatasetScoreHyperparametersFile
{{ dataset }}{{ '%9.7f' % info[0] }}{{ info[1] }} + {% set url = url_for(request.endpoint, **request.view_args)|urlencode %} + {{ info[2] }} +
+
+{% endblock %} +{% block jscript %} + +{% endblock %} + From b7d26b82b1577fab5ff0b321bce57c8e304f6f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 1 Jun 2023 01:14:38 +0200 Subject: [PATCH 26/34] flavour fix --- benchmark/scripts/app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py index 5032cc1..999d28b 100755 --- a/benchmark/scripts/app/main.py +++ b/benchmark/scripts/app/main.py @@ -164,7 +164,7 @@ def excel(): @main.route("/config//") def config(framework, compare): - if not framework in current_app.config[FRAMEWORKS]: + if framework not in current_app.config[FRAMEWORKS]: message = f"framework {framework} not supported" return render_template("error.html", message=message) env = EnvData() From aeec3a65af0b77e8a57665a35c64e9d1dca083c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 1 Jun 2023 01:49:23 +0200 Subject: [PATCH 27/34] Fix checkboxes on change page --- benchmark/scripts/app/templates/datasets.html | 58 ++++++++++++------- .../scripts/app/templates/partials/select.js | 28 ++++----- .../scripts/app/templates/report_best.html | 6 +- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/benchmark/scripts/app/templates/datasets.html b/benchmark/scripts/app/templates/datasets.html index 207bde3..c11c1ae 100644 --- a/benchmark/scripts/app/templates/datasets.html +++ b/benchmark/scripts/app/templates/datasets.html @@ -1,28 +1,44 @@ -{% extends "base_" ~ framework ~ ".html" %} -{% if framework == "bootstrap" %} - {% set close_button = '' %} - {% set button_class = "btn btn-primary btn-small" %} - {% set h1_class = "text-center" %} - {% set table_class = "table table-striped table-hover table-bordered" %} - {% set head_class = "bg-primary text-white" %} - {% set text_right = "text-end" %} - {% set container = "container" %} - {% set selected = "selected" %} +{% extends 'base_' ~ framework ~ '.html' %} +{% if framework == 'bootstrap' %} + {% set button_class = 'btn btn-primary btn-small' %} + {% set h1_class = 'text-center' %} + {% set table_class = 'table table-striped table-hover table-bordered' %} + {% set head_class = 'bg-primary text-white' %} + {% set text_right = 'text-end' %} + {% set container = 'container' %} + {% set selected = 'selected' %} + {%- macro header(title, close, url) -%} +
+ {%- if close -%} + + {%- endif -%} +

{{ title }}

+
+ {%- endmacro -%} {% else %} - {% set close_button = '' %} - {% set button_class = "button is-primary is-small" %} - {% set h1_class = "title is-1 has-text-centered" %} - {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} - {% set head_class = "is-selected" %} - {% set text_right = "has-text-right" %} - {% set container = "container" %} - {% set selected = "is-selected" %} + {% set button_class = 'button is-primary is-small' %} + {% set h1_class = 'title is-1 has-text-centered' %} + {% set table_class = 'table is-striped is-hoverable cell-border is-bordered' %} + {% set head_class = 'is-selected' %} + {% set text_right = 'has-text-right' %} + {% set container = 'container' %} + {% set selected = 'is-selected' %} + {%- macro header(title, close, url) -%} +
+
+ {%- if close -%} + + {%- endif -%} +

{{ title }}

+
+
+ {%- endmacro -%} {% endif %} {% block content %}
-

{{ close_button|safe }} Benchmark Datasets Report

+ {{ header('Benchmark Datasets Report', True, url_for('main.index', compare = compare)) }} - {% include "partials/datasets_table.html" %} + {% include 'partials/datasets_table.html' %}
{% endblock %} {% block jscript %} @@ -46,4 +62,4 @@ } }); -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/benchmark/scripts/app/templates/partials/select.js b/benchmark/scripts/app/templates/partials/select.js index 4baf072..d20a897 100644 --- a/benchmark/scripts/app/templates/partials/select.js +++ b/benchmark/scripts/app/templates/partials/select.js @@ -16,6 +16,9 @@ $(document).ready(function () { // "lengthMenu": "_MENU_" //} }); + $('#file-table').on( 'draw.dt', function () { + enable_disable_best_buttons(); + } ); // Check if row is selected $("#file-table tbody").on("click", "tr", function () { if ($(this).hasClass("{{ select.selected() }}")) { @@ -38,22 +41,19 @@ $(document).ready(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"); - } + enable_disable_best_buttons(); }); - 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"); - } + enable_disable_best_buttons(); }); +function enable_disable_best_buttons(){ + if ($('#compare').is(':checked')) { + $("[name='best_buttons']").addClass("tag is-link is-normal"); + $("[name='best_buttons']").removeAttr("hidden"); + } else { + $("[name='best_buttons']").removeClass("tag is-link is-normal"); + $("[name='best_buttons']").attr("hidden", true); + } +} function showFile(selectedFile) { var form = $( '' + diff --git a/benchmark/scripts/app/templates/report_best.html b/benchmark/scripts/app/templates/report_best.html index bada157..442a74b 100644 --- a/benchmark/scripts/app/templates/report_best.html +++ b/benchmark/scripts/app/templates/report_best.html @@ -2,8 +2,8 @@ {% extends "base_" ~ framework ~ ".html" %} {% import "partials/cfg_select_" ~ framework ~ ".jinja" as select %} {% block content %} - {{ select.header(title, True, url_for("main.index", compare=compare)) }} - +
+ {{ select.header(title, True, url_for("main.index", compare=compare)) }} @@ -27,7 +27,7 @@ {% endfor %}
- +
{% endblock %} {% block jscript %} - {% block jscript %} {% endblock %} + {% block jscript %} + + {% endblock %} diff --git a/benchmark/scripts/app/templates/base_bulma.html b/benchmark/scripts/app/templates/base_bulma.html index cc27f4f..876a23d 100644 --- a/benchmark/scripts/app/templates/base_bulma.html +++ b/benchmark/scripts/app/templates/base_bulma.html @@ -2,41 +2,18 @@ {{ title }} - - - - - + + + + - {% block content %} {% endblock %} + {% block content %} + + {% endblock %} - {% block jscript %} {% endblock %} + {% block jscript %} + + {% endblock %} diff --git a/benchmark/scripts/app/templates/datasets.html b/benchmark/scripts/app/templates/datasets.html index c11c1ae..a48a163 100644 --- a/benchmark/scripts/app/templates/datasets.html +++ b/benchmark/scripts/app/templates/datasets.html @@ -43,7 +43,7 @@ {% endblock %} {% block jscript %} +{% endmacro %} +{% set title = 'Report Viewer' %} +{% extends 'base_' ~ framework ~ '.html' %} +{% block content %} + {% if framework == 'bootstrap' %} + {% set center = 'text-center' %} + {% set right = 'text-end' %} + {% set button = 'btn btn-primary' %} + {% include 'partials/table_report_bootstrap.html' %} {% else %} - {% set center = "has-text-centered" %} - {% set right = "has-text-right" %} - {% set button = "button is-primary" %} - {% include "partials/table_report_bulma.html" %} + {% set center = 'has-text-centered' %} + {% set right = 'has-text-right' %} + {% set button = 'button is-primary' %} + {% include 'partials/table_report_bulma.html' %} {% endif %} {% endblock %} {% block jscript %} - {% if framework == "bootstrap" %} - {% set selected = "selected" %} + {% if framework == 'bootstrap' %} + {% set selected = 'selected' %} {% else %} - {% set selected = "is-selected" %} + {% set selected = 'is-selected' %} {% endif %} + {{ javascript("js/excelFiles.js") }} {% endblock %} diff --git a/benchmark/scripts/app/templates/select.html b/benchmark/scripts/app/templates/select.html index 2fcd44c..fccb625 100644 --- a/benchmark/scripts/app/templates/select.html +++ b/benchmark/scripts/app/templates/select.html @@ -1,20 +1,20 @@ -{% set title = "Benchmark Results" %} -{% extends "base_" ~ framework ~ ".html" %} -{% import "partials/cfg_select_" ~ framework ~ ".jinja" as select %} +{% macro javascript(file) %} + +{% endmacro %} +{% set title = 'Benchmark Results' %} +{% extends 'base_' ~ framework ~ '.html' %} +{% import 'partials/cfg_select_' ~ framework ~ '.jinja' as select %} {% block content %} - {% include "partials/table_select_design.html" %} + {% include 'partials/table_select_design.html' %} {% endblock %} {% block jscript %} - {% if framework == "bootstrap" %} - + {% if framework == 'bootstrap' %} + {% endif %} + {{ javascript('/js/excelFiles.js') }} {% endblock %} - - \ No newline at end of file From 0b258595f99db1c2484f409cf1e35b81e47b4c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 1 Jun 2023 11:44:03 +0200 Subject: [PATCH 29/34] Fix datasets --- benchmark/scripts/app/templates/datasets.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/benchmark/scripts/app/templates/datasets.html b/benchmark/scripts/app/templates/datasets.html index a48a163..b028aae 100644 --- a/benchmark/scripts/app/templates/datasets.html +++ b/benchmark/scripts/app/templates/datasets.html @@ -1,4 +1,7 @@ {% extends 'base_' ~ framework ~ '.html' %} +{% macro javascript(file) %} + +{% endmacro %} {% if framework == 'bootstrap' %} {% set button_class = 'btn btn-primary btn-small' %} {% set h1_class = 'text-center' %} @@ -42,8 +45,8 @@
{% endblock %} {% block jscript %} +{{ javascript("js/excelFiles.js") }} - {{ javascript('/js/excelFiles.js') }} + {{ javascript('js/excelFiles.js') }} {% endblock %} diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 071f8ed..ef10285 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -12,6 +12,7 @@ def main(args_test=None): app = create_app() app.config[TEST] = args_test is not None app.config[OUTPUT] = args.output + print("Output is ", args.output) if args.output == "local": webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234, host="0.0.0.0") From 4b17cc2230535a38ba201687a1aa38f8d99a0498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 26 Jun 2023 10:09:01 +0200 Subject: [PATCH 32/34] Add boostAODE model --- benchmark/Models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark/Models.py b/benchmark/Models.py index fcf31c6..1c18a20 100644 --- a/benchmark/Models.py +++ b/benchmark/Models.py @@ -8,7 +8,7 @@ from sklearn.ensemble import ( ) from sklearn.svm import SVC from stree import Stree -from bayesclass.clfs import TAN, KDB, AODE, KDBNew, TANNew, AODENew +from bayesclass.clfs import TAN, KDB, AODE, KDBNew, TANNew, AODENew, BoostAODE from wodt import Wodt from odte import Odte from xgboost import XGBClassifier @@ -45,6 +45,7 @@ class Models: "KDBNew": KDBNew(k=2), "AODENew": AODENew(random_state=random_state), "AODE": AODE(random_state=random_state), + "BoostAODE": BoostAODE(random_state=random_state), "Cart": DecisionTreeClassifier(random_state=random_state), "ExtraTree": ExtraTreeClassifier(random_state=random_state), "Wodt": Wodt(random_state=random_state), From 6844d13973795bc7db55b121b573e82e02102162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 26 Jun 2023 11:07:12 +0200 Subject: [PATCH 33/34] Update format to report --- benchmark/scripts/app/main.py | 4 +- .../app/templates/partials/table_report.html | 36 ++--- .../partials/table_report_bootstrap.html | 151 +++++++++-------- .../partials/table_report_bulma.html | 153 +++++++++--------- 4 files changed, 177 insertions(+), 167 deletions(-) diff --git a/benchmark/scripts/app/main.py b/benchmark/scripts/app/main.py index 9e7a3e3..446b9da 100755 --- a/benchmark/scripts/app/main.py +++ b/benchmark/scripts/app/main.py @@ -3,6 +3,7 @@ import os import json import shutil import xlsxwriter +from dotenv import dotenv_values from benchmark.Utils import Files, Folders from benchmark.Arguments import EnvData from benchmark.ResultsBase import StubReport @@ -99,7 +100,7 @@ def datasets(compare): def showfile(file_name, compare, back=None): compare = compare.capitalize() == "True" 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: data = json.load(f) try: @@ -113,6 +114,7 @@ def showfile(file_name, compare, back=None): summary=summary, framework=current_app.config[FRAMEWORK], back=back, + app_config=app_config, ) diff --git a/benchmark/scripts/app/templates/partials/table_report.html b/benchmark/scripts/app/templates/partials/table_report.html index 47855d9..e572dd0 100644 --- a/benchmark/scripts/app/templates/partials/table_report.html +++ b/benchmark/scripts/app/templates/partials/table_report.html @@ -1,28 +1,14 @@ {% for item in data.results %} - - {{item.dataset}} - - - {{'{:,}'.format(item.samples)}} - - - {{"%d" % item.features}} - - - {{"%d" % item.classes}} - - - {{'{:,.2f}'.format(item.nodes)}} - - - {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} - - - {{"%.6f±%.4f" % (item.time, item.time_std)}} - - - {{item.hyperparameters}} - + {{ item.dataset }} + {{ '{:,}'.format(item.samples) }} + {{"%d" % item.features}} + {{"%d" % item.classes}} + {{ '{:,.2f}'.format(item.nodes|float) }} + {{ '{:,.2f}'.format(item.leaves|float) }} + {{ '{:,.2f}'.format(item.depth|float) }} + {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} + {{"%.6f±%.4f" % (item.time, item.time_std)}} + {{ item.hyperparameters }} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/benchmark/scripts/app/templates/partials/table_report_bootstrap.html b/benchmark/scripts/app/templates/partials/table_report_bootstrap.html index 9484a24..8be1437 100644 --- a/benchmark/scripts/app/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/app/templates/partials/table_report_bootstrap.html @@ -1,69 +1,77 @@
-
-
-
- -

{{ data.title }}

-
-
- - - - - - - - {% if data.duration > 7200 %} +
+
+
+ +

{{ data.title }}

+
+
+
PlatformModelDateTime
+ + + + + + + {% if data.duration > 7200 %} {% set unit = "h" %} {% set divider = 3600 %} - {% else %} + {% else %} {% set unit = "min" %} {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
-
- -
- - - - - - - - - - - - - - + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
Duration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date }}{{ data.time }}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
+
+ +
+ + + + + + + + + + + + + + + + {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClasses{{ app_config.nodes }}{{ app_config.leaves }}{{ app_config.depth }}{{ data.score_name|capitalize }}Timehyperparameters
- {% if summary|length > 0 %} + + + {% if summary|length > 0 %}
@@ -76,12 +84,19 @@ {% include "partials/table_summary.html" %}
- {% endif %} - - - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} - - Number of files: {{ data.results | length }} -
+ {% endif %} + + + + Total score: {{ "%.6f" % (data.results | sum(attribute="score") ) }} + + + + Number of files: {{ data.results | length }} + +
-
\ No newline at end of file +
diff --git a/benchmark/scripts/app/templates/partials/table_report_bulma.html b/benchmark/scripts/app/templates/partials/table_report_bulma.html index 86859e7..07e87db 100644 --- a/benchmark/scripts/app/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/app/templates/partials/table_report_bulma.html @@ -1,75 +1,80 @@
-
-
-
-
- -

{{ data.title }}

-
+
+
+
+
+ +

{{ data.title }}

-
-
-
-
- - - - - - - - {% if data.duration > 7200 %} + + +
+
+
+
PlatformModelDateTime
+ + + + + + + {% if data.duration > 7200 %} {% set unit = "h" %} {% set divider = 3600 %} - {% else %} + {% else %} {% set unit = "min" %} {% set divider = 60 %} - {% endif %} - - - - - - - - - - - - - - - - - - - - - - -
PlatformModelDateTimeDuration ({{ unit }})StratifiedDiscretized# Folds
{{ data.platform }}{{ data.model }} {{ data.version }}{{ data.date}}{{ data.time}}{{ "%.2f" % (data.duration/divider) }}{{ data.stratified }}{{ data.discretized }}{{ data.folds }}
Language{{ data.language }} {{ data.language_version }}Seeds{{ data.seeds }}
-
- -
- - - - - - - - - - - - - - - {% include "partials/table_report.html" %} - -
DatasetSamplesFeaturesClassesNodes{{data.score_name|capitalize}}Timehyperparameters
- {% if summary|length > 0 %} + {% endif %} + Duration ({{ unit }}) + Stratified + Discretized + # Folds + + + {{ data.platform }} + {{ data.model }} {{ data.version }} + {{ data.date }} + {{ data.time }} + {{ "%.2f" % (data.duration/divider) }} + {{ data.stratified }} + {{ data.discretized }} + {{ data.folds }} + + + Language + {{ data.language }} {{ data.language_version }} + Seeds + {{ data.seeds }} + + + +
+ +
+ + + + + + + + + + + + + + + + + {% include "partials/table_report.html" %} + +
DatasetSamplesFeaturesClasses{{ app_config.nodes }}{{ app_config.leaves }}{{ app_config.depth }}{{ data.score_name|capitalize }}Timehyperparameters
+ {% if summary|length > 0 %}
@@ -82,12 +87,14 @@ {% include "partials/table_summary.html" %}
- {% endif %} -

- - Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} -

-

Number of files: {{ data.results | length }}

-
+ {% endif %} +

+ + + Total score: {{ "%.6f" % (data.results | sum(attribute="score") ) }} + +

+

Number of files: {{ data.results | length }}

+
-
\ No newline at end of file +
From a31d62263d91b8a833b6498e37d7e2e304dc2760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Wed, 13 Mar 2024 16:16:35 +0100 Subject: [PATCH 34/34] Remove Bayesian classifiers --- benchmark/Models.py | 17 +++++++++-------- requirements.txt | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/benchmark/Models.py b/benchmark/Models.py index 1c18a20..2ef6fa4 100644 --- a/benchmark/Models.py +++ b/benchmark/Models.py @@ -8,7 +8,8 @@ from sklearn.ensemble import ( ) from sklearn.svm import SVC from stree import Stree -from bayesclass.clfs import TAN, KDB, AODE, KDBNew, TANNew, AODENew, BoostAODE + +# from bayesclass.clfs import TAN, KDB, AODE, KDBNew, TANNew, AODENew, BoostAODE from wodt import Wodt from odte import Odte from xgboost import XGBClassifier @@ -39,13 +40,13 @@ class Models: def define_models(random_state): return { "STree": Stree(random_state=random_state), - "TAN": TAN(random_state=random_state), - "KDB": KDB(k=2), - "TANNew": TANNew(random_state=random_state), - "KDBNew": KDBNew(k=2), - "AODENew": AODENew(random_state=random_state), - "AODE": AODE(random_state=random_state), - "BoostAODE": BoostAODE(random_state=random_state), + # "TAN": TAN(random_state=random_state), + # "KDB": KDB(k=2), + # "TANNew": TANNew(random_state=random_state), + # "KDBNew": KDBNew(k=2), + # "AODENew": AODENew(random_state=random_state), + # "AODE": AODE(random_state=random_state), + # "BoostAODE": BoostAODE(random_state=random_state), "Cart": DecisionTreeClassifier(random_state=random_state), "ExtraTree": ExtraTreeClassifier(random_state=random_state), "Wodt": Wodt(random_state=random_state), diff --git a/requirements.txt b/requirements.txt index eb705fe..37dc400 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ odte cython fimdlp mufs -bayesclass @ git+ssh://git@github.com/doctorado-ml/bayesclass.git +#bayesclass @ git+ssh://git@github.com/doctorado-ml/bayesclass.git xlsxwriter openpyxl tqdm