@@ -806,7 +806,7 @@ def get_opt_trace_by_steps(experiment: Experiment) -> npt.NDArray:
806806 "Cumulative epochs not supported for problems with outcome constraints."
807807 )
808808
809- objective_name = optimization_config .objective .metric .name
809+ objective_name : str = optimization_config .objective .metric .name
810810 data = assert_is_instance (experiment .lookup_data (), MapData )
811811 map_df = data .map_df
812812
@@ -815,39 +815,40 @@ def get_opt_trace_by_steps(experiment: Experiment) -> npt.NDArray:
815815 # to know which actually ran
816816 def _get_df (trial : Trial ) -> pd .DataFrame :
817817 """
818- Get the (virtual) time each epoch finished at.
818+ Get the (virtual) time each epoch finished at, along with the ground
819+ truth values (Y_true).
819820 """
820821 metadata = trial .run_metadata ["benchmark_metadata" ]
821822 backend_simulator = none_throws (metadata .backend_simulator )
822- # Data for the first metric, which is the only metric
823- df = next ( iter ( metadata .dfs . values ()) )
823+ # Get the DataFrame for the objective metric
824+ df = metadata .dfs [ objective_name ]. copy ( )
824825 start_time = backend_simulator .get_sim_trial_by_index (
825826 trial .index
826827 ).sim_start_time
827828 df ["time" ] = df ["virtual runtime" ] + start_time
828829 return df
829830
830- with_timestamps = pd .concat (
831+ with_timestamps_and_y_true = pd .concat (
831832 (
832833 _get_df (trial = assert_is_instance (trial , Trial ))
833834 for trial in experiment .trials .values ()
834835 ),
835836 axis = 0 ,
836837 ignore_index = True ,
837- )[["trial_index" , MAP_KEY , "time" ]]
838+ )[["trial_index" , MAP_KEY , "time" , "Y_true" ]]
838839
839840 df = (
840841 map_df .loc [
841842 map_df ["metric_name" ] == objective_name ,
842- ["trial_index" , "arm_name" , "mean" , MAP_KEY ],
843+ ["trial_index" , "arm_name" , MAP_KEY ],
843844 ]
844- .merge (with_timestamps , how = "left" )
845+ .merge (with_timestamps_and_y_true , how = "left" )
845846 .sort_values ("time" , ignore_index = True )
846847 )
847848 return (
848- df ["mean " ].cummin ()
849+ df ["Y_true " ].cummin ()
849850 if optimization_config .objective .minimize
850- else df ["mean " ].cummax ()
851+ else df ["Y_true " ].cummax ()
851852 ).to_numpy ()
852853
853854
0 commit comments