Download render_figures.py from synsetai/medgemma-source-verification: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/spaces/synsetai/medgemma-source-verification/resolve/main/render_figures.py
- Command line
-
hf download hf://spaces/synsetai/medgemma-source-verification/render_figures.py
-
curl -L -o render_figures.py https://huggingface.co/spaces/synsetai/medgemma-source-verification/resolve/main/render_figures.py
2.13 kB
| """Render the structured-source delivery figure from aggregate-only data.""" | |
| from pathlib import Path | |
| import json | |
| import numpy as np | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| ROOT = Path(__file__).resolve().parent | |
| DATA = json.loads((ROOT / "results.json").read_text()) | |
| OUT = ROOT / "figures" | |
| OUT.mkdir(exist_ok=True) | |
| plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 11, | |
| "axes.spines.top": False, "axes.spines.right": False, | |
| "axes.titleweight": "bold", "figure.facecolor": "white", | |
| "savefig.facecolor": "white", "axes.axisbelow": True}) | |
| fig, axes = plt.subplots(1, 2, figsize=(10, 4.8)) | |
| colors = ["#60758a", "#087f75", "#ad8b52"] | |
| names = ["Model", "Guarded\ndelivery", "Direct\nlookup"] | |
| for ax, field, title in ( | |
| (axes[0], "unsupported_on_negative", "Unsupported answers when evidence is inadequate"), | |
| (axes[1], "correct_on_positive", "Correct answers when evidence supports a gene"), | |
| ): | |
| values = [DATA[field][k] for k in ("unmodified", "guard", "lookup")] | |
| bars = ax.bar(np.arange(3), values, color=colors, width=.65) | |
| ax.bar_label(bars, labels=[f"{v}/60" for v in values], padding=4, fontweight="bold") | |
| ax.set_xticks(np.arange(3), names) | |
| ax.set_ylim(0, 72) | |
| ax.set_ylabel("Tasks out of 60") | |
| ax.set_title(title, fontsize=11, pad=12) | |
| ax.grid(axis="y", alpha=.16) | |
| fig.suptitle("Source verification changes delivered answers", x=.05, ha="left", fontsize=16, fontweight="bold") | |
| fig.text(.05, .095, "Guarded delivery and direct lookup agreed on all 120 tasks. Three baseline negative tasks were unscorable.", fontsize=9, color="#495866") | |
| fig.text(.05, .055, "One-sided 95% lower bound on corrections minus possible harms: 29.27 percentage points.", fontsize=9, color="#495866") | |
| fig.text(.05, .02, "One-sided 95% upper bounds on correct-answer loss and coverage loss: 4.87% each. 60 families.", fontsize=9, color="#495866") | |
| fig.tight_layout(rect=(0, .14, 1, .91)) | |
| for ext in ("png", "pdf"): | |
| fig.savefig(OUT / ("01_source_delivery." + ext), dpi=210, bbox_inches="tight") | |
| plt.close(fig) | |