Archived
85 lines
6.9 KiB
Python
85 lines
6.9 KiB
Python
"""Display existing scalar scores only; never read labels or prediction arrays."""
|
||
import hashlib
|
||
import json
|
||
import math
|
||
from pathlib import Path
|
||
import statistics
|
||
import time
|
||
|
||
START_CPU = time.process_time()
|
||
BASE = Path('/home/frank14f/optane/MeltMind')
|
||
ROOT = BASE / 'artifacts/gre24-v4-stored-score-display-2026-11-16'
|
||
SOURCE = BASE / 'artifacts/gre24-v4-reproduction-2026-11-16/protocol/scores.json'
|
||
EXPECTED = '7308e1b74d96e1f003766b72fc751c2cb0eedb9956d906d2446924015fcd04a9'
|
||
raw = SOURCE.read_bytes()
|
||
assert hashlib.sha256(raw).hexdigest() == EXPECTED
|
||
rows = json.loads(raw)['rows']
|
||
assert len(rows) == 1575
|
||
assert len({(r['split'], r['case']) for r in rows}) == len(rows)
|
||
metrics = {'rrmse_rms': 'RMS(y)', 'rrmse_maximum': 'max(y)', 'rrmse_mean': 'mean(y)'}
|
||
models = ['naive', 'GBRT', 'FNN']
|
||
splits = []
|
||
for split, expected_count in enumerate([304, 311, 308, 309, 305]):
|
||
requested = [r for r in rows if r['split'] == split]
|
||
scored = [r for r in requested if r['status'] == 'SCORED']
|
||
assert len(requested) == 315 and len(scored) == expected_count
|
||
item = {'split': split, 'requested': 315, 'scored': len(scored),
|
||
'missing': 315 - len(scored), 'fractions': {}, 'paired_medians': {}}
|
||
for metric in metrics:
|
||
item['fractions'][metric] = {}
|
||
for model in models:
|
||
values = [r['scores'][model][metric] for r in scored]
|
||
assert all(isinstance(v, (int, float)) and math.isfinite(v) for v in values)
|
||
assert all(not r['scores'][model]['undefined_metrics'] for r in scored)
|
||
count = sum(v < 0.1 for v in values)
|
||
item['fractions'][metric][model] = {'below': count, 'total': len(values),
|
||
'fraction': count / len(values)}
|
||
differences = [r['scores']['naive'][metric] - r['scores']['GBRT'][metric]
|
||
for r in scored]
|
||
item['paired_medians'][metric] = {'pairs': len(differences),
|
||
'median_naive_minus_GBRT': statistics.median(differences)}
|
||
splits.append(item)
|
||
means = {metric: {model: statistics.mean(s['fractions'][metric][model]['fraction']
|
||
for s in splits) for model in models} for metric in metrics}
|
||
result = {'source': str(SOURCE.relative_to(BASE)), 'source_sha256': EXPECTED,
|
||
'authorization': 'Claude1794839041.521639', 'threshold': 0.1,
|
||
'comparison': 'strictly less than', 'aggregation': 'equal mean of five split fractions',
|
||
'paired_definition': 'median of same-case naive minus GBRT scalar RRMSE within each split',
|
||
'splits': splits, 'mean_split_fractions': means,
|
||
'no_new_fit_prediction_scoring_decode_or_bootstrap': True}
|
||
(ROOT / 'supplement.json').write_text(json.dumps(result, indent=2) + '\n')
|
||
lines = ['# Gre24 v4:已有评分的阈值及配对差展示补充', '',
|
||
'按Claude1794839041.521639要求,仅汇总固定 scores.json 内已有逐件标量。原评分SHA256为 `' + EXPECTED + '`,读取前后相同;未读取标签、预测数组或模型,未重新拟合、预测、评分或bootstrap。原评分和终态账不改。', '',
|
||
'## RRMSE严格小于0.1的比例', '',
|
||
'五次独立随机315测试/314训练划分,不是五折交叉验证。有效测试依次304/311/308/309/305,缺失11/4/7/6/10;1575次测试访问含38个准备失败行。比例分母为各split有效评分件数,五split比例等权平均,不按节点加权或先池化;14个准备失败及原排除保持不变。', '',
|
||
'| 分母 | 模型 | split0 | split1 | split2 | split3 | split4 | 五split比例平均 |',
|
||
'| --- | --- | --- | --- | --- | --- | --- | ---: |']
|
||
for metric, label in metrics.items():
|
||
for model in models:
|
||
cells = [s['fractions'][metric][model] for s in splits]
|
||
lines.append('| ' + ' | '.join([label, model] + [f"{c['below']}/{c['total']} ({100*c['fraction']:.4f}%)" for c in cells] + [f'{100*means[metric][model]:.6f}%']) + ' |')
|
||
lines += ['', '## 同件配对的naive与GBRT差', '',
|
||
'先在每件上计算 Δ = RRMSE_naive − RRMSE_GBRT,再在各split取Δ中位数;不是两模型中位数相减。正值表示GBRT误差较低。配对数量为304/311/308/309/305,数值为比例而非百分比。', '',
|
||
'| 分母 | split0 median(Δ) | split1 median(Δ) | split2 median(Δ) | split3 median(Δ) | split4 median(Δ) |',
|
||
'| --- | ---: | ---: | ---: | ---: | ---: |']
|
||
for metric, label in metrics.items():
|
||
lines.append('| ' + ' | '.join([label] + [f"{s['paired_medians'][metric]['median_naive_minus_GBRT']:.12f}" for s in splits]) + ' |')
|
||
lines += ['', '## 解释边界与费用', '',
|
||
'RMS(y)仍为内部预登记主指标;max(y)是保留tet域最后到达时间,作为论文total fill time的代理,作者评分代码尚未取得。三分母完整保留,不据数值接近改主指标。失败覆盖偏差方向未知,v4/v5摘要相近不能建立版本因果配对;t_set替代缺失Q、R1离散补充、fill-only/早停FNN和随机几何近重复限制均保留。', '',
|
||
'这是既有分数的描述性展示,不新增统计检验、训练或版本因果结论。原始结果见[固定结果报告](gre24-v4-reproduction-results-2026-11-16.md),独立审计见[MeltAssist审计](meltassist-v4-terminal-audit-2026-11-16.md)。完整计数与配对中位数见[补充JSON](../artifacts/gre24-v4-stored-score-display-2026-11-16/supplement.json)。']
|
||
assert hashlib.sha256(SOURCE.read_bytes()).hexdigest() == EXPECTED
|
||
cpu = time.process_time() - START_CPU
|
||
receipt = {'status': 'COMPLETE', 'created_unix': time.time(), 'display_cpu_seconds': cpu,
|
||
'original_worker_cpu_seconds': 140042.73955399985,
|
||
'original_plus_display_cpu_seconds': 140042.73955399985 + cpu,
|
||
'cpu_cap_seconds': 216000, 'gpu_added_seconds': 0,
|
||
'source_before_sha256': EXPECTED, 'source_after_sha256': EXPECTED,
|
||
'builder_sha256': hashlib.sha256(Path(__file__).read_bytes()).hexdigest(),
|
||
'supplement_sha256': hashlib.sha256((ROOT / 'supplement.json').read_bytes()).hexdigest(),
|
||
'accounting_note': 'Display aggregation CPU only; prior independent audit costs remain separately reported.'}
|
||
assert receipt['original_plus_display_cpu_seconds'] < receipt['cpu_cap_seconds']
|
||
(ROOT / 'receipt.json').write_text(json.dumps(receipt, indent=2) + '\n')
|
||
lines += ['', f'此次展示汇总CPU {cpu:.9f}秒单列;原科学账140042.739554秒不改,加本次展示为{receipt["original_plus_display_cpu_seconds"]:.9f}/216000秒。先前独立审计费用仍另列,非这里的全活动总账。GPU新增0。费用与源码哈希见[回执](../artifacts/gre24-v4-stored-score-display-2026-11-16/receipt.json)。', '']
|
||
(BASE / 'docs/gre24-v4-stored-score-display-2026-11-16.md').write_text('\n'.join(lines))
|
||
print(json.dumps({'means': means, 'paired': [s['paired_medians'] for s in splits], 'cpu_seconds': cpu}))
|