Add results list and experiments.txt

This commit is contained in:
2022-01-27 20:22:46 +01:00
parent 3e2a120c45
commit 180460e1f2
3 changed files with 57 additions and 4 deletions

View File

@@ -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
]
)
)

5
src/experiments.txt Normal file
View File

@@ -0,0 +1,5 @@
Experiments to do:
Bagging
Odte
Random Forest

40
src/list.py Normal file
View File

@@ -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)