Download code/della/time_saving_by_agent.py from drkylj/prophet-v3: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/datasets/drkylj/prophet-v3/resolve/main/code/della/time_saving_by_agent.py
- Command line
-
hf download hf://datasets/drkylj/prophet-v3/code/della/time_saving_by_agent.py
-
curl -L -o time_saving_by_agent.py https://huggingface.co/datasets/drkylj/prophet-v3/resolve/main/code/della/time_saving_by_agent.py
2.07 kB
| """Time saved and final-reward error per predicted agent (the FrontierCS agent being forecast) and cut. | |
| Reads results/v3/time_saving.json -> results/v3/time_saving_by_agent.json""" | |
| import json, statistics as st, collections | |
| R = '/scratch/gpfs/TRIDAO/ly3223/oraclebench/' | |
| d = json.load(open(R + 'results/v3/time_saving.json')) | |
| fr = json.load(open(R + 'data/hf_raw/metadata/formal-results.json')) | |
| name = {r['model_id']: r['candidate_name'] for r in fr['runs']} | |
| idx = {json.loads(l)['task_id']: json.loads(l) for l in open(R + 'data/v3/full/metadata/task_index.jsonl')} | |
| g = collections.defaultdict(list) | |
| for r in d['rows']: | |
| g[(name[idx[r['task_id']]['model']], r['p'])].append(r) | |
| def q(v, p): | |
| v = sorted(v); return v[min(len(v) - 1, int(p * (len(v) - 1) + .5))] | |
| out = collections.defaultdict(dict) | |
| for (a, p), rows in g.items(): | |
| ev = [x['eval_min'] for x in rows if x['eval_min'] is not None] | |
| e = {'n': len(rows), 'runtime': round(st.mean(x['runtime'] for x in rows), 1), | |
| 'saved_min': round(st.mean(x['saved'] for x in rows), 1), 'saved_pct': round(st.mean(x['saved_pct'] for x in rows), 4), | |
| 'eval_min': round(st.mean(ev), 1) if ev else None, 'truth': round(st.mean(x['truth'] for x in rows), 2), 'models': {}} | |
| for t in d['tags']: | |
| ab = [abs(x[t]) for x in rows] | |
| e['models'][t] = {'median_abs': round(q(ab, .5), 3), 'mae': round(st.mean(ab), 3), | |
| 'le2': round(sum(v < 2 for v in ab) / len(ab), 3), 'bias': round(st.mean(x[t] for x in rows), 3)} | |
| out[a][str(p)] = e | |
| json.dump({'tags': d['tags'], 'agents': out}, open(R + 'results/v3/time_saving_by_agent.json', 'w'), separators=(',', ':')) | |
| rows = sorted(out.items(), key=lambda kv: -kv[1].get('25', {}).get('saved_pct', 0)) | |
| for a, c in rows[:6] + rows[-4:]: | |
| s = ' | '.join(f"{p}%: n={c[p]['n']} saved {c[p]['saved_min']:.0f}m ({100 * c[p]['saved_pct']:.0f}%) Opus ±{c[p]['models']['opus55-high']['median_abs']:.1f}" | |
| for p in ('25', '50', '75') if p in c) | |
| print(f'{a[:38]:38s} {s}') | |
| print('agents', len(out)) | |