File size: 5,400 Bytes
9affda1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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), # Expected Negative
    'P02': ('delta_coverage_error_fraction', -1), # Expected Negative
    'P03': ('delta_opacity_pathology_rate', -1), # Expected Negative (Design intent)
    'P04': ('delta_opacity_net_effect', -1) # Expected Negative
}

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)
    
    # 根据设计预期计算 Agreement
    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': # 特殊处理 LightGaussian (Counter-finding)
        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() # P03我们check reverse
    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 被移除。")