smac.optimizer.subspaces¶
Classes
|
|
|
A subspace that is designed for local Bayesian Optimization. |
- class smac.optimizer.subspaces.ChallengerListLocal(cs_local, cs_global, challengers, config_origin, incumbent_array=None)[source]¶
Bases:
Iterator
- class smac.optimizer.subspaces.LocalSubspace(config_space, bounds, hps_types, bounds_ss_cont=None, bounds_ss_cat=None, model_local=<class 'smac.epm.gaussian_process.augmented.GloballyAugmentedLocalGaussianProcess'>, model_local_kwargs={}, acq_func_local=<class 'smac.optimizer.acquisition.EI'>, acq_func_local_kwargs=None, rng=None, initial_data=None, activate_dims=None, incumbent_array=None)[source]¶
Bases:
abc.ABC
A subspace that is designed for local Bayesian Optimization. If bounds_ss_cont and bounds_ss_cat are not given, this subspace is equivalent to the original configuration space. Additionally, this subspace supports local BO that only works with a subset of the dimensions, where the missing values are filled by the corresponding values from incumbent_array.
- Parameters
config_space (ConfigurationSpace) – raw Configuration space
bounds (List[Tuple[float, float]]) – raw bounds of the Configuration space, notice that here bounds denotes the bounds of the entire space
hps_types (List[int],) – types of the hyperparameters
bounds_ss_cont (np.ndarray(D_cont, 2)) – subspaces bounds of continuous hyperparameters, its length is the number of continuous hyperparameters
bounds_ss_cat (List[Tuple]) – subspaces bounds of categorical hyperparameters, its length is the number of categorical hyperparameters
rng (np.random.RandomState) – random state
model_local (BaseEPM) – model in subspace
model_local_kwargs (Optional[Dict]) – argument for subspace model
acq_func_local (AbstractAcquisitionFunction) – local acquisition function
acq_func_local_kwargs (Optional[Dict]) – argument for acquisition function
activate_dims (Optional[np.ndarray]) – activate dimensions in the subspace, if it is None, we preserve all the dimensions
incumbent_array (Optional[np.ndarray]) – incumbent array, used when activate_dims has less dimension and this value is used to complementary the resulted configurations
- add_new_observations(X, y)[source]¶
Add new observations to the subspace
- Parameters
X (np.ndarray(N,D),) – new feature vector of the observations, constructed by the global configuration space
y (np.ndarray(N)) – new performances of the observations
- Returns
indices_in_ss – indices of data that included in subspaces
- Return type
np.ndarray(N)
- static fit_forbidden_to_ss(cs_local, forbidden)[source]¶
Fit the forbidden to subspaces. If the target forbidden can be added to subspace, we return a new forbidden with exactly the same type of the input forbidden. Otherwise, None is returned.
- Parameters
cs_local (ConfigurationSpace) – local configuration space of the subspace
forbidden (AbstractForbiddenComponent) – forbidden to check
- Returns
forbidden_ss – forbidden in subspaces
- Return type
Optional[AbstractForbiddenComponent]
- generate_challengers(**optimizer_kwargs)[source]¶
Generate a list of challengers that will be transformed into the global configuration space
- Parameters
optimizer_kwargs (Any) – additional configurations passed to ‘self._generate_challengers’
- Return type
A list of challengers in the global configuration space
- normalize_input(X)[source]¶
Normalize X to fit the local configuration space
- Parameters
X (np.ndarray(N,D)) – input X, configurations arrays
- Returns
X_normalized – normalized input X
- Return type
np.ndarray(N,D)
- update_incumbent_array(new_incumbent)[source]¶
Update a new incumbent array. The array is generated from the global configuration
- Parameters
new_incumbent (np.ndarray(D)) – new incumbent, which correspondences to the global configuration
- Return type
None
- update_model(predict_x_best=True, update_incumbent_array=False)[source]¶
Update the model and acquisition function parameters
- Parameters
predict_x_best (bool,) – if the incumbent is acquired by the predicted mean of a surrogate model
update_incumbent_array (bool) – if the incumbent_array of this subspace is replaced with the newly updated incumbent
- Return type
None
Modules