Datasets:
Download code/export_results.py from spatial-evidence-bench/SpatialEvidenceBench: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/2f24e28c8148dd98783009ecceecff73bbef2326/code/export_results.py
- Command line
-
hf download hf://datasets/spatial-evidence-bench/SpatialEvidenceBench@2f24e28c8148dd98783009ecceecff73bbef2326/code/export_results.py
-
curl -L -o export_results.py https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/2f24e28c8148dd98783009ecceecff73bbef2326/code/export_results.py
2.85 kB
| import csv | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| AN = ROOT / "analysis" | |
| RES = ROOT / "results" | |
| MODELS = ["qwen3vl", "qwen25vl"] | |
| METHOD_CALLS = { | |
| "direct_only": (0, 0), | |
| "trust_all": (0, 0), | |
| "vcg": (2, 0), | |
| "vcg_support_only": (2, 0), | |
| "vcg_confident": (2, 0), | |
| "witness_only": (2, 0), | |
| "independent_vlm_check": (0, 1), | |
| } | |
| def load(path): | |
| with path.open(encoding="utf-8") as fh: | |
| return json.load(fh) | |
| def main(): | |
| RES.mkdir(parents=True, exist_ok=True) | |
| paired = {"schema": "graphevolve.n_full_v1.paired_metrics.v1", "models": {}} | |
| vcg = {"schema": "graphevolve.n_full_v1.vcg_results.v1", "models": {}} | |
| for model in MODELS: | |
| matrix = load(AN / f"matrix_{model}.json") | |
| paired["models"][model] = { | |
| "n_scene_pairs": matrix["n_scene_pairs"], | |
| "matrix": matrix["matrix"], | |
| "cells": matrix["cells"], | |
| "by_family": matrix["by_family"], | |
| "fca_Tpos": matrix["fca_Tpos"], | |
| "fca_Tneg": matrix["fca_Tneg"], | |
| "teu_Tpos": matrix["teu_Tpos"], | |
| "teu_Tneg": matrix["teu_Tneg"], | |
| } | |
| gate = load(AN / f"vcg_test_{model}.json") | |
| vcg["models"][model] = { | |
| "params": gate["params"], | |
| "methods": gate["methods"], | |
| "by_family": gate["by_family"], | |
| "risk_coverage": gate["risk_coverage"], | |
| } | |
| (RES / "paired_metrics.json").write_text( | |
| json.dumps(paired, indent=2, ensure_ascii=False), encoding="utf-8" | |
| ) | |
| (RES / "vcg_results.json").write_text( | |
| json.dumps(vcg, indent=2, ensure_ascii=False), encoding="utf-8" | |
| ) | |
| rows = [] | |
| for model in MODELS: | |
| gate = load(AN / f"vcg_test_{model}.json") | |
| for stats in gate["methods"]: | |
| method = stats["method"] | |
| tool_calls, vlm_calls = METHOD_CALLS.get(method, (0, 0)) | |
| rows.append( | |
| { | |
| "model": model, | |
| "method": method, | |
| "accuracy": round(stats["accuracy"], 4), | |
| "coverage": round(stats["coverage"], 4), | |
| "induced_error": round(stats["induced_error"], 4), | |
| "harm_rate": round(stats["harm_rate"], 4), | |
| "repair_rate": round(stats["repair_rate"], 4), | |
| "extra_tool_calls": tool_calls, | |
| "extra_vlm_calls": vlm_calls, | |
| } | |
| ) | |
| with (RES / "costs.csv").open("w", encoding="utf-8", newline="") as fh: | |
| writer = csv.DictWriter(fh, fieldnames=list(rows[0].keys())) | |
| writer.writeheader() | |
| writer.writerows(rows) | |
| print(f"WROTE {RES/'paired_metrics.json'} {RES/'vcg_results.json'} {RES/'costs.csv'} rows={len(rows)}") | |
| if __name__ == "__main__": | |
| main() | |