prophet-v3 / code /della /strength_corr.py
drkylj's picture
Add predictor results (Opus/Sonnet/Haiku 5.5, effort high): forecasts, scores, audits, analyses; launch and audit code
2e7f744 verified
Raw History Blame Contribute Delete
3.35 kB
"""Does Opus forecast accuracy depend on how strong the forecast agent is? -> results/v3/strength_corr.json
Agent strength comes from the official FrontierCS 2 results for all 48 tasks (formal-results.json), not from
the forecast sample:
bench_mean mean official score over the agent's 48 task runs (a missing run counts 0)
bench_pct mean over tasks of the agent's percentile among the 32 agents on that task (0 = worst, 1 = best)
Opus accuracy per agent and cut (five-hour window, audited forecasts, agents with >= 5 forecasts):
mae, adj (task-adjusted error), fmae (final error) as in rank_corr.py.
Per forecast: error vs the run's own within-task percentile.
Spearman rho with two-sided permutation p-values.
"""
import json, collections, statistics as st, sys
sys.path.insert(0, '/scratch/gpfs/TRIDAO/ly3223/oraclebench/v3/della')
from rank_corr import F, agents, spearman # same forecast set and agent rows as the ranking figures
R = '/scratch/gpfs/TRIDAO/ly3223/oraclebench/'
fr = json.load(open(R + 'data/hf_raw/metadata/formal-results.json'))
tasks = sorted({t['task'] for t in fr['tasks']})
name = {r['model_id']: r['candidate_name'] for r in fr['runs']}
score = collections.defaultdict(dict)
for r in fr['runs']:
score[r['task']][r['candidate_name']] = float(r.get('score') or 0.0)
agents_all = sorted(set(name.values()))
pct = collections.defaultdict(dict)
for t in tasks:
s = score[t]
vals = [s.get(a, 0.0) for a in agents_all]
for a in agents_all:
v = s.get(a, 0.0)
below = sum(x < v for x in vals); eq = sum(x == v for x in vals) - 1
pct[t][a] = (below + eq / 2) / (len(vals) - 1)
bench = {a: {'bench_mean': st.mean(score[t].get(a, 0.0) for t in tasks),
'bench_pct': st.mean(pct[t][a] for t in tasks)} for a in agents_all}
out = {'bench': bench, 'tests': {}, 'per_forecast': {}, 'agents': {}}
for p, rows in agents.items():
for r in rows:
r.update(bench[r['agent']])
col = lambda k: [r[k] for r in rows]
out['agents'][p] = [{k: r[k] for k in ('agent', 'n', 'mae', 'adj', 'fmae', 'bench_mean', 'bench_pct')} for r in rows]
out['tests'][p] = {
'error_vs_bench_mean': spearman(col('mae'), col('bench_mean')),
'error_vs_bench_pct': spearman(col('mae'), col('bench_pct')),
'adj_error_vs_bench_pct': spearman(col('adj'), col('bench_pct')),
'final_error_vs_bench_pct': spearman(col('fmae'), col('bench_pct')),
}
fs = [f for f in F if f['p'] == p]
out['per_forecast'][p] = spearman([f['err'] for f in fs], [pct[f['task']][f['agent']] for f in fs], n_perm=2000)
json.dump(out, open(R + 'results/v3/strength_corr.json', 'w'), indent=1)
top = sorted(bench.items(), key=lambda x: -x[1]['bench_pct'])
print('strongest:', [(a, round(b['bench_mean'], 1), round(b['bench_pct'], 2)) for a, b in top[:3]])
print('weakest: ', [(a, round(b['bench_mean'], 1), round(b['bench_pct'], 2)) for a, b in top[-3:]])
print('bench_mean vs bench_pct', spearman([b['bench_mean'] for b in bench.values()], [b['bench_pct'] for b in bench.values()]))
for p in (25, 50, 75):
print(f'== {p}% cut')
for k, v in out['tests'][p].items():
print(f' {k:28s} rho={v[0]:+.3f} p={v[1]:.4f} n={v[2]}')
v = out['per_forecast'][p]
print(f' per-forecast error vs run percentile rho={v[0]:+.3f} p={v[1]:.4f} n={v[2]}')