@@ -254,7 +254,8 @@ def list_evaluations_setups(
254254 tag : Optional [str ] = None ,
255255 per_fold : Optional [bool ] = None ,
256256 sort_order : Optional [str ] = None ,
257- output_format : str = 'dataframe'
257+ output_format : str = 'dataframe' ,
258+ parameters_in_separate_columns : bool = False
258259) -> Union [Dict , pd .DataFrame ]:
259260 """
260261 List all run-evaluation pairs matching all of the given filters
@@ -287,12 +288,19 @@ def list_evaluations_setups(
287288 The parameter decides the format of the output.
288289 - If 'dict' the output is a dict of dict
289290 - If 'dataframe' the output is a pandas DataFrame
291+ parameters_in_separate_columns: bool, optional (default= False)
292+ Returns hyperparameters in separate columns if set to True.
293+ Valid only for a single flow
290294
291295
292296 Returns
293297 -------
294298 dict or dataframe with hyperparameter settings as a list of tuples.
295299 """
300+ if parameters_in_separate_columns and (flow is None or len (flow ) != 1 ):
301+ raise ValueError ("Can set parameters_in_separate_columns to true "
302+ "only for single flow_id" )
303+
296304 # List evaluations
297305 evals = list_evaluations (function = function , offset = offset , size = size , id = id , task = task ,
298306 setup = setup , flow = flow , uploader = uploader , tag = tag ,
@@ -315,14 +323,18 @@ def list_evaluations_setups(
315323 # Convert parameters of setup into list of tuples of (hyperparameter, value)
316324 for parameter_dict in setups ['parameters' ]:
317325 if parameter_dict is not None :
318- parameters .append ([ tuple ([ param ['parameter_name' ], param ['value' ]])
319- for param in parameter_dict .values ()] )
326+ parameters .append ({ param ['full_name' ]: param ['value' ]
327+ for param in parameter_dict .values ()} )
320328 else :
321- parameters .append ([] )
329+ parameters .append ({} )
322330 setups ['parameters' ] = parameters
323331 # Merge setups with evaluations
324332 df = pd .merge (evals , setups , on = 'setup_id' , how = 'left' )
325333
334+ if parameters_in_separate_columns :
335+ df = pd .concat ([df .drop ('parameters' , axis = 1 ),
336+ df ['parameters' ].apply (pd .Series )], axis = 1 )
337+
326338 if output_format == 'dataframe' :
327339 return df
328340 else :
0 commit comments