| from __future__ import annotations |
|
|
| import math |
| import re |
| from pathlib import Path |
|
|
| import pandas as pd |
|
|
|
|
| REPO_ROOT = Path(__file__).resolve().parents[2] |
| EVAL_ROOT = REPO_ROOT / "Evaluation" |
| OUT_DIR = EVAL_ROOT / "benchmark_overall_table" / "final" |
|
|
| |
| PAPER_MODEL_ORDER = [ |
| "real", |
| "arf", |
| "bayesnet", |
| "ctgan", |
| "forestdiffusion", |
| "realtabformer", |
| "tabbyflow", |
| "tabddpm", |
| "tabdiff", |
| "tabpfgen", |
| "tabsyn", |
| "tvae", |
| ] |
|
|
| MODEL_LABELS = { |
| "real": "REAL", |
| "arf": "ARF", |
| "bayesnet": "BayesNet", |
| "ctgan": "CTGAN", |
| "forestdiffusion": "ForestDiffusion", |
| "realtabformer": "RealTabFormer", |
| "tabbyflow": "TabbyFlow", |
| "tabddpm": "TabDDPM", |
| "tabdiff": "TabDiff", |
| "tabpfgen": "TabPFGen", |
| "tabsyn": "TabSyn", |
| "tvae": "TVAE", |
| } |
|
|
| FINAL_BASENAME = "benchmark_overall_table_real" |
| MODEL_ORDER_MAP = {model_id: idx for idx, model_id in enumerate(PAPER_MODEL_ORDER)} |
|
|
| COMPUTED_METRICS = [ |
| { |
| "key": "distance_overall", |
| "group": "Classical Fidelity", |
| "title": "Dist. overall $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": True, |
| "source_kind": "distance_dataset_export", |
| "source_file": "Evaluation/distance/runs/*/datasets/*/distance_summary__*.csv", |
| }, |
| { |
| "key": "jsd_distance", |
| "group": "Classical Fidelity", |
| "title": "JSD $\\downarrow$", |
| "direction": "lower", |
| "reference_value": 0.0, |
| "highlight_column": False, |
| "source_kind": "distance_dataset_export", |
| "source_file": "Evaluation/distance/runs/*/datasets/*/distance_summary__*.csv", |
| }, |
| { |
| "key": "ks_distance", |
| "group": "Classical Fidelity", |
| "title": "KS $\\downarrow$", |
| "direction": "lower", |
| "reference_value": 0.0, |
| "highlight_column": False, |
| "source_kind": "distance_dataset_export", |
| "source_file": "Evaluation/distance/runs/*/datasets/*/distance_summary__*.csv", |
| }, |
| { |
| "key": "tvd_distance", |
| "group": "Classical Fidelity", |
| "title": "TVD $\\downarrow$", |
| "direction": "lower", |
| "reference_value": 0.0, |
| "highlight_column": False, |
| "source_kind": "distance_dataset_export", |
| "source_file": "Evaluation/distance/runs/*/datasets/*/distance_summary__*.csv", |
| }, |
| { |
| "key": "wasserstein_distance", |
| "group": "Classical Fidelity", |
| "title": "Wasserstein $\\downarrow$", |
| "direction": "lower", |
| "reference_value": 0.0, |
| "highlight_column": False, |
| "source_kind": "distance_dataset_export", |
| "source_file": "Evaluation/distance/runs/*/datasets/*/distance_summary__*.csv", |
| }, |
| { |
| "key": "query_overall", |
| "group": "Query-centric Families", |
| "title": "Query overall $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": True, |
| "source_kind": "derived_query_overall", |
| "source_file": "Derived from the five query-centric family dataset-level scores in build_overall_benchmark_table.py.", |
| }, |
| { |
| "key": "subgroup_structure", |
| "group": "Query-centric Families", |
| "title": "Subgroup $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": False, |
| "source_kind": "query_family_dataset_export", |
| "source_file": "Evaluation/query_fivepart_breakdown/subgroup_breakdown/data/dataset_model_scores.csv", |
| }, |
| { |
| "key": "conditional_dependency_structure", |
| "group": "Query-centric Families", |
| "title": "Conditional $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": False, |
| "source_kind": "query_family_dataset_export", |
| "source_file": "Evaluation/query_fivepart_breakdown/conditional_breakdown/data/dataset_model_scores.csv", |
| }, |
| { |
| "key": "tail_breakdown", |
| "group": "Query-centric Families", |
| "title": "Tail $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": False, |
| "source_kind": "query_family_dataset_export", |
| "source_file": "Evaluation/query_fivepart_breakdown/tail_breakdown/data/dataset_model_scores.csv", |
| }, |
| { |
| "key": "missingness_structure", |
| "group": "Query-centric Families", |
| "title": "Missingness $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": False, |
| "source_kind": "query_family_dataset_export", |
| "source_file": "Evaluation/query_fivepart_breakdown/missingness_breakdown/data/dataset_model_scores.csv", |
| }, |
| { |
| "key": "cardinality_structure", |
| "group": "Query-centric Families", |
| "title": "Cardinality $\\uparrow$", |
| "direction": "higher", |
| "reference_value": 1.0, |
| "highlight_column": False, |
| "source_kind": "cardinality_dataset_export", |
| "source_file": "Evaluation/query_fivepart_breakdown/cardinality/data/cleaned_results.csv", |
| }, |
| ] |
|
|
| PLACEHOLDER_COLUMNS = [ |
| { |
| "key": "train_time", |
| "group": "Cost", |
| "title": "Train time", |
| "placeholder": True, |
| }, |
| { |
| "key": "generation_time", |
| "group": "Cost", |
| "title": "Gen. time", |
| "placeholder": True, |
| }, |
| ] |
|
|
| DISPLAY_COLUMNS = COMPUTED_METRICS + PLACEHOLDER_COLUMNS |
|
|
| METRIC_SPECS = {metric["key"]: metric for metric in COMPUTED_METRICS} |
| DISPLAY_SPECS = {column["key"]: column for column in DISPLAY_COLUMNS} |
| FAMILY_KEYS = [ |
| "subgroup_structure", |
| "conditional_dependency_structure", |
| "tail_breakdown", |
| "missingness_structure", |
| "cardinality_structure", |
| ] |
|
|
|
|
| def ensure_out_dir() -> None: |
| OUT_DIR.mkdir(parents=True, exist_ok=True) |
|
|
|
|
| def dataset_prefix(dataset_id: str) -> str: |
| return str(dataset_id)[0] if dataset_id else "" |
|
|
|
|
| def dataset_sort_tuple(dataset_id: str) -> tuple[str, int, str]: |
| text = str(dataset_id) |
| match = re.match(r"([A-Za-z]+)(\d+)", text) |
| if match: |
| return match.group(1), int(match.group(2)), text |
| return text, 0, text |
|
|
|
|
| def latex_escape(text: str) -> str: |
| replacements = { |
| "\\": r"\textbackslash{}", |
| "&": r"\&", |
| "%": r"\%", |
| "$": r"\$", |
| "#": r"\#", |
| "_": r"\_", |
| "{": r"\{", |
| "}": r"\}", |
| "~": r"\textasciitilde{}", |
| "^": r"\textasciicircum{}", |
| } |
| escaped = text |
| for src, dst in replacements.items(): |
| escaped = escaped.replace(src, dst) |
| return escaped |
|
|
|
|
| def fmt_num(value: float) -> str: |
| if abs(value) < 5e-4: |
| value = 0.0 |
| return f"{value:.2f}" |
|
|
|
|
| def normalize_long_metric( |
| df: pd.DataFrame, |
| metric_key: str, |
| value_col: str, |
| source_path: str, |
| source_kind: str, |
| ) -> pd.DataFrame: |
| subset = df.copy() |
| subset = subset[subset["model_id"].isin(PAPER_MODEL_ORDER)].copy() |
| subset["model_label"] = subset["model_id"].map(MODEL_LABELS) |
| subset["metric_key"] = metric_key |
| subset["metric_group"] = METRIC_SPECS[metric_key]["group"] |
| subset["metric_title"] = METRIC_SPECS[metric_key]["title"] |
| subset["metric_value"] = subset[value_col] |
| subset["source_kind"] = source_kind |
| subset["source_path"] = source_path |
| subset["row_kind"] = subset["model_id"].map(lambda model_id: "reference" if model_id == "real" else "synthetic") |
| return subset[ |
| [ |
| "dataset_id", |
| "dataset_prefix", |
| "model_id", |
| "model_label", |
| "metric_key", |
| "metric_group", |
| "metric_title", |
| "metric_value", |
| "source_kind", |
| "source_path", |
| "row_kind", |
| ] |
| ] |
|
|
|
|
| def load_distance_long() -> pd.DataFrame: |
| frames = [] |
| cols = [ |
| "dataset_id", |
| "model_id", |
| "timestamp_utc", |
| "jensen_shannon_distance", |
| "kolmogorov_smirnov_distance", |
| "total_variation_distance", |
| "wasserstein_distance", |
| "overall_fidelity_score", |
| ] |
| for path in (EVAL_ROOT / "distance" / "runs").glob("*/*/distance_summary__*.csv"): |
| try: |
| df = pd.read_csv(path, usecols=cols, low_memory=False) |
| except Exception: |
| continue |
| frames.append(df) |
|
|
| if not frames: |
| raise FileNotFoundError("No distance dataset exports were found under Evaluation/distance/runs.") |
|
|
| df = pd.concat(frames, ignore_index=True) |
| df = df[df["model_id"].isin([model for model in PAPER_MODEL_ORDER if model != "real"])].copy() |
| df["timestamp_utc"] = pd.to_datetime(df["timestamp_utc"], errors="coerce") |
| df["dataset_prefix"] = df["dataset_id"].map(dataset_prefix) |
| df = df.sort_values(["dataset_id", "model_id", "timestamp_utc"]).drop_duplicates( |
| ["dataset_id", "model_id"], keep="last" |
| ) |
|
|
| metric_map = [ |
| ("distance_overall", "overall_fidelity_score"), |
| ("jsd_distance", "jensen_shannon_distance"), |
| ("ks_distance", "kolmogorov_smirnov_distance"), |
| ("tvd_distance", "total_variation_distance"), |
| ("wasserstein_distance", "wasserstein_distance"), |
| ] |
| long_frames = [] |
| for metric_key, value_col in metric_map: |
| long_frames.append( |
| normalize_long_metric( |
| df[["dataset_id", "dataset_prefix", "model_id", value_col]].rename(columns={value_col: "metric_tmp"}), |
| metric_key=metric_key, |
| value_col="metric_tmp", |
| source_path="distance_dataset_export_dedup_latest", |
| source_kind="distance_dataset_export", |
| ) |
| ) |
| return pd.concat(long_frames, ignore_index=True) |
|
|
|
|
| def load_family_long() -> pd.DataFrame: |
| frames = [] |
|
|
| subgroup_path = EVAL_ROOT / "query_fivepart_breakdown" / "subgroup_breakdown" / "data" / "dataset_model_scores.csv" |
| subgroup_df = pd.read_csv(subgroup_path) |
| frames.append( |
| normalize_long_metric( |
| subgroup_df[["dataset_id", "dataset_prefix", "model_id", "subgroup_structure_score"]], |
| metric_key="subgroup_structure", |
| value_col="subgroup_structure_score", |
| source_path=str(subgroup_path.relative_to(REPO_ROOT)), |
| source_kind="query_family_dataset_export", |
| ) |
| ) |
|
|
| conditional_path = EVAL_ROOT / "query_fivepart_breakdown" / "conditional_breakdown" / "data" / "dataset_model_scores.csv" |
| conditional_df = pd.read_csv(conditional_path) |
| frames.append( |
| normalize_long_metric( |
| conditional_df[["dataset_id", "dataset_prefix", "model_id", "conditional_dependency_structure_score"]], |
| metric_key="conditional_dependency_structure", |
| value_col="conditional_dependency_structure_score", |
| source_path=str(conditional_path.relative_to(REPO_ROOT)), |
| source_kind="query_family_dataset_export", |
| ) |
| ) |
|
|
| tail_path = EVAL_ROOT / "query_fivepart_breakdown" / "tail_breakdown" / "data" / "dataset_model_scores.csv" |
| tail_df = pd.read_csv(tail_path) |
| frames.append( |
| normalize_long_metric( |
| tail_df[["dataset_id", "dataset_prefix", "model_id", "tail_breakdown_score"]], |
| metric_key="tail_breakdown", |
| value_col="tail_breakdown_score", |
| source_path=str(tail_path.relative_to(REPO_ROOT)), |
| source_kind="query_family_dataset_export", |
| ) |
| ) |
|
|
| missing_path = EVAL_ROOT / "query_fivepart_breakdown" / "missingness_breakdown" / "data" / "dataset_model_scores.csv" |
| missing_df = pd.read_csv(missing_path) |
| frames.append( |
| normalize_long_metric( |
| missing_df[["dataset_id", "dataset_prefix", "model_id", "missingness_structure_score"]], |
| metric_key="missingness_structure", |
| value_col="missingness_structure_score", |
| source_path=str(missing_path.relative_to(REPO_ROOT)), |
| source_kind="query_family_dataset_export", |
| ) |
| ) |
|
|
| cardinality_path = EVAL_ROOT / "query_fivepart_breakdown" / "cardinality" / "data" / "cleaned_results.csv" |
| cardinality_raw = pd.read_csv( |
| cardinality_path, |
| low_memory=False, |
| usecols=["dataset", "model", "official_cardinality_range_score"], |
| ) |
| cardinality_df = ( |
| cardinality_raw.groupby(["dataset", "model"], as_index=False)["official_cardinality_range_score"].mean() |
| .rename( |
| columns={ |
| "dataset": "dataset_id", |
| "model": "model_id", |
| "official_cardinality_range_score": "cardinality_structure_score", |
| } |
| ) |
| ) |
| cardinality_df["dataset_prefix"] = cardinality_df["dataset_id"].map(dataset_prefix) |
| frames.append( |
| normalize_long_metric( |
| cardinality_df[["dataset_id", "dataset_prefix", "model_id", "cardinality_structure_score"]], |
| metric_key="cardinality_structure", |
| value_col="cardinality_structure_score", |
| source_path=str(cardinality_path.relative_to(REPO_ROOT)), |
| source_kind="cardinality_dataset_export", |
| ) |
| ) |
|
|
| family_long = pd.concat(frames, ignore_index=True) |
| return family_long[family_long["model_id"] != "real"].copy() |
|
|
|
|
| def derive_query_overall_long(family_long: pd.DataFrame) -> pd.DataFrame: |
| query_long = ( |
| family_long[family_long["metric_key"].isin(FAMILY_KEYS)] |
| .groupby(["dataset_id", "dataset_prefix", "model_id", "model_label"], as_index=False) |
| .agg(metric_value=("metric_value", "mean")) |
| ) |
| query_long["metric_key"] = "query_overall" |
| query_long["metric_group"] = METRIC_SPECS["query_overall"]["group"] |
| query_long["metric_title"] = METRIC_SPECS["query_overall"]["title"] |
| query_long["source_kind"] = METRIC_SPECS["query_overall"]["source_kind"] |
| query_long["source_path"] = "derived_query_overall" |
| query_long["row_kind"] = "synthetic" |
| return query_long[ |
| [ |
| "dataset_id", |
| "dataset_prefix", |
| "model_id", |
| "model_label", |
| "metric_key", |
| "metric_group", |
| "metric_title", |
| "metric_value", |
| "source_kind", |
| "source_path", |
| "row_kind", |
| ] |
| ] |
|
|
|
|
| def add_reference_rows(long_df: pd.DataFrame) -> pd.DataFrame: |
| frames = [long_df] |
| for metric in COMPUTED_METRICS: |
| metric_key = metric["key"] |
| metric_df = long_df[ |
| (long_df["metric_key"] == metric_key) & long_df["metric_value"].notna() |
| ].copy() |
| if metric_df.empty: |
| continue |
|
|
| reference_rows = ( |
| metric_df[["dataset_id", "dataset_prefix"]] |
| .drop_duplicates() |
| .assign( |
| model_id="real", |
| model_label="REAL", |
| metric_key=metric_key, |
| metric_group=metric["group"], |
| metric_title=metric["title"], |
| metric_value=metric["reference_value"], |
| source_kind="real_self_reference", |
| source_path="real_self_reference", |
| row_kind="reference", |
| ) |
| ) |
| frames.append(reference_rows) |
|
|
| combined = pd.concat(frames, ignore_index=True) |
| combined["model_order"] = combined["model_id"].map(MODEL_ORDER_MAP) |
| return combined.sort_values( |
| ["metric_key", "dataset_id", "model_order"], |
| key=lambda col: col.map(dataset_sort_tuple) if col.name == "dataset_id" else col, |
| ).reset_index(drop=True) |
|
|
|
|
| def assemble_dataset_level_table() -> pd.DataFrame: |
| distance_long = load_distance_long() |
| family_long = load_family_long() |
| query_overall_long = derive_query_overall_long(family_long) |
| long_df = pd.concat([distance_long, family_long, query_overall_long], ignore_index=True) |
| long_df = long_df[long_df["metric_value"].notna()].copy() |
| long_df = add_reference_rows(long_df) |
| return long_df[ |
| [ |
| "dataset_id", |
| "dataset_prefix", |
| "model_id", |
| "model_label", |
| "metric_key", |
| "metric_group", |
| "metric_title", |
| "metric_value", |
| "source_kind", |
| "source_path", |
| "row_kind", |
| "model_order", |
| ] |
| ] |
|
|
|
|
| def build_model_summary(dataset_level: pd.DataFrame) -> pd.DataFrame: |
| grouped = ( |
| dataset_level.groupby( |
| ["model_id", "model_label", "row_kind", "metric_key", "metric_group", "metric_title"], |
| as_index=False, |
| ) |
| .agg( |
| metric_mean=("metric_value", "mean"), |
| metric_std=("metric_value", "std"), |
| metric_count=("metric_value", "count"), |
| ) |
| ) |
| grouped.loc[grouped["metric_count"] <= 1, "metric_std"] = 0.0 |
|
|
| wide = pd.DataFrame( |
| { |
| "model_id": PAPER_MODEL_ORDER, |
| "model_label": [MODEL_LABELS[model_id] for model_id in PAPER_MODEL_ORDER], |
| "row_kind": ["reference" if model_id == "real" else "synthetic" for model_id in PAPER_MODEL_ORDER], |
| "model_order": [MODEL_ORDER_MAP[model_id] for model_id in PAPER_MODEL_ORDER], |
| } |
| ) |
|
|
| for metric in COMPUTED_METRICS: |
| metric_key = metric["key"] |
| metric_rows = grouped[grouped["metric_key"] == metric_key][ |
| ["model_id", "metric_mean", "metric_std", "metric_count"] |
| ].rename( |
| columns={ |
| "metric_mean": f"{metric_key}_mean", |
| "metric_std": f"{metric_key}_std", |
| "metric_count": f"{metric_key}_count", |
| } |
| ) |
| wide = wide.merge(metric_rows, on="model_id", how="left") |
|
|
| for metric in COMPUTED_METRICS: |
| metric_key = metric["key"] |
| mean_col = f"{metric_key}_mean" |
| rank_col = f"{metric_key}_rank" |
| ascending = metric["direction"] == "lower" |
| wide[rank_col] = pd.NA |
| ranking = ( |
| wide[(wide["row_kind"] == "synthetic") & wide[mean_col].notna()][["model_id", mean_col]] |
| .sort_values(mean_col, ascending=ascending) |
| .reset_index(drop=True) |
| ) |
| for idx, row in ranking.head(3).iterrows(): |
| wide.loc[wide["model_id"] == row["model_id"], rank_col] = idx + 1 |
|
|
| for placeholder in PLACEHOLDER_COLUMNS: |
| key = placeholder["key"] |
| wide[f"{key}_mean"] = pd.NA |
| wide[f"{key}_std"] = pd.NA |
| wide[f"{key}_count"] = pd.NA |
| wide[f"{key}_rank"] = pd.NA |
|
|
| return wide.sort_values("model_order").reset_index(drop=True) |
|
|
|
|
| def render_cell_text(column_key: str, mean_value: float | None, std_value: float | None, rank: int | None) -> str: |
| spec = DISPLAY_SPECS[column_key] |
| prefix = r"\cellcolor{OverallTint} " if spec.get("highlight_column") else "" |
|
|
| if spec.get("placeholder"): |
| return prefix + "" |
|
|
| if pd.isna(mean_value): |
| return prefix + r"\textit{N/A}" |
|
|
| std_numeric = 0.0 if pd.isna(std_value) else float(std_value) |
| body = f"{fmt_num(float(mean_value))}$_{{\\pm {fmt_num(std_numeric)}}}$" |
| rank_value = None if pd.isna(rank) else int(rank) |
| if rank_value == 1: |
| body = rf"{{\color{{FirstPlace}}\textbf{{{body}}}}}" |
| elif rank_value == 2: |
| body = rf"{{\color{{SecondPlace}}\textbf{{{body}}}}}" |
| elif rank_value == 3: |
| body = rf"{{\color{{ThirdPlace}}\textbf{{{body}}}}}" |
| return prefix + body |
|
|
|
|
| def build_header_cells(group_name: str) -> list[dict[str, object]]: |
| return [column for column in DISPLAY_COLUMNS if column["group"] == group_name] |
|
|
|
|
| def render_latex(summary: pd.DataFrame) -> str: |
| row_lines = [] |
| for _, row in summary.iterrows(): |
| cells = [latex_escape(str(row["model_label"]))] |
| for column in DISPLAY_COLUMNS: |
| key = column["key"] |
| cells.append(render_cell_text(key, row.get(f"{key}_mean"), row.get(f"{key}_std"), row.get(f"{key}_rank"))) |
| row_lines.append(" & ".join(cells) + r" \\") |
|
|
| classical_cols = build_header_cells("Classical Fidelity") |
| query_cols = build_header_cells("Query-centric Families") |
| cost_cols = build_header_cells("Cost") |
| total_cols = 1 + len(DISPLAY_COLUMNS) |
| tabular_spec = "@{}l " + " ".join("c" for _ in DISPLAY_COLUMNS) + "@{}" |
|
|
| header_cells = [] |
| for column in DISPLAY_COLUMNS: |
| title = column["title"] |
| if column.get("highlight_column"): |
| header_cells.append(rf"\cellcolor{{OverallTint}} {title}") |
| else: |
| header_cells.append(title) |
|
|
| return rf"""\documentclass[10pt]{{article}} |
| \usepackage[a4paper,landscape,margin=0.60in]{{geometry}} |
| \usepackage[T1]{{fontenc}} |
| \usepackage[utf8]{{inputenc}} |
| \usepackage{{newtxtext,newtxmath}} |
| \usepackage{{booktabs}} |
| \usepackage[table]{{xcolor}} |
| \usepackage{{array}} |
| \usepackage{{multirow}} |
| \usepackage{{caption}} |
| \usepackage{{microtype}} |
| \usepackage{{graphicx}} |
| \captionsetup{{font=small,labelfont=bf}} |
| \definecolor{{FirstPlace}}{{HTML}}{{1397B8}} |
| \definecolor{{SecondPlace}}{{HTML}}{{7B45E5}} |
| \definecolor{{ThirdPlace}}{{HTML}}{{F28E2B}} |
| \definecolor{{OverallTint}}{{HTML}}{{F8F1DA}} |
| \definecolor{{RuleGray}}{{HTML}}{{C8CDD3}} |
| \arrayrulecolor{{RuleGray}} |
| \setlength{{\tabcolsep}}{{4.0pt}} |
| \renewcommand{{\arraystretch}}{{1.12}} |
| |
| \begin{{document}} |
| \thispagestyle{{empty}} |
| |
| \noindent{{\small\textit{{Conference-style benchmark summary for the evaluation section}}}}\\[-0.15em] |
| \noindent\color{{RuleGray}}\rule{{\textwidth}}{{0.5pt}} |
| |
| \begin{{table}}[ht] |
| \centering |
| \caption{{Benchmark-wide summary of the frozen paper-facing model set specified in the README figure convention: 11 synthetic generators plus the \texttt{{REAL}} reference row. We report mean $\pm$ std across covered datasets using the current materialized evaluation exports. Lower is better for the four raw classical distance columns; higher is better for the two overall columns and the five query-centric family scores. The {{\color{{FirstPlace}} First}}, {{\color{{SecondPlace}} Second}}, and {{\color{{ThirdPlace}} Third}} best synthetic-model values in each column are highlighted with the same colors used in the table.}} |
| \label{{tab:benchmark_overall_real}} |
| \footnotesize |
| \resizebox{{\textwidth}}{{!}}{{% |
| \begin{{tabular}}{{{tabular_spec}}} |
| \toprule |
| \multirow{{2}}{{*}}{{\textbf{{Generator}}}} & \multicolumn{{{len(classical_cols)}}}{{c}}{{\textbf{{Classical Fidelity}}}} & \multicolumn{{{len(query_cols)}}}{{c}}{{\textbf{{Query-centric Families}}}} & \multicolumn{{{len(cost_cols)}}}{{c}}{{\textbf{{Cost}}}} \\ |
| \cmidrule(lr){{2-{1 + len(classical_cols)}}} |
| \cmidrule(lr){{{2 + len(classical_cols)}-{1 + len(classical_cols) + len(query_cols)}}} |
| \cmidrule(lr){{{2 + len(classical_cols) + len(query_cols)}-{total_cols}}} |
| & {" & ".join(header_cells)} \\ |
| \midrule |
| {chr(10).join(row_lines)} |
| \bottomrule |
| \end{{tabular}}% |
| }} |
| |
| \vspace{{0.45em}} |
| \begin{{minipage}}{{0.95\linewidth}} |
| \small |
| \textit{{Note.}} The \texttt{{REAL}} row is a self-comparison reference row. For raw distance columns it is fixed to 0.00; for \texttt{{Dist. overall}}, \texttt{{Query overall}}, and the five family-score columns it is fixed to 1.00. The cost columns are intentionally left blank as placeholders for the training-time and generation-time statistics that will be added next. |
| \end{{minipage}} |
| \end{{table}} |
| |
| \end{{document}} |
| """ |
|
|
|
|
| def build_source_manifest() -> pd.DataFrame: |
| rows = [] |
| for metric in COMPUTED_METRICS: |
| rows.append( |
| { |
| "metric_key": metric["key"], |
| "metric_group": metric["group"], |
| "metric_title": metric["title"], |
| "source_kind": metric["source_kind"], |
| "source_file": metric["source_file"], |
| } |
| ) |
| for placeholder in PLACEHOLDER_COLUMNS: |
| rows.append( |
| { |
| "metric_key": placeholder["key"], |
| "metric_group": placeholder["group"], |
| "metric_title": placeholder["title"], |
| "source_kind": "placeholder", |
| "source_file": "Reserved placeholder column; real values will be added later.", |
| } |
| ) |
| rows.append( |
| { |
| "metric_key": "real_reference_rows", |
| "metric_group": "Reference", |
| "metric_title": "REAL self-comparison rows", |
| "source_kind": "derived_reference", |
| "source_file": "Generated in build_overall_benchmark_table.py from the applicable dataset coverage of each metric.", |
| } |
| ) |
| return pd.DataFrame(rows) |
|
|
|
|
| def write_outputs(dataset_level: pd.DataFrame, summary: pd.DataFrame) -> None: |
| ensure_out_dir() |
| dataset_csv_path = OUT_DIR / f"{FINAL_BASENAME}_dataset_level.csv" |
| summary_csv_path = OUT_DIR / f"{FINAL_BASENAME}_model_summary.csv" |
| sources_csv_path = OUT_DIR / f"{FINAL_BASENAME}_sources.csv" |
| tex_path = OUT_DIR / f"{FINAL_BASENAME}.tex" |
|
|
| dataset_level.to_csv(dataset_csv_path, index=False) |
| summary.to_csv(summary_csv_path, index=False) |
| build_source_manifest().to_csv(sources_csv_path, index=False) |
| tex_path.write_text(render_latex(summary), encoding="utf-8") |
|
|
|
|
| def main() -> None: |
| dataset_level = assemble_dataset_level_table() |
| summary = build_model_summary(dataset_level) |
| write_outputs(dataset_level, summary) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|