smac.epm.base_epm¶
Classes
|
Abstract implementation of the EPM API. |
- class smac.epm.base_epm.BaseEPM(configspace, types, bounds, seed, instance_features=None, pca_components=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.- 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).
- 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
- get_configspace()[source]¶
Retrieves the ConfigurationSpace used for the model.
- Returns
self.configspace
- Return type
The ConfigurationSpace of the model
- predict(X, cov_return_type='diagonal_cov')[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 (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
- Return type
Tuple
[ndarray
,Optional
[ndarray
]]- 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)[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)]
- Return type
Tuple
[ndarray
,ndarray
]- Returns
means (np.ndarray of shape = [n_samples, 1]) – Predictive mean
vars (np.ndarray of shape = [n_samples, 1]) – Predictive variance
- train(X, Y)[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