From 468ddc756b84b59ff25367019684340ea7cf6a2d Mon Sep 17 00:00:00 2001 From: Tamino Huxohl <thuxohl@techfak.uni-bielefeld.de> Date: Tue, 11 Oct 2022 11:52:13 +0200 Subject: [PATCH] introduce pandas and saving to csv in eval script --- mu_map/eval/measures.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mu_map/eval/measures.py b/mu_map/eval/measures.py index b17f73a..f91c3e6 100644 --- a/mu_map/eval/measures.py +++ b/mu_map/eval/measures.py @@ -94,7 +94,7 @@ if __name__ == "__main__": ) measures = {"NMAE": nmae, "MSE": mse} - values = pd.Dataframe(map(lambda x: (x, []), measures.keys())) + values = pd.DataFrame(dict(map(lambda x: (x, []), measures.keys()))) for i, (recon, mu_map) in enumerate(dataset): print( f"Process input {str(i):>{len(str(len(dataset)))}}/{len(dataset)}", end="\r" @@ -104,12 +104,15 @@ if __name__ == "__main__": prediction = prediction.squeeze().cpu().numpy() mu_map = mu_map.squeeze().cpu().numpy() - row = dict( - map(lambda item: (item[0], item[1](prediction, mu_map)), measures.items) - ) - values = values.append(row, ignore_index=True) + row = pd.DataFrame(dict( + map(lambda item: (item[0], [item[1](prediction, mu_map)]), measures.items()) + )) + values = pd.concat((values, row), ignore_index=True) print(f" " * 100, end="\r") + if args.out: + values.to_csv(args.out, index=False) + print("Scores:") for measure_name, measure_values in values.items(): mean = measure_values.mean() -- GitLab