2023-10-27 12:37:18 +02:00
|
|
|
from sys import platform
|
2023-10-31 03:01:24 +01:00
|
|
|
from traceback import print_exception as traceback
|
2023-10-23 03:14:35 +02:00
|
|
|
|
2023-10-20 23:36:05 +02:00
|
|
|
import quacc.evaluation.comp as comp
|
|
|
|
from quacc.dataset import Dataset
|
2023-10-27 12:37:18 +02:00
|
|
|
from quacc.environment import env
|
2023-10-31 03:01:24 +01:00
|
|
|
from quacc.logger import Logger
|
2023-10-27 12:37:18 +02:00
|
|
|
from quacc.utils import create_dataser_dir
|
2023-10-19 02:36:53 +02:00
|
|
|
|
2023-05-17 14:02:29 +02:00
|
|
|
|
2023-10-27 12:37:18 +02:00
|
|
|
def toast():
|
|
|
|
if platform == "win32":
|
|
|
|
import win11toast
|
|
|
|
|
|
|
|
win11toast.notify("Comp", "Completed Execution")
|
2023-10-23 03:14:35 +02:00
|
|
|
|
|
|
|
|
2023-09-24 02:21:18 +02:00
|
|
|
def estimate_comparison():
|
2023-10-31 03:01:24 +01:00
|
|
|
log = Logger.logger()
|
2023-10-27 12:37:18 +02:00
|
|
|
for conf in env.get_confs():
|
|
|
|
create_dataser_dir(conf, update=env.DATASET_DIR_UPDATE)
|
2023-10-23 03:14:35 +02:00
|
|
|
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,
|
2023-10-23 03:14:35 +02:00
|
|
|
)
|
|
|
|
try:
|
|
|
|
dr = comp.evaluate_comparison(dataset, estimators=env.COMP_ESTIMATORS)
|
2023-10-27 12:37:18 +02:00
|
|
|
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,
|
|
|
|
)
|
|
|
|
)
|
2023-10-23 03:14:35 +02:00
|
|
|
except Exception as e:
|
2023-10-27 12:37:18 +02:00
|
|
|
log.error(f"Configuration {conf} failed. Exception: {e}")
|
|
|
|
traceback(e)
|
2023-09-24 02:21:18 +02:00
|
|
|
|
2023-10-19 02:36:53 +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)
|
|
|
|
|
2023-10-27 12:37:18 +02:00
|
|
|
toast()
|
2023-10-28 16:14:37 +02:00
|
|
|
Logger.close()
|
2023-05-17 14:02:29 +02:00
|
|
|
|
2023-10-19 02:36:53 +02:00
|
|
|
|
2023-05-11 21:43:59 +02:00
|
|
|
if __name__ == "__main__":
|
2023-09-24 02:21:18 +02:00
|
|
|
main()
|