@@ -183,12 +183,18 @@ def stat_func(x):
183183
184184 length_treatment = len (treatment_group )
185185
186+ # Calculate holdout percentage - percentage of metric that treatment states represent
187+ total_metric_sum = df_pivot .sum (axis = 1 ).sum () # Sum of all locations across all time periods
188+ treatment_metric_sum = df_pivot [treatment_group ].sum (axis = 1 ).sum () # Sum of treatment locations across all time periods
189+ holdout_percentage = 100 - round ((treatment_metric_sum / total_metric_sum ) * 100 , 2 )
190+
186191 logger .info (f"Final results:" )
187192 logger .info (f" MAPE: { MAPE :.4f} " )
188193 logger .info (f" SMAPE: { SMAPE :.4f} " )
189194 logger .info (f" Percentage lift: { percenge_lift :.4f} %" )
190195 logger .info (f" P-value: { p_value :.6f} " )
191196 logger .info (f" Power: { power :.4f} " )
197+ logger .info (f" Holdout percentage: { holdout_percentage :.2f} %" )
192198
193199 results_evaluation = {
194200 "MAPE" : MAPE ,
@@ -205,6 +211,7 @@ def stat_func(x):
205211 "period" : period ,
206212 "spend" : round (float (spend ), 2 ),
207213 "length_treatment" : length_treatment ,
214+ "holdout_percentage" : holdout_percentage ,
208215 # Complete data for plotting (including post-treatment)
209216 "counterfactual_complete" : np .round (counterfactual_complete , 2 ),
210217 "treatment_complete" : np .round (treatment_complete , 2 ),
@@ -354,6 +361,7 @@ def get_evaluation_chart_data(
354361 "null_stats" : results ["null_stats" ].tolist (),
355362 "control_group" : results ["control_group" ],
356363 "weights" : results ["weights" ],
364+ "holdout_percentage" : results ["holdout_percentage" ],
357365 }
358366
359367 logger .info ("get_evaluation_chart_data completed successfully" )
0 commit comments