smac.epm.base_epm module

class smac.epm.base_epm.AbstractEPM(configspace: ConfigSpace.configuration_space.ConfigurationSpace, types: List[int], bounds: List[Tuple[float, float]], seed: int, instance_features: Optional[numpy.ndarray] = None, pca_components: Optional[int] = 7)[source]

Bases: object

Abstract implementation of the EPM API.

Note: The input dimensionality of Y for training and the output dimensions of all predictions (also called n_objectives) depends on the concrete implementation of this abstract class.

instance_features

Contains the K dimensional instance features of the I different instances

Type

np.ndarray(I, K)

pca

Object to perform PCA

Type

sklearn.decomposition.PCA

pca_components

Number of components to keep or None

Type

float

n_feats

Number of instance features

Type

int

n_params

Number of parameters in a configuration (only available after train has been called)

Type

int

scaler

Object to scale data to be withing [0, 1]

Type

sklearn.preprocessing.MinMaxScaler

var_threshold

Lower bound vor variance. If estimated variance < var_threshold, the set to var_threshold

Type

float

types

If set, contains a list with feature types (cat,const) of input vector

Type

list

Constructor

Parameters
  • configspace (ConfigurationSpace) – Configuration space to tune for.

  • types (List[int]) – Specifies the number of categorical values of an input dimension where the i-th entry corresponds to the i-th input dimension. Let’s say we have 2 dimension where the first dimension consists of 3 different categorical choices and the second dimension is continuous than we have to pass [3, 0]. Note that we count starting from 0.

  • bounds (List[Tuple[float, float]]) – bounds of input dimensions: (lower, uppper) for continuous dims; (n_cat, np.nan) for categorical dims

  • seed (int) – The seed that is passed to the model library.

  • instance_features (np.ndarray (I, K)) – Contains the K dimensional instance features of the I different instances

  • pca_components (float) – Number of components to keep when using PCA to reduce dimensionality of instance features. Requires to set n_feats (> pca_dims).

_predict(X: numpy.ndarray, cov_return_type: Optional[str] = 'diagonal_cov') → Tuple[numpy.ndarray, Optional[numpy.ndarray]][source]

Predict means and variances for given X.

Parameters
  • X (np.ndarray) – [n_samples, n_features (config + instance features)]

  • cov_return_type (typing.Optional[str]) – Specifies what to return along with the mean. Refer predict() for more information.

Returns

  • means (np.ndarray of shape = [n_samples, n_objectives]) – Predictive mean

  • vars (None or np.ndarray of shape = [n_samples, n_objectives] or [n_samples, n_samples]) – Predictive variance or standard deviation

_train(X: numpy.ndarray, Y: numpy.ndarray)smac.epm.base_epm.AbstractEPM[source]

Trains the random forest on X and y.

Parameters
  • X (np.ndarray [n_samples, n_features (config + instance features)]) – Input data points.

  • Y (np.ndarray [n_samples, n_objectives]) – The corresponding target values. n_objectives must match the number of target names specified in the constructor.

Returns

Return type

self

predict(X: numpy.ndarray, cov_return_type: Optional[str] = 'diagonal_cov') → Tuple[numpy.ndarray, Optional[numpy.ndarray]][source]

Predict means and variances for given X.

Parameters
  • X (np.ndarray of shape = [n_samples, n_features (config + instance features)]) – Training samples

  • cov_return_type (typing.Optional[str]) – Specifies what to return along with the mean. (Applies to only Gaussian Process for now) Can take 4 values: [None, diagonal_std, diagonal_cov, full_cov] * None - only mean is returned * diagonal_std - standard deviation at test points is returned * diagonal_cov - diagonal of the covariance matrix is returned * full_cov - whole covariance matrix between the test points is returned

Returns

  • means (np.ndarray of shape = [n_samples, n_objectives]) – Predictive mean

  • vars (None or np.ndarray of shape = [n_samples, n_objectives] or [n_samples, n_samples]) – Predictive variance or standard deviation

predict_marginalized_over_instances(X: numpy.ndarray) → Tuple[numpy.ndarray, numpy.ndarray][source]

Predict mean and variance marginalized over all instances.

Returns the predictive mean and variance marginalised over all instances for a set of configurations.

Parameters

X (np.ndarray) – [n_samples, n_features (config)]

Returns

  • means (np.ndarray of shape = [n_samples, 1]) – Predictive mean

  • vars (np.ndarray of shape = [n_samples, 1]) – Predictive variance

train(X: numpy.ndarray, Y: numpy.ndarray)smac.epm.base_epm.AbstractEPM[source]

Trains the EPM on X and Y.

Parameters
  • X (np.ndarray [n_samples, n_features (config + instance features)]) – Input data points.

  • Y (np.ndarray [n_samples, n_objectives]) – The corresponding target values. n_objectives must match the number of target names specified in the constructor.

Returns

self

Return type

AbstractEPM