From 180460e1f20368e0df41c2292a6cb9dc3a756e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 27 Jan 2022 20:22:46 +0100 Subject: [PATCH] Add results list and experiments.txt --- src/Results.py | 16 ++++++++++++---- src/experiments.txt | 5 +++++ src/list.py | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 src/experiments.txt create mode 100644 src/list.py diff --git a/src/Results.py b/src/Results.py index a990f01..c0b45d9 100644 --- a/src/Results.py +++ b/src/Results.py @@ -700,15 +700,23 @@ class Summary: self.datasets[result] = report.lines self.data.append(entry) - def list(self) -> None: + def list(self, score=None, model=None) -> None: """Print the list of results""" - max_length = max(len(x["file"]) for x in self.data) + data = self.data.copy() + if score: + data = [x for x in data if x["score"] == score] + if model: + data = [x for x in data if x["model"] == model] + max_file = max(len(x["file"]) for x in data) + max_title = max(len(x["title"]) for x in data) + print(f"{'File':{max_file}s} {'Score':7s} {'Title':s}") + print("=" * max_file + " " + "=" * 7 + " " + "=" * max_title) print( "\n".join( [ - f"{x['file']:{max_length}s} {x['metric']:7.3f} " + f"{x['file']:{max_file}s} {x['metric']:7.3f} " f"{x['title']}" - for x in self.data + for x in data ] ) ) diff --git a/src/experiments.txt b/src/experiments.txt new file mode 100644 index 0000000..5e13183 --- /dev/null +++ b/src/experiments.txt @@ -0,0 +1,5 @@ +Experiments to do: +Bagging + +Odte +Random Forest diff --git a/src/list.py b/src/list.py new file mode 100644 index 0000000..b6b5199 --- /dev/null +++ b/src/list.py @@ -0,0 +1,40 @@ +import argparse +from Results import Summary + +"""List experiments of a model +""" + + +def parse_arguments(): + ap = argparse.ArgumentParser() + ap.add_argument( + "-x", + "--excel", + type=bool, + required=False, + help="Generate Excel file", + ) + ap.add_argument( + "-s", + "--score", + type=str, + required=False, + help="score used in experiment", + ) + ap.add_argument( + "-m", + "--model", + type=str, + required=False, + help="model used in experiment", + ) + args = ap.parse_args() + + return (args.excel, args.score, args.model) + + +(excel, score, model) = parse_arguments() + +data = Summary() +data.acquire() +data.list(score, model)