Abstract facade
smac.facade.abstract_facade
#
AbstractFacade
#
AbstractFacade(
scenario: Scenario,
target_function: (
Callable | str | AbstractRunner | None
) = None,
*,
model: AbstractModel | None = None,
acquisition_function: (
AbstractAcquisitionFunction | None
) = None,
acquisition_maximizer: (
AbstractAcquisitionMaximizer | None
) = None,
initial_design: AbstractInitialDesign | None = None,
random_design: AbstractRandomDesign | None = None,
intensifier: AbstractIntensifier | None = None,
multi_objective_algorithm: (
AbstractMultiObjectiveAlgorithm | None
) = None,
runhistory_encoder: (
AbstractRunHistoryEncoder | None
) = None,
config_selector: ConfigSelector | None = None,
logging_level: (
int | Path | Literal[False] | None
) = None,
callbacks: list[Callback] = None,
overwrite: bool = False,
dask_client: Client | None = None
)
Facade is an abstraction on top of the SMBO backend to organize the components of a Bayesian Optimization loop in a configurable and separable manner to suit the various needs of different (hyperparameter) optimization pipelines.
With the exception to scenario and target_function, which are expected of the user, the parameters model,
acquisition_function, acquisition_maximizer, initial_design, random_design, intensifier,
multi_objective_algorithm, runhistory_encoder can either be explicitly specified in the subclasses'
get_* methods (defining a specific BO pipeline) or be instantiated by the user to overwrite a pipeline
components explicitly.
| PARAMETER | DESCRIPTION |
|---|---|
scenario
|
The scenario object, holding all environmental information.
TYPE:
|
target_function
|
This function is called internally to judge a trial's performance. If a string is passed,
it is assumed to be a script. In this case,
TYPE:
|
model
|
The surrogate model.
TYPE:
|
acquisition_function
|
The acquisition function.
TYPE:
|
acquisition_maximizer
|
The acquisition maximizer, deciding which configuration is most promising based on the surrogate model and acquisition function.
TYPE:
|
initial_design
|
The sampled configurations from the initial design are evaluated before the Bayesian optimization loop starts.
TYPE:
|
random_design
|
The random design is used in the acquisition maximizer, deciding whether the next configuration should be drawn from the acquisition function or randomly.
TYPE:
|
intensifier
|
The intensifier decides which trial (combination of configuration, seed, budget and instance) should be run next.
TYPE:
|
multi_objective_algorithm
|
In case of multiple objectives, the objectives need to be interpreted so that an optimization is possible. The multi-objective algorithm takes care of that.
TYPE:
|
runhistory_encoder
|
Based on the runhistory, the surrogate model is trained. However, the data first needs to be encoded, which is done by the runhistory encoder. For example, inactive hyperparameters need to be encoded or cost values can be log transformed.
TYPE:
|
logging_level
|
The level of logging (the lowest level 0 indicates the debug level). If a path is passed, a yaml file is expected with the logging configuration. If nothing is passed, the default logging.yml from SMAC is used. If False is passed, SMAC will not do any customization of the logging setup and the responsibility is left to the user. |
callbacks
|
Callbacks, which are incorporated into the optimization loop. |
overwrite
|
When True, overwrites the run results if a previous run is found that is consistent in the meta data with the current setup. When False and a previous run is found that is consistent in the meta data, the run is continued. When False and a previous run is found that is not consistent in the meta data, the the user is asked for the exact behaviour (overwrite completely or rename old run first).
TYPE:
|
dask_client
|
User-created dask client, which can be used to start a dask cluster and then attach SMAC to it. This will not be closed automatically and will have to be closed manually if provided explicitly. If none is provided (default), a local one will be created for you and closed upon completion.
TYPE:
|
Source code in smac/facade/abstract_facade.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
intensifier
property
#
intensifier: AbstractIntensifier
The optimizer which is responsible for the BO loop. Keeps track of useful information like status.
meta
property
#
Generates a hash based on all components of the facade. This is used for the run name or to determine whether a run should be continued or not.
optimizer
property
#
optimizer: SMBO
The optimizer which is responsible for the BO loop. Keeps track of useful information like status.
runhistory
property
#
runhistory: RunHistory
The runhistory which is filled with all trials during the optimization process.
get_acquisition_function
abstractmethod
staticmethod
#
get_acquisition_function(
scenario: Scenario,
) -> AbstractAcquisitionFunction
Returns the acquisition function instance used in the BO loop, defining the exploration/exploitation trade-off.
Source code in smac/facade/abstract_facade.py
get_acquisition_maximizer
abstractmethod
staticmethod
#
get_acquisition_maximizer(
scenario: Scenario,
) -> AbstractAcquisitionMaximizer
Returns the acquisition optimizer instance to be used in the BO loop, specifying how the acquisition function instance is optimized.
Source code in smac/facade/abstract_facade.py
get_config_selector
staticmethod
#
get_config_selector(
scenario: Scenario,
*,
retrain_after: int = 8,
retries: int = 16
) -> ConfigSelector
Returns the default configuration selector.
Source code in smac/facade/abstract_facade.py
get_initial_design
abstractmethod
staticmethod
#
get_initial_design(
scenario: Scenario,
) -> AbstractInitialDesign
Returns an instance of the initial design class to be used in the BO loop, specifying how the configurations the BO loop is 'warm-started' with are selected.
Source code in smac/facade/abstract_facade.py
get_intensifier
abstractmethod
staticmethod
#
get_intensifier(scenario: Scenario) -> AbstractIntensifier
Returns the intensifier instance to be used in the BO loop, specifying how to challenge the incumbent configuration on other problem instances.
Source code in smac/facade/abstract_facade.py
get_model
abstractmethod
staticmethod
#
get_model(scenario: Scenario) -> AbstractModel
Returns the surrogate cost model instance used in the BO loop.
get_multi_objective_algorithm
abstractmethod
staticmethod
#
get_multi_objective_algorithm(
scenario: Scenario,
) -> AbstractMultiObjectiveAlgorithm
Returns the multi-objective algorithm instance to be used in the BO loop, specifying the scalarization strategy for multiple objectives' costs.
Source code in smac/facade/abstract_facade.py
get_random_design
abstractmethod
staticmethod
#
get_random_design(
scenario: Scenario,
) -> AbstractRandomDesign
Returns an instance of the random design class to be used in the BO loop, specifying how to interleave the BO iterations with randomly selected configurations.
Source code in smac/facade/abstract_facade.py
get_runhistory_encoder
abstractmethod
staticmethod
#
get_runhistory_encoder(
scenario: Scenario,
) -> AbstractRunHistoryEncoder
Returns an instance of the runhistory encoder class to be used in the BO loop, specifying how the runhistory is to be prepared for the next surrogate model.
Source code in smac/facade/abstract_facade.py
optimize
#
Optimizes the configuration of the algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
data_to_scatter
|
We first note that this argument is valid only dask_runner! When a user scatters data from their local process to the distributed network, this data is distributed in a round-robin fashion grouping by number of cores. Roughly speaking, we can keep this data in memory and then we do not have to (de-)serialize the data every time we would like to execute a target function with a big dataset. For example, when your target function has a big dataset shared across all the target function, this argument is very useful. |
| RETURNS | DESCRIPTION |
|---|---|
incumbent
|
Best found configuration.
TYPE:
|
Source code in smac/facade/abstract_facade.py
tell
#
tell(
info: TrialInfo, value: TrialValue, save: bool = True
) -> None
Adds the result of a trial to the runhistory and updates the intensifier.
| PARAMETER | DESCRIPTION |
|---|---|
info
|
Describes the trial from which to process the results.
TYPE:
|
value
|
Contains relevant information regarding the execution of a trial.
TYPE:
|
save
|
Whether the runhistory should be saved.
TYPE:
|
Source code in smac/facade/abstract_facade.py
validate
#
Validates a configuration on seeds different from the ones used in the optimization process and on the highest budget (if budget type is real-valued).
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Configuration to validate
TYPE:
|
seed
|
If None, the seed from the scenario is used.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
cost
|
The averaged cost of the configuration. In case of multi-fidelity, the cost of each objective is averaged. |