Datasets:
Download code/make_matrix_tables.py from spatial-evidence-bench/SpatialEvidenceBench: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/5c8b07c8e3679dc7d2dd54b6fae5e27f9d82c4db/code/make_matrix_tables.py
- Command line
-
hf download hf://datasets/spatial-evidence-bench/SpatialEvidenceBench@5c8b07c8e3679dc7d2dd54b6fae5e27f9d82c4db/code/make_matrix_tables.py
-
curl -L -o make_matrix_tables.py https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/5c8b07c8e3679dc7d2dd54b6fae5e27f9d82c4db/code/make_matrix_tables.py
4.14 kB
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| OUT = Path("D:/GraphEvolve/docs/paper_v3/tables") | |
| MODELS = [("qwen3vl", "Qwen3-VL-8B"), ("qwen25vl", "Qwen2.5-VL-7B")] | |
| FAMILIES = [("left_right", "left/right"), ("above_below", "above/below"), | |
| ("front_behind", "front/behind"), ("on_not_on", "on/not-on")] | |
| KEYS = ("v", "t", "k") | |
| def load(path): | |
| path = Path(path) | |
| return json.loads(path.read_text(encoding="utf-8")) if path.exists() else None | |
| def pct(value, digits=1): | |
| return "--" if value is None else f"{value * 100:.{digits}f}" | |
| def ci(value): | |
| if not isinstance(value, dict): | |
| return "" | |
| low, high = value["ci95"] | |
| return f" [{low * 100:.1f}, {high * 100:.1f}]" | |
| def write(name, text): | |
| OUT.mkdir(parents=True, exist_ok=True) | |
| (OUT / name).write_text(text, encoding="utf-8") | |
| print(f"WROTE {name}") | |
| def tab_matrix(): | |
| lines = [ | |
| r"\begin{tabular}{lcccccc}", | |
| r"\toprule", | |
| r"Model & $V$ & $T$ & $K$ & PFC$(T{+})$ & PFC$(T{-})$ & $n$ \\", | |
| r"\midrule", | |
| ] | |
| for key, label in MODELS: | |
| table = load(ROOT / f"analysis/matrix_{key}.json") | |
| if not table: | |
| continue | |
| matrix = table["matrix"] | |
| cells = [f"{pct(matrix[k]['value'])}{ci(matrix[k])}" for k in KEYS] | |
| cells.append(pct(matrix["pfc_Tpos"]["value"])) | |
| cells.append(pct(matrix["pfc_Tneg"]["value"])) | |
| lines.append(f"{label} & " + " & ".join(cells) + f" & {table['n_scene_pairs']} \\\\") | |
| lines += [r"\bottomrule", r"\end{tabular}"] | |
| write("tab_matrix.tex", "\n".join(lines) + "\n") | |
| def tab_family_matrix(): | |
| lines = [ | |
| r"\begin{tabular}{llccc}", | |
| r"\toprule", | |
| r"Model & Family & $V$ & $T$ & $K$ \\", | |
| r"\midrule", | |
| ] | |
| for key, label in MODELS: | |
| table = load(ROOT / f"analysis/matrix_{key}.json") | |
| if not table: | |
| continue | |
| for family, family_label in FAMILIES: | |
| cell = table["by_family"].get(family) | |
| if not cell: | |
| continue | |
| matrix = cell["matrix"] | |
| values = [pct(matrix[k]["value"] if isinstance(matrix[k], dict) else matrix[k]) for k in KEYS] | |
| lines.append(f"{label} & {family_label} & " + " & ".join(values) + r" \\") | |
| lines.append(r"\addlinespace[2pt]") | |
| lines += [r"\bottomrule", r"\end{tabular}"] | |
| write("tab_family_matrix.tex", "\n".join(lines) + "\n") | |
| def tab_gate(): | |
| lines = [ | |
| r"\begin{tabular}{lcccc}", | |
| r"\toprule", | |
| r"Model & Direct & Trust-all & Gated-support & Gated \\", | |
| r"\midrule", | |
| ] | |
| for key, label in MODELS: | |
| table = load(ROOT / f"analysis/vcg_test_{key}.json") | |
| if not table: | |
| continue | |
| methods = {row["method"]: row for row in table["methods"]} | |
| cells = [pct(methods[name]["accuracy"]) for name in | |
| ("direct_only", "trust_all", "vcg_support_only", "vcg")] | |
| lines.append(f"{label} & " + " & ".join(cells) + r" \\") | |
| lines += [r"\bottomrule", r"\end{tabular}"] | |
| write("tab_gate_v2.tex", "\n".join(lines) + "\n") | |
| def tab_gate_family(): | |
| lines = [ | |
| r"\begin{tabular}{llccccc}", | |
| r"\toprule", | |
| r"Model & Family & Direct & Gated-support & Gated & Support & Refute \\", | |
| r"\midrule", | |
| ] | |
| for key, label in MODELS: | |
| table = load(ROOT / f"analysis/vcg_test_{key}.json") | |
| if not table: | |
| continue | |
| for family, family_label in FAMILIES: | |
| cell = table["by_family"].get(family) | |
| if not cell: | |
| continue | |
| lines.append( | |
| f"{label} & {family_label} & {pct(cell['direct_only'])} & {pct(cell['vcg_support_only'])} & " | |
| f"{pct(cell['vcg'])} & {pct(cell['support_rate'])} & {pct(cell['refute_rate'])} \\\\" | |
| ) | |
| lines.append(r"\addlinespace[2pt]") | |
| lines += [r"\bottomrule", r"\end{tabular}"] | |
| write("tab_gate_family.tex", "\n".join(lines) + "\n") | |
| if __name__ == "__main__": | |
| tab_matrix() | |
| tab_family_matrix() | |
| tab_gate() | |
| tab_gate_family() | |