Download scorer/examples/quickstart.py from figmirror/PlotTwin-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/datasets/figmirror/PlotTwin-Bench/resolve/main/scorer/examples/quickstart.py
- Command line
-
hf download hf://datasets/figmirror/PlotTwin-Bench/scorer/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/datasets/figmirror/PlotTwin-Bench/resolve/main/scorer/examples/quickstart.py
1.28 kB
| """Score a simple baseline on a few PlotTwin-Bench tasks. | |
| Every task gives a reference figure and a target CSV. A method writes one plotting | |
| script per task, `<id>.py`, that reads the target data from `data.csv` and saves one | |
| PNG. This example writes a default-style pandas plot for the first three tasks and | |
| scores it: | |
| cd scorer | |
| export OPENAI_API_KEY=... # plus OPENAI_BASE_URL for a compatible endpoint | |
| uv run python examples/quickstart.py | |
| """ | |
| from pathlib import Path | |
| from datasets import load_dataset | |
| from plottwin_scorer.cli import main as plottwin_score | |
| BASELINE = '''\ | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| df = pd.read_csv("data.csv") | |
| df.select_dtypes("number").iloc[:, :3].plot(figsize=(6, 4)) | |
| plt.tight_layout() | |
| plt.savefig("figure.png", dpi=150) | |
| ''' | |
| bench = load_dataset("figmirror/PlotTwin-Bench", split="test") | |
| pred_dir = Path("quickstart_preds") | |
| pred_dir.mkdir(exist_ok=True) | |
| for row in bench.select(range(3)): | |
| # A real method reads row["reference_image"] and row["target_data"] here. | |
| (pred_dir / f"{row['id']}.py").write_text(BASELINE) | |
| # Same as: uv run plottwin-score --pred-dir quickstart_preds --out-dir quickstart_scores | |
| plottwin_score(["--pred-dir", str(pred_dir), "--out-dir", "quickstart_scores"]) | |