Summarize LCB dominance unsafe rate
Browse files
workspace/scripts/summarize_ctt_runs.py
CHANGED
|
@@ -27,6 +27,7 @@ COLUMNS = [
|
|
| 27 |
"pptc_0p20",
|
| 28 |
"pptc_0p40",
|
| 29 |
"negative_near_0p20",
|
|
|
|
| 30 |
"calibration_ece",
|
| 31 |
"seeds",
|
| 32 |
"ci",
|
|
@@ -67,11 +68,19 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 67 |
utility = args.run_root / "utility_energy_smoke" / "metrics.json"
|
| 68 |
if utility.exists():
|
| 69 |
rows.append(_utility_row(utility))
|
| 70 |
-
for
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
for pattern in ("ctt_learned_dominance*/metrics.json", "ctt*_learned_dominance*/metrics.json"):
|
| 76 |
for metrics_path in sorted(args.run_root.glob(pattern)):
|
| 77 |
if metrics_path in seen_metric_paths:
|
|
@@ -126,6 +135,7 @@ def _reproduce_rows(path: Path) -> list[dict[str, str]]:
|
|
| 126 |
"negative_near_0p20": _fmt(
|
| 127 |
proxy.get("negative_near_at_0p20", proxy.get("negative_near_at_16_thr_0p2"))
|
| 128 |
),
|
|
|
|
| 129 |
"calibration_ece": "n/a",
|
| 130 |
"seeds": "3",
|
| 131 |
"ci": "see run",
|
|
@@ -157,6 +167,7 @@ def _ctt_row(path: Path) -> dict[str, str]:
|
|
| 157 |
"pptc_0p20": _summary_mean(summary, "pptc_at_16_thr_0p20"),
|
| 158 |
"pptc_0p40": _summary_mean(summary, "pptc_at_16_thr_0p40"),
|
| 159 |
"negative_near_0p20": _summary_mean(summary, "negative_near_at_16_thr_0p20"),
|
|
|
|
| 160 |
"calibration_ece": "n/a",
|
| 161 |
"seeds": _seed_count(path.parent),
|
| 162 |
"ci": "see run",
|
|
@@ -185,6 +196,7 @@ def _positive_memory_row(path: Path) -> dict[str, str]:
|
|
| 185 |
"pptc_0p20": _summary_mean(summary, "pptc_at_16_thr_0p20"),
|
| 186 |
"pptc_0p40": _summary_mean(summary, "pptc_at_16_thr_0p40"),
|
| 187 |
"negative_near_0p20": _summary_mean(summary, "negative_near_at_16_thr_0p20"),
|
|
|
|
| 188 |
"calibration_ece": "n/a",
|
| 189 |
"seeds": _seed_count(path.parent),
|
| 190 |
"ci": "see run",
|
|
@@ -217,6 +229,7 @@ def _comparison_rows(path: Path) -> list[dict[str, str]]:
|
|
| 217 |
"pptc_0p20": _fmt(item.get("pptc_0p20")),
|
| 218 |
"pptc_0p40": _fmt(item.get("pptc_0p40")),
|
| 219 |
"negative_near_0p20": _fmt(item.get("negative_near_0p20")),
|
|
|
|
| 220 |
"calibration_ece": "n/a",
|
| 221 |
"seeds": str(item.get("train_seeds", "unknown")),
|
| 222 |
"ci": "aggregate over run means",
|
|
@@ -245,6 +258,7 @@ def _utility_row(path: Path) -> dict[str, str]:
|
|
| 245 |
"pptc_0p20": "n/a",
|
| 246 |
"pptc_0p40": "n/a",
|
| 247 |
"negative_near_0p20": "n/a",
|
|
|
|
| 248 |
"calibration_ece": _summary_mean(data.get("summary", {}), "pairwise_causal_calibration_ece"),
|
| 249 |
"seeds": "train split",
|
| 250 |
"ci": "see run",
|
|
@@ -303,6 +317,7 @@ def _dominance_row(path: Path) -> dict[str, str]:
|
|
| 303 |
"pptc_0p20": "n/a",
|
| 304 |
"pptc_0p40": "n/a",
|
| 305 |
"negative_near_0p20": "n/a",
|
|
|
|
| 306 |
"calibration_ece": _fmt(ece),
|
| 307 |
"seeds": str(seed_count),
|
| 308 |
"ci": "see run",
|
|
@@ -393,6 +408,7 @@ def _measured_ctt_row(path: Path, data: dict[str, Any]) -> dict[str, str]:
|
|
| 393 |
"pptc_0p20": "n/a",
|
| 394 |
"pptc_0p40": "n/a",
|
| 395 |
"negative_near_0p20": "n/a",
|
|
|
|
| 396 |
"calibration_ece": _fmt(ece),
|
| 397 |
"seeds": str(seed_count),
|
| 398 |
"ci": "see measured_metrics",
|
|
@@ -521,8 +537,8 @@ def _markdown(rows: list[dict[str, str]]) -> str:
|
|
| 521 |
lines = [
|
| 522 |
"# CTT Summary",
|
| 523 |
"",
|
| 524 |
-
"| Method | Status | Base | Selected | Proposal oracle | Hidden oracle | Utility support gap | Utility selector gap | Success support gap | Success selector gap | OutcomePTR | PPTC@0.20 | PPTC@0.40 | NegativeNear@0.20 | Calibration ECE | Run |",
|
| 525 |
-
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- |",
|
| 526 |
]
|
| 527 |
for row in rows:
|
| 528 |
lines.append(
|
|
@@ -530,7 +546,7 @@ def _markdown(rows: list[dict[str, str]]) -> str:
|
|
| 530 |
"{proposal_oracle} | {hidden_oracle} | {support_gap} | {selector_gap} | "
|
| 531 |
"{success_support_gap} | {success_selector_gap} | {outcome_ptr} | "
|
| 532 |
"{pptc_0p20} | {pptc_0p40} | "
|
| 533 |
-
"{negative_near_0p20} | {calibration_ece} | `{run_path}` |".format(**row)
|
| 534 |
)
|
| 535 |
lines.append("")
|
| 536 |
lines.append(
|
|
|
|
| 27 |
"pptc_0p20",
|
| 28 |
"pptc_0p40",
|
| 29 |
"negative_near_0p20",
|
| 30 |
+
"unsafe_execution",
|
| 31 |
"calibration_ece",
|
| 32 |
"seeds",
|
| 33 |
"ci",
|
|
|
|
| 68 |
utility = args.run_root / "utility_energy_smoke" / "metrics.json"
|
| 69 |
if utility.exists():
|
| 70 |
rows.append(_utility_row(utility))
|
| 71 |
+
for pattern in ("ctt_dominance*/metrics.json", "ctt*_dominance*/metrics.json"):
|
| 72 |
+
for metrics_path in sorted(args.run_root.glob(pattern)):
|
| 73 |
+
if metrics_path in seen_metric_paths:
|
| 74 |
+
continue
|
| 75 |
+
report_type = _report_type(metrics_path)
|
| 76 |
+
if report_type not in {
|
| 77 |
+
"dominance_calibrated_selector_eval",
|
| 78 |
+
"learned_dominance_selector_eval",
|
| 79 |
+
"nonlinear_dominance_selector_eval",
|
| 80 |
+
}:
|
| 81 |
+
continue
|
| 82 |
+
rows.append(_dominance_row(metrics_path))
|
| 83 |
+
seen_metric_paths.add(metrics_path)
|
| 84 |
for pattern in ("ctt_learned_dominance*/metrics.json", "ctt*_learned_dominance*/metrics.json"):
|
| 85 |
for metrics_path in sorted(args.run_root.glob(pattern)):
|
| 86 |
if metrics_path in seen_metric_paths:
|
|
|
|
| 135 |
"negative_near_0p20": _fmt(
|
| 136 |
proxy.get("negative_near_at_0p20", proxy.get("negative_near_at_16_thr_0p2"))
|
| 137 |
),
|
| 138 |
+
"unsafe_execution": "n/a",
|
| 139 |
"calibration_ece": "n/a",
|
| 140 |
"seeds": "3",
|
| 141 |
"ci": "see run",
|
|
|
|
| 167 |
"pptc_0p20": _summary_mean(summary, "pptc_at_16_thr_0p20"),
|
| 168 |
"pptc_0p40": _summary_mean(summary, "pptc_at_16_thr_0p40"),
|
| 169 |
"negative_near_0p20": _summary_mean(summary, "negative_near_at_16_thr_0p20"),
|
| 170 |
+
"unsafe_execution": "n/a",
|
| 171 |
"calibration_ece": "n/a",
|
| 172 |
"seeds": _seed_count(path.parent),
|
| 173 |
"ci": "see run",
|
|
|
|
| 196 |
"pptc_0p20": _summary_mean(summary, "pptc_at_16_thr_0p20"),
|
| 197 |
"pptc_0p40": _summary_mean(summary, "pptc_at_16_thr_0p40"),
|
| 198 |
"negative_near_0p20": _summary_mean(summary, "negative_near_at_16_thr_0p20"),
|
| 199 |
+
"unsafe_execution": "n/a",
|
| 200 |
"calibration_ece": "n/a",
|
| 201 |
"seeds": _seed_count(path.parent),
|
| 202 |
"ci": "see run",
|
|
|
|
| 229 |
"pptc_0p20": _fmt(item.get("pptc_0p20")),
|
| 230 |
"pptc_0p40": _fmt(item.get("pptc_0p40")),
|
| 231 |
"negative_near_0p20": _fmt(item.get("negative_near_0p20")),
|
| 232 |
+
"unsafe_execution": "n/a",
|
| 233 |
"calibration_ece": "n/a",
|
| 234 |
"seeds": str(item.get("train_seeds", "unknown")),
|
| 235 |
"ci": "aggregate over run means",
|
|
|
|
| 258 |
"pptc_0p20": "n/a",
|
| 259 |
"pptc_0p40": "n/a",
|
| 260 |
"negative_near_0p20": "n/a",
|
| 261 |
+
"unsafe_execution": "n/a",
|
| 262 |
"calibration_ece": _summary_mean(data.get("summary", {}), "pairwise_causal_calibration_ece"),
|
| 263 |
"seeds": "train split",
|
| 264 |
"ci": "see run",
|
|
|
|
| 317 |
"pptc_0p20": "n/a",
|
| 318 |
"pptc_0p40": "n/a",
|
| 319 |
"negative_near_0p20": "n/a",
|
| 320 |
+
"unsafe_execution": _fmt(summary.get("unsafe_execution_known")),
|
| 321 |
"calibration_ece": _fmt(ece),
|
| 322 |
"seeds": str(seed_count),
|
| 323 |
"ci": "see run",
|
|
|
|
| 408 |
"pptc_0p20": "n/a",
|
| 409 |
"pptc_0p40": "n/a",
|
| 410 |
"negative_near_0p20": "n/a",
|
| 411 |
+
"unsafe_execution": _summary_mean(summary, f"selected_unsafe_known_at_{k}"),
|
| 412 |
"calibration_ece": _fmt(ece),
|
| 413 |
"seeds": str(seed_count),
|
| 414 |
"ci": "see measured_metrics",
|
|
|
|
| 537 |
lines = [
|
| 538 |
"# CTT Summary",
|
| 539 |
"",
|
| 540 |
+
"| Method | Status | Base | Selected | Proposal oracle | Hidden oracle | Utility support gap | Utility selector gap | Success support gap | Success selector gap | OutcomePTR | PPTC@0.20 | PPTC@0.40 | NegativeNear@0.20 | Unsafe exec. | Calibration ECE | Run |",
|
| 541 |
+
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- |",
|
| 542 |
]
|
| 543 |
for row in rows:
|
| 544 |
lines.append(
|
|
|
|
| 546 |
"{proposal_oracle} | {hidden_oracle} | {support_gap} | {selector_gap} | "
|
| 547 |
"{success_support_gap} | {success_selector_gap} | {outcome_ptr} | "
|
| 548 |
"{pptc_0p20} | {pptc_0p40} | "
|
| 549 |
+
"{negative_near_0p20} | {unsafe_execution} | {calibration_ece} | `{run_path}` |".format(**row)
|
| 550 |
)
|
| 551 |
lines.append("")
|
| 552 |
lines.append(
|