| import pandas as pd |
| import numpy as np |
|
|
| |
| file_path = "outputs/phase2/task_2_3_appE_full.csv" |
| df = pd.read_csv(file_path) |
|
|
| print("========================================================") |
| print("1. 原始文件基础信息") |
| print("========================================================") |
| print(f"总行数: {len(df)}") |
| pair_info = df.groupby('pair_id').agg( |
| base=('base', 'first'), |
| variant=('variant', 'first'), |
| scene_count=('scene', 'nunique'), |
| row_count=('scene', 'count') |
| ).reset_index() |
| print(pair_info.to_markdown(index=False)) |
|
|
| print("\n========================================================") |
| print("2. 生成新版 Appendix E (仅保留 P01-P04)") |
| print("========================================================") |
| df_new = df[df['pair_id'].isin(['P01', 'P02', 'P03', 'P04'])].copy() |
| new_file_path = "outputs/phase2/task_2_3_appE_filtered_P01_P04.csv" |
| df_new.to_csv(new_file_path, index=False) |
| print(f"已过滤掉 P05,新表行数: {len(df_new)}") |
| print(f"新表已保存至: {new_file_path}") |
|
|
| print("\n========================================================") |
| print("3. Table 3 Summary Aggregation (目标统计)") |
| print("========================================================") |
| targets = { |
| 'P01': ('delta_opacity_net_effect', -1), |
| 'P02': ('delta_coverage_error_fraction', -1), |
| 'P03': ('delta_opacity_pathology_rate', -1), |
| 'P04': ('delta_opacity_net_effect', -1) |
| } |
|
|
| for pid in ['P01', 'P02', 'P03', 'P04']: |
| sub = df[df['pair_id'] == pid] |
| if sub.empty: continue |
| |
| base = sub['base'].iloc[0] |
| variant = sub['variant'].iloc[0] |
| target_col, exp_sign = targets[pid] |
| |
| median_val = sub[target_col].median() |
| iqr_val = sub[target_col].quantile(0.75) - sub[target_col].quantile(0.25) |
| |
| |
| agree_design_cnt = (sub[target_col] < 0).sum() if exp_sign == -1 else (sub[target_col] > 0).sum() |
| agree_design_frac = agree_design_cnt / len(sub) |
| |
| print(f"Pair ID: {pid} | Base: {base} | Variant: {variant}") |
| print(f"Target Channel: {target_col}") |
| print(f"Median Δ: {median_val:.3f} | IQR: {iqr_val:.3f}") |
| |
| if pid == 'P03': |
| reverse_cnt = (sub[target_col] > 0).sum() |
| reverse_frac = reverse_cnt / len(sub) |
| print(f"Dir. Agreement (Design Intent): {agree_design_cnt}/{len(sub)} ({agree_design_frac:.3f})") |
| print(f"Dir. Agreement (Observed Reverse): {reverse_cnt}/{len(sub)} ({reverse_frac:.3f})") |
| print("Status: Counter-finding") |
| else: |
| status = "Validated" if agree_design_frac == 1.0 else ("Directional" if agree_design_frac >= 0.8 else "Unknown") |
| print(f"Dir. Agreement: {agree_design_cnt}/{len(sub)} ({agree_design_frac:.3f})") |
| print(f"Status: {status}") |
| print("-" * 50) |
|
|
| print("\n========================================================") |
| print("4. P05 剔除数据统计 (Dropped / Inconclusive)") |
| print("========================================================") |
| p05 = df[df['pair_id'] == 'P05'] |
| if not p05.empty: |
| target_col = 'delta_coverage_error_fraction' |
| median_val = p05[target_col].median() |
| iqr_val = p05[target_col].quantile(0.75) - p05[target_col].quantile(0.25) |
| agree_cnt = (p05[target_col] < 0).sum() |
| print(f"Pair ID: P05 | Base: {p05['base'].iloc[0]} | Variant: {p05['variant'].iloc[0]}") |
| print(f"Target Channel: {target_col}") |
| print(f"Median Δ: {median_val:.3f} | IQR: {iqr_val:.3f}") |
| print(f"Dir. Agreement: {agree_cnt}/{len(p05)} ({(agree_cnt/len(p05)):.3f})") |
| print("Status: Inconclusive") |
| print("删除理由: Median 值过小且 IQR 方差极大,无法形成强力结论,故移出正文 main text。") |
| else: |
| print("未找到 P05 数据。") |
|
|
| print("\n========================================================") |
| print("5. 论文一致性 Sanity Checks") |
| print("========================================================") |
| |
| def check_pid(pid, expect_str): |
| sub = df[df['pair_id'] == pid] |
| if sub.empty: return "N/A" |
| cnt = (sub[targets[pid][0]] < 0).sum() |
| if pid == 'P03': cnt = (sub[targets[pid][0]] > 0).sum() |
| return f"{cnt}/{len(sub)}" |
|
|
| print(f"[Check 1] P01 (PGSR) 是否 31/31? 实际: {check_pid('P01', '31/31')} -> {'PASS' if check_pid('P01', '31/31') == '31/31' else 'FAIL'}") |
| print(f"[Check 2] P02 (eRankGS) 是否 31/31? 实际: {check_pid('P02', '31/31')} -> {'PASS' if check_pid('P02', '31/31') == '31/31' else 'FAIL'}") |
| print(f"[Check 3] P03 (LightGaussian) 是否 Counter-finding? 实际反向符合数: {check_pid('P03', 'reverse')}") |
| print(f"[Check 4] P04 (SteepGS) 是否 26/31 (0.839)? 实际: {check_pid('P04', '26/31')} -> {'PASS' if check_pid('P04', '26/31') == '26/31' else 'FAIL'}") |
| print(f"[Check 5] 新版 Appendix E 总行数是否为 124? 实际: {len(df_new)} -> {'PASS' if len(df_new) == 124 else 'FAIL'}") |
|
|
| if len(df) == 155 and len(df_new) == 124: |
| print("\n⚠️ 论文修改提醒:") |
| print("原版 Appendix E 描述中提到有 155 行数据。请确保在更新 LaTeX 时:") |
| print("1. 将 Appendix E 表述改为 124 行 (4 pairs x 31 scenes)。") |
| print("2. 在 Supplementary 中说明 P05 已作为 Inconclusive Pair 被移除。") |
|
|