Datasets:
Download code/make_submission_v3.py from tchaudha/heat-seekers-protostar: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/datasets/tchaudha/heat-seekers-protostar/resolve/main/code/make_submission_v3.py
- Command line
-
hf download hf://datasets/tchaudha/heat-seekers-protostar/code/make_submission_v3.py
-
curl -L -o make_submission_v3.py https://huggingface.co/datasets/tchaudha/heat-seekers-protostar/resolve/main/code/make_submission_v3.py
1.13 kB
| """2019-2025 forecast from data <= 2018 using results/v3_selection.json (methods from v3lib.v3_block).""" | |
| import hashlib, json, sys | |
| import numpy as np, pandas as pd | |
| sys.path.insert(0, str(__import__('pathlib').Path(__file__).resolve().parent)) | |
| from v3lib import * | |
| RES = ROOT / 'results' | |
| def build(P): | |
| sel = json.loads((RES / 'v3_selection.json').read_text())['selection'] | |
| f = v3_block(P, 2018) | |
| p = pd.concat([f[(f.metric == m) & (f.method == sel[m])] for m in METRICS]).drop(columns='method') | |
| t = pd.read_csv(TEMPLATE).drop(columns='predicted_value') | |
| out = t.merge(p, on=KEY, how='left', validate='one_to_one', sort=False) | |
| assert out.predicted_value.notna().all(); validate(out); return out, sel | |
| def main(): | |
| P = attach(Panel()); out, sel = build(P) | |
| path = RES / 'submission_v3.csv'; out.to_csv(path, index=False, float_format='%.6f'); validate(pd.read_csv(path)) | |
| h = hashlib.sha256(path.read_bytes()).hexdigest() | |
| (RES / 'submission_v3.json').write_text(json.dumps(dict(selection=sel, sha256=h, rows=len(out)), indent=2)) | |
| print('VALID', path, h) | |
| if __name__ == '__main__': main() | |