@@ -80,10 +80,10 @@ def __init__(self, *, # pylint: disable=too-many-locals,too-many-arguments
80
80
See Also: mlos_bench.optimizer.bulk_register
81
81
82
82
max_ratio : Optional[int]
83
- Maximum ratio of max_trials to be random configurations to be evaluated
83
+ Maximum ratio of max_trials to be random configs to be evaluated
84
84
at start to bootstrap the optimizer.
85
85
Useful if you want to explicitly control the number of random
86
- configurations evaluated at start.
86
+ configs evaluated at start.
87
87
88
88
use_default_config: bool
89
89
Whether to use the default config for the first trial after random initialization.
@@ -168,7 +168,7 @@ def __init__(self, *, # pylint: disable=too-many-locals,too-many-arguments
168
168
initial_design_args ['n_configs' ] = n_random_init
169
169
if n_random_init > 0.25 * max_trials and max_ratio is None :
170
170
warning (
171
- 'Number of random initial configurations (%d) is ' +
171
+ 'Number of random initial configs (%d) is ' +
172
172
'greater than 25%% of max_trials (%d). ' +
173
173
'Consider setting max_ratio to avoid SMAC overriding n_random_init.' ,
174
174
n_random_init ,
@@ -241,17 +241,17 @@ def _dummy_target_func(config: ConfigSpace.Configuration, seed: int = 0) -> None
241
241
# -- this planned to be fixed in some future release: https://github.com/automl/SMAC3/issues/946
242
242
raise RuntimeError ('This function should never be called.' )
243
243
244
- def _register (self , configurations : pd .DataFrame ,
244
+ def _register (self , * , configs : pd .DataFrame ,
245
245
scores : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> None :
246
- """Registers the given configurations and scores.
246
+ """Registers the given configs and scores.
247
247
248
248
Parameters
249
249
----------
250
- configurations : pd.DataFrame
251
- Dataframe of configurations / parameters. The columns are parameter names and the rows are the configurations .
250
+ configs : pd.DataFrame
251
+ Dataframe of configs / parameters. The columns are parameter names and the rows are the configs .
252
252
253
253
scores : pd.DataFrame
254
- Scores from running the configurations . The index is the same as the index of the configurations .
254
+ Scores from running the configs . The index is the same as the index of the configs .
255
255
256
256
context : pd.DataFrame
257
257
Not Yet Implemented.
@@ -262,7 +262,7 @@ def _register(self, configurations: pd.DataFrame,
262
262
warn (f"Not Implemented: Ignoring context { list (context .columns )} " , UserWarning )
263
263
264
264
# Register each trial (one-by-one)
265
- for (config , (_i , score )) in zip (self ._to_configspace_configs (configurations ), scores .iterrows ()):
265
+ for (config , (_i , score )) in zip (self ._to_configspace_configs (configs = configs ), scores .iterrows ()):
266
266
# Retrieve previously generated TrialInfo (returned by .ask()) or create new TrialInfo instance
267
267
info : TrialInfo = self .trial_info_map .get (
268
268
config , TrialInfo (config = config , seed = self .base_optimizer .scenario .seed ))
@@ -272,7 +272,7 @@ def _register(self, configurations: pd.DataFrame,
272
272
# Save optimizer once we register all configs
273
273
self .base_optimizer .optimizer .save ()
274
274
275
- def _suggest (self , context : Optional [pd .DataFrame ] = None ) -> pd .DataFrame :
275
+ def _suggest (self , * , context : Optional [pd .DataFrame ] = None ) -> pd .DataFrame :
276
276
"""Suggests a new configuration.
277
277
278
278
Parameters
@@ -299,10 +299,10 @@ def _suggest(self, context: Optional[pd.DataFrame] = None) -> pd.DataFrame:
299
299
config_df = pd .DataFrame ([trial .config ], columns = list (self .optimizer_parameter_space .keys ()))
300
300
return config_df
301
301
302
- def register_pending (self , configurations : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> None :
302
+ def register_pending (self , * , configs : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> None :
303
303
raise NotImplementedError ()
304
304
305
- def surrogate_predict (self , configurations : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> npt .NDArray :
305
+ def surrogate_predict (self , * , configs : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> npt .NDArray :
306
306
from smac .utils .configspace import convert_configurations_to_array # pylint: disable=import-outside-toplevel
307
307
308
308
if context is not None :
@@ -318,11 +318,11 @@ def surrogate_predict(self, configurations: pd.DataFrame, context: Optional[pd.D
318
318
if self .base_optimizer ._config_selector ._model is None :
319
319
raise RuntimeError ('Surrogate model is not yet trained' )
320
320
321
- configs : npt .NDArray = convert_configurations_to_array (self ._to_configspace_configs (configurations ))
322
- mean_predictions , _ = self .base_optimizer ._config_selector ._model .predict (configs )
321
+ config_array : npt .NDArray = convert_configurations_to_array (self ._to_configspace_configs (configs = configs ))
322
+ mean_predictions , _ = self .base_optimizer ._config_selector ._model .predict (config_array )
323
323
return mean_predictions .reshape (- 1 ,)
324
324
325
- def acquisition_function (self , configurations : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> npt .NDArray :
325
+ def acquisition_function (self , * , configs : pd .DataFrame , context : Optional [pd .DataFrame ] = None ) -> npt .NDArray :
326
326
if context is not None :
327
327
warn (f"Not Implemented: Ignoring context { list (context .columns )} " , UserWarning )
328
328
if self ._space_adapter :
@@ -332,28 +332,28 @@ def acquisition_function(self, configurations: pd.DataFrame, context: Optional[p
332
332
if self .base_optimizer ._config_selector ._acquisition_function is None :
333
333
raise RuntimeError ('Acquisition function is not yet initialized' )
334
334
335
- configs : list = self ._to_configspace_configs (configurations )
336
- return self .base_optimizer ._config_selector ._acquisition_function (configs ).reshape (- 1 ,)
335
+ cs_configs : list = self ._to_configspace_configs (configs = configs )
336
+ return self .base_optimizer ._config_selector ._acquisition_function (cs_configs ).reshape (- 1 ,)
337
337
338
338
def cleanup (self ) -> None :
339
339
if self ._temp_output_directory is not None :
340
340
self ._temp_output_directory .cleanup ()
341
341
self ._temp_output_directory = None
342
342
343
- def _to_configspace_configs (self , configurations : pd .DataFrame ) -> List [ConfigSpace .Configuration ]:
344
- """Convert a dataframe of configurations to a list of ConfigSpace configurations .
343
+ def _to_configspace_configs (self , * , configs : pd .DataFrame ) -> List [ConfigSpace .Configuration ]:
344
+ """Convert a dataframe of configs to a list of ConfigSpace configs .
345
345
346
346
Parameters
347
347
----------
348
- configurations : pd.DataFrame
349
- Dataframe of configurations / parameters. The columns are parameter names and the rows are the configurations .
348
+ configs : pd.DataFrame
349
+ Dataframe of configs / parameters. The columns are parameter names and the rows are the configs .
350
350
351
351
Returns
352
352
-------
353
- configurations : list
354
- List of ConfigSpace configurations .
353
+ configs : list
354
+ List of ConfigSpace configs .
355
355
"""
356
356
return [
357
357
ConfigSpace .Configuration (self .optimizer_parameter_space , values = config .to_dict ())
358
- for (_ , config ) in configurations .astype ('O' ).iterrows ()
358
+ for (_ , config ) in configs .astype ('O' ).iterrows ()
359
359
]
0 commit comments