From 7daa19b987228ae878227a136c869e35c19b85b8 Mon Sep 17 00:00:00 2001 From: Alexandra Udaltsova <43303448+AUdaltsova@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:05:42 +0100 Subject: [PATCH 1/3] Fix history bug and add bells in analysis.py --- experiments/analysis.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/experiments/analysis.py b/experiments/analysis.py index 75b00cd9..9d7d35f9 100644 --- a/experiments/analysis.py +++ b/experiments/analysis.py @@ -16,10 +16,11 @@ def main(runs: list[str], run_names: list[str]) -> None: """ api = wandb.Api() dfs = [] + epoch_num = [] for run in runs: - run = api.run(f"openclimatefix/india/{run}") + run = api.run(f"openclimatefix/PROJECT/{run}") - df = run.history() + df = run.history(samples=run.lastHistoryStep+1) # Get the columns that are in the format 'MAE_horizon/step_/val` mae_cols = [col for col in df.columns if "MAE_horizon/step_" in col and "val" in col] # Sort them @@ -40,6 +41,7 @@ def main(runs: list[str], run_names: list[str]) -> None: # Get the step from the column name column_timesteps = [int(col.split("_")[-1].split("/")[0]) * 15 for col in mae_cols] dfs.append(df) + epoch_num.append(min_row_idx) # Get the timedelta for each group groupings = [ [0, 0], @@ -89,22 +91,22 @@ def main(runs: list[str], run_names: list[str]) -> None: # Plot the error on per timestep, and all timesteps plt.figure() for idx, df in enumerate(dfs): - plt.plot(column_timesteps, df, label=run_names[idx]) - plt.legend() - plt.xlabel("Timestep (minutes)") - plt.ylabel("MAE %") - plt.title("MAE % for each timestep") + plt.plot(column_timesteps, df, label=f"{run_names[idx]}, epoch: {epoch_num[idx]}") + plt.legend(fontsize=18) + plt.xlabel("Timestep (minutes)", fontsize=18) + plt.ylabel("MAE %", fontsize=18) + plt.title("MAE % for each timestep", fontsize=24) plt.savefig("mae_per_timestep.png") plt.show() # Plot the error on per timestep, and grouped timesteps plt.figure() - for run_name in run_names: - plt.plot(groups_df[run_name], label=run_name) - plt.legend() - plt.xlabel("Timestep (minutes)") - plt.ylabel("MAE %") - plt.title("MAE % for each timestep") + for idx, run_name in enumerate(run_names): + plt.plot(groups_df[run_name], label=f"{run_name}, epoch: {epoch_num[idx]}") + plt.legend(fontsize=18) + plt.xlabel("Timestep (minutes)", fontsize=18) + plt.ylabel("MAE %", fontsize=18) + plt.title("MAE % for each timestep", fontsize=24) plt.savefig("mae_per_timestep.png") plt.show() @@ -119,3 +121,4 @@ def main(runs: list[str], run_names: list[str]) -> None: parser.add_argument("--run_names", nargs="+") args = parser.parse_args() main(args.list_of_runs, args.run_names) + From e268a61fdc9c3d487038a96be7cbdeab90c0e1df Mon Sep 17 00:00:00 2001 From: Alexandra Udaltsova <43303448+AUdaltsova@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:14:37 +0100 Subject: [PATCH 2/3] Update analysis.py --- experiments/analysis.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/experiments/analysis.py b/experiments/analysis.py index 9d7d35f9..33fc718d 100644 --- a/experiments/analysis.py +++ b/experiments/analysis.py @@ -92,10 +92,10 @@ def main(runs: list[str], run_names: list[str]) -> None: plt.figure() for idx, df in enumerate(dfs): plt.plot(column_timesteps, df, label=f"{run_names[idx]}, epoch: {epoch_num[idx]}") - plt.legend(fontsize=18) - plt.xlabel("Timestep (minutes)", fontsize=18) - plt.ylabel("MAE %", fontsize=18) - plt.title("MAE % for each timestep", fontsize=24) + plt.legend() + plt.xlabel("Timestep (minutes)") + plt.ylabel("MAE %") + plt.title("MAE % for each timestep") plt.savefig("mae_per_timestep.png") plt.show() @@ -103,10 +103,10 @@ def main(runs: list[str], run_names: list[str]) -> None: plt.figure() for idx, run_name in enumerate(run_names): plt.plot(groups_df[run_name], label=f"{run_name}, epoch: {epoch_num[idx]}") - plt.legend(fontsize=18) - plt.xlabel("Timestep (minutes)", fontsize=18) - plt.ylabel("MAE %", fontsize=18) - plt.title("MAE % for each timestep", fontsize=24) + plt.legend() + plt.xlabel("Timestep (minutes)") + plt.ylabel("MAE %") + plt.title("MAE % for each timestep") plt.savefig("mae_per_timestep.png") plt.show() From f928e801200329188d9567de23efd9b30ba0fd7f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:16:57 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- experiments/analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/experiments/analysis.py b/experiments/analysis.py index 33fc718d..bb119664 100644 --- a/experiments/analysis.py +++ b/experiments/analysis.py @@ -20,7 +20,7 @@ def main(runs: list[str], run_names: list[str]) -> None: for run in runs: run = api.run(f"openclimatefix/PROJECT/{run}") - df = run.history(samples=run.lastHistoryStep+1) + df = run.history(samples=run.lastHistoryStep + 1) # Get the columns that are in the format 'MAE_horizon/step_/val` mae_cols = [col for col in df.columns if "MAE_horizon/step_" in col and "val" in col] # Sort them @@ -121,4 +121,3 @@ def main(runs: list[str], run_names: list[str]) -> None: parser.add_argument("--run_names", nargs="+") args = parser.parse_args() main(args.list_of_runs, args.run_names) -