"""Organizers' practice run (train to 2010, predict 2011-2018, all 8 years) for reference models.""" import sys, json import pandas as pd sys.path.insert(0, str(__import__('pathlib').Path(__file__).resolve().parent)) from v2lib import * P = Panel(); f = forecast_block(P, 2010, configs=[(15, 0.0, 'national')], H=8) r = score_origin(P, f, 2010, H=8) mae = r.groupby(['method', 'metric']).error.mean().unstack() models = {'clim30': dict.fromkeys(METRICS, 'clim30'), 'lin30': dict.fromkeys(METRICS, 'lin30'), 'v1': {'annual_avg_temp': 'exp10', 'cdd': 'exp10', 'hottest_day_temp': 'clim30', 'total_precip_in': 'clim30'}, 'v2_strict': {'annual_avg_temp': 'LT_L15_a0_national', 'cdd': 'exp10', 'hottest_day_temp': 'clim30', 'total_precip_in': 'clim30'}, 'v2b': {'annual_avg_temp': 'LT_L15_a0_national', 'cdd': 'SHmean_L15_a0_national', 'hottest_day_temp': 'clim30', 'total_precip_in': 'clim30'}} rows = [] for k, ch in models.items(): d = {m: mae.loc[ch[m], m] for m in METRICS} sk = [1 - d[m] / mae.loc['clim30', m] for m in METRICS] rows.append(dict(model=k, **{f'mae_{m}': d[m] for m in METRICS}, score=100 * max(0, sum(sk) / 4))) t = pd.DataFrame(rows); t.to_csv(ROOT / 'results/v2_practice_run_2010.csv', index=False); print(t.round(3).to_string())