smac.model

Interfaces

class smac.model.AbstractModel(configspace, instance_features=None, pca_components=7, seed=0)[source]

Bases: object

Abstract implementation of the surrogate model.

Note

The input dimensionality of Y for training and the output dimensions of all predictions depend on the concrete implementation of this abstract class.

Parameters:
  • configspace (ConfigurationSpace) –

  • instance_features (dict[str, list[int | float]] | None, defaults to None) – Features (list of int or floats) of the instances (str). The features are incorporated into the X data, on which the model is trained on.

  • pca_components (float, defaults to 7) – Number of components to keep when using PCA to reduce dimensionality of instance features.

  • seed (int) –

property meta: dict[str, Any]

Returns the meta data of the created object.

predict(X, covariance_type='diagonal')[source]

Predicts mean and variance for a given X. Internally, calls the method _predict.

Parameters:
  • X (np.ndarray [#samples, #hyperparameters + #features]) – Input data points.

  • covariance_type (str | None, defaults to "diagonal") – Specifies what to return along with the mean. Applied only to Gaussian Processes. Takes four valid inputs: * None: Only the mean is returned. * “std”: Standard deviation at test points is returned. * “diagonal”: Diagonal of the covariance matrix is returned. * “full”: Whole covariance matrix between the test points is returned.

Return type:

tuple[ndarray, Optional[ndarray]]

Returns:

  • means (np.ndarray [#samples, #objectives]) – The predictive mean.

  • vars (np.ndarray [#samples, #objectives] or [#samples, #samples] | None) – Predictive variance or standard deviation.

predict_marginalized(X)[source]

Predicts mean and variance marginalized over all instances.

Warning

The input data must not include any features.

Parameters:

X (np.ndarray [#samples, #hyperparameters]) – Input data points.

Return type:

tuple[ndarray, ndarray]

Returns:

  • means (np.ndarray [#samples, 1]) – The predictive mean.

  • vars (np.ndarray [#samples, 1]) – The predictive variance.

train(X, Y)[source]

Trains the random forest on X and Y. Internally, calls the method _train.

Parameters:
  • X (np.ndarray [#samples, #hyperparameters + #features]) – Input data points.

  • Y (np.ndarray [#samples, #objectives]) – The corresponding target values.

Returns:

self

Return type:

AbstractModel

class smac.model.MultiObjectiveModel(models, objectives, seed=0)[source]

Bases: AbstractModel

Wrapper for the surrogate model to predict multiple objectives.

Parameters:
  • models (AbstractModel | list[AbstractModel]) – Which model should be used. If it is a list, then it must provide as many models as objectives. If it is a single model only, the model is used for all objectives.

  • objectives (list[str]) – Which objectives should be used.

  • seed (int) –

property models: list[smac.model.abstract_model.AbstractModel]

The internally used surrogate models.

predict_marginalized(X)[source]

Predicts mean and variance marginalized over all instances.

Warning

The input data must not include any features.

Parameters:

X (np.ndarray [#samples, #hyperparameters]) – Input data points.

Return type:

tuple[ndarray, ndarray]

Returns:

  • means (np.ndarray [#samples, 1]) – The predictive mean.

  • vars (np.ndarray [#samples, 1]) – The predictive variance.

class smac.model.RandomModel(configspace, instance_features=None, pca_components=7, seed=0)[source]

Bases: AbstractModel

AbstractModel which returns random values on a call to fit.

Modules

smac.model.abstract_model

smac.model.gaussian_process

smac.model.multi_objective_model

smac.model.random_forest

smac.model.random_model