@@ -43,6 +43,13 @@ def summarize(release: pd.DataFrame, results: pd.DataFrame) -> pd.DataFrame:
4343 raise RuntimeError ("an exact assignment exceeded its matched movement budget" )
4444 if (results ["predicted_gain_pp" ] < - 1e-9 ).any ():
4545 raise RuntimeError ("supplied-score dominance failed" )
46+ joint_budget_slack = 2e-6 * (1 + results ["n_cases" ])
47+ if (
48+ results ["joint_expected_flips" ] > results ["flip_budget" ] + joint_budget_slack
49+ ).any ():
50+ raise RuntimeError ("a joint assignment exceeded its matched flip budget" )
51+ if (results ["joint_predicted_gain_pp" ] < - 1e-9 ).any ():
52+ raise RuntimeError ("joint supplied-score dominance failed" )
4653 if (results ["conditional_gain_pp" ] < results ["robust_lower_bound_pp" ] - 1e-8 ).any ():
4754 raise RuntimeError ("the probability-error lower bound failed" )
4855 endpoint = results [results ["alpha" ] == 1.0 ]
@@ -54,6 +61,9 @@ def summarize(release: pd.DataFrame, results: pd.DataFrame) -> pd.DataFrame:
5461 ).agg (
5562 move_share = ("baseline_move_share" , "mean" ),
5663 nfr = ("baseline_nfr" , "mean" ),
64+ operational_nfr = ("operational_nfr" , "mean" ),
65+ joint_nfr = ("joint_nfr" , "mean" ),
66+ joint_conditional_gain_pp = ("joint_conditional_gain_pp" , "mean" ),
5767 predicted_gain_pp = ("predicted_gain_pp" , "mean" ),
5868 conditional_gain_pp = ("conditional_gain_pp" , "mean" ),
5969 realized_gain_pp = ("realized_gain_pp" , "mean" ),
@@ -63,6 +73,10 @@ def summarize(release: pd.DataFrame, results: pd.DataFrame) -> pd.DataFrame:
6373 repetitions = ("realized_gain_pp" , "size" ),
6474 move_share = ("move_share" , "mean" ),
6575 nfr = ("nfr" , "mean" ),
76+ operational_nfr = ("operational_nfr" , "mean" ),
77+ joint_nfr = ("joint_nfr" , "mean" ),
78+ joint_conditional_gain_pp = ("joint_conditional_gain_pp" , "mean" ),
79+ joint_conditional_gain_se = ("joint_conditional_gain_pp" , "sem" ),
6680 predicted_gain_pp = ("predicted_gain_pp" , "mean" ),
6781 conditional_gain_pp = ("conditional_gain_pp" , "mean" ),
6882 conditional_gain_se = ("conditional_gain_pp" , "sem" ),
@@ -89,17 +103,20 @@ def write_table(summary: pd.DataFrame, path: Path) -> None:
89103 selected = summary [summary ["alpha" ].isin ([0.0 , 0.5 , 1.0 ])]
90104 rows = []
91105 for row in selected .itertuples (index = False ):
92- conditional_low = row .conditional_gain_pp - 1.96 * row .conditional_gain_se
93- conditional_high = row .conditional_gain_pp + 1.96 * row .conditional_gain_se
94- realized_low = row .realized_gain_pp - 1.96 * row .realized_gain_se
95- realized_high = row .realized_gain_pp + 1.96 * row .realized_gain_se
106+ qs_low = row .conditional_gain_pp - 1.96 * row .conditional_gain_se
107+ qs_high = row .conditional_gain_pp + 1.96 * row .conditional_gain_se
108+ joint_low = row .joint_conditional_gain_pp - 1.96 * row .joint_conditional_gain_se
109+ joint_high = (
110+ row .joint_conditional_gain_pp + 1.96 * row .joint_conditional_gain_se
111+ )
96112 rows .append (
97113 f"{ SCENARIO_LABELS [row .scenario ]} & { row .alpha :.1f} & "
98114 f"{ 100 * row .move_share :.2f} & "
99- f"{ row .predicted_gain_pp :.2f} & "
100- f"{ row .conditional_gain_pp :.2f} "
101- f"[{ conditional_low :.2f} , { conditional_high :.2f} ] & "
102- f"{ row .realized_gain_pp :.2f} [{ realized_low :.2f} , { realized_high :.2f} ] \\ \\ "
115+ f"{ 100 * row .nfr :.1f} & { 100 * row .operational_nfr :.1f} & "
116+ f"{ 100 * row .joint_nfr :.1f} & "
117+ f"{ row .conditional_gain_pp :.2f} [{ qs_low :.2f} , { qs_high :.2f} ] & "
118+ f"{ row .joint_conditional_gain_pp :.2f} "
119+ f"[{ joint_low :.2f} , { joint_high :.2f} ] \\ \\ "
103120 )
104121 content = "\n " .join (
105122 [
@@ -108,13 +125,14 @@ def write_table(summary: pd.DataFrame, path: Path) -> None:
108125 r"\caption{Estimated-model validation against NFR interpolation}" ,
109126 r"\label{tab:estimated-validation}" ,
110127 r"\scriptsize" ,
111- r"\begin{tabular}{lrrrrr }" ,
128+ r"\begin{tabular}{lrrrrrrr }" ,
112129 r"\toprule" ,
113130 (
114- r"Scenario & $\alpha$ & Shift (\%) & Score gain & "
115- r"True gain [95\% CI] & Realized gain [95\% CI] \\"
131+ r" & & Shift & \multicolumn{3}{c}{NFR (\%)} & "
132+ r"\multicolumn{2}{c}{ True gain over interp. (pp) [95\% CI]} \\"
116133 ),
117- r" & & & (pp) & (pp) & (pp) \\" ,
134+ r"\cmidrule(lr){4-6}\cmidrule(lr){7-8}" ,
135+ r"Scenario & $\alpha$ & (\%) & Interp. & QS & QS+flips & QS & QS+flips \\" ,
118136 r"\midrule" ,
119137 * rows ,
120138 r"\bottomrule" ,
@@ -125,8 +143,9 @@ def write_table(summary: pd.DataFrame, path: Path) -> None:
125143 r"estimated on historical samples and released only after the candidate "
126144 r"wins on an independent labeled sample. Each row compares exact "
127145 r"assignment with probability interpolation at the same realized queue "
128- r"shift. True gain uses the simulation's conditional probabilities and "
129- r"is unavailable in applications. Results average four planning batches "
146+ r"shift (QS), and at both its queue shift and its expected negative flips "
147+ r"(QS+flips). True gain uses the simulation's conditional "
148+ r"probabilities and is unavailable in applications. Results average four planning batches "
130149 r"within each independently trained accepted update before averaging "
131150 r"across updates."
132151 ),
0 commit comments