QuAcc/quacc/main.py

64 lines
1.9 KiB
Python
Raw Normal View History

from sys import platform
2023-10-31 03:01:24 +01:00
from traceback import print_exception as traceback
import quacc.evaluation.comp as comp
from quacc.dataset import Dataset
from quacc.environment import env
2023-10-31 03:01:24 +01:00
from quacc.logger import Logger
from quacc.utils import create_dataser_dir
2023-05-17 14:02:29 +02:00
def toast():
if platform == "win32":
import win11toast
win11toast.notify("Comp", "Completed Execution")
2023-09-24 02:21:18 +02:00
def estimate_comparison():
2023-10-31 03:01:24 +01:00
log = Logger.logger()
for conf in env.get_confs():
create_dataser_dir(conf, update=env.DATASET_DIR_UPDATE)
dataset = Dataset(
env.DATASET_NAME,
target=env.DATASET_TARGET,
n_prevalences=env.DATASET_N_PREVS,
2023-10-28 16:14:37 +02:00
prevs=env.DATASET_PREVS,
)
try:
dr = comp.evaluate_comparison(dataset, estimators=env.COMP_ESTIMATORS)
for plot_conf in env.get_plot_confs():
for m in env.METRICS:
output_path = env.OUT_DIR / f"{plot_conf}_{m}.md"
with open(output_path, "w") as f:
f.write(
dr.to_md(
conf=plot_conf,
metric=m,
estimators=env.PLOT_ESTIMATORS,
stdev=env.PLOT_STDEV,
)
)
except Exception as e:
log.error(f"Configuration {conf} failed. Exception: {e}")
traceback(e)
2023-09-24 02:21:18 +02:00
# print(df.to_latex(float_format="{:.4f}".format))
# print(utils.avg_group_report(df).to_latex(float_format="{:.4f}".format))
2023-09-24 02:21:18 +02:00
def main():
2023-10-31 03:01:24 +01:00
log = Logger.logger()
2023-10-28 16:14:37 +02:00
try:
estimate_comparison()
except Exception as e:
log.error(f"estimate comparison failed. Exceprion: {e}")
traceback(e)
toast()
2023-10-28 16:14:37 +02:00
Logger.close()
2023-05-17 14:02:29 +02:00
if __name__ == "__main__":
2023-09-24 02:21:18 +02:00
main()