surrogates.api
surrogates.api
Classes
| Name | Description |
|---|---|
| Surrogate | |
| TrainableSurrogate | |
| SingleTaskGPSurrogate | |
| MultiTaskGPSurrogate | |
| BotorchSurrogates | |
| LinearDeterministicSurrogate | |
| EmpiricalSurrogate | All necessary functions has to be implemented in the model which can then be loaded |
| RandomForestSurrogate | BoFire Random Forest model. |
| MLPEnsemble | |
| PiecewiseLinearGPSurrogate |
Surrogate
surrogates.api.Surrogate(data_model)Attributes
| Name | Description |
|---|---|
| is_fitted | Return True if model is fitted, else False. |
Methods
| Name | Description |
|---|---|
| dumps | Dumps the actual model to a string as this is not directly json serializable. |
| loads | Loads the actual model from a string and writes it to the model attribute. |
dumps
surrogates.api.Surrogate.dumps()Dumps the actual model to a string as this is not directly json serializable.
loads
surrogates.api.Surrogate.loads(data)Loads the actual model from a string and writes it to the model attribute.
TrainableSurrogate
surrogates.api.TrainableSurrogate()Methods
| Name | Description |
|---|---|
| cross_validate | Perform a cross validation for the provided training data. |
| fit | Fit the surrogate model to the provided experiments. |
cross_validate
surrogates.api.TrainableSurrogate.cross_validate(
experiments,
folds=-1,
include_X=False,
include_labcodes=False,
random_state=None,
stratified_feature=None,
group_split_column=None,
hooks=None,
hook_kwargs=None,
)Perform a cross validation for the provided training data.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | Data on which the cross validation should be performed. | required |
| folds | int | Number of folds. -1 is equal to LOO CV. Defaults to -1. | -1 |
| include_X | bool | If true the X values of the fold are written to respective CvResult objects for later analysis. Defaults to False. | False |
| random_state | int | Controls the randomness of the indices in the train and test sets of each fold. Defaults to None. | None |
| stratified_feature | str | The feature name to preserve the percentage of samples for each class in the stratified folds. Defaults to None. | None |
| group_split_column | str | The column name of the group id. This parameter is used to ensure that the splits are made such that the same group is not present in both training and testing sets. This is useful in scenarios where data points are related or dependent on each other, and splitting them into different sets would violate the assumption of independence. The number of unique groups must be greater than or equal to the number of folds. Defaults to None. | None |
| hooks | Dict[str, Callable[[Model, pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame], Any]] | Dictionary of callable hooks that are called within the CV loop. The callable retrieves the current trained modeld and the current CV folds in the following order: X_train, y_train, X_test, y_test. Defaults to {}. | None |
| hook_kwargs | Dict[str, Dict[str, Any]] | Dictionary holding hook specific keyword arguments. Defaults to {}. | None |
Returns
| Name | Type | Description |
|---|---|---|
| Tuple[CvResults, CvResults, Dict[str, List[Any]]] | Tuple[CvResults, CvResults, Dict[str, List[Any]]]: First CvResults object reflects the training data, second CvResults object the test data, dictionary object holds the return values of the applied hooks. |
fit
surrogates.api.TrainableSurrogate.fit(experiments, options=None)Fit the surrogate model to the provided experiments.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | The experimental data to fit the model. | required |
| options | Optional[Dict] | Additional options for fitting the model. Defaults to None. | None |
SingleTaskGPSurrogate
surrogates.api.SingleTaskGPSurrogate(data_model, **kwargs)MultiTaskGPSurrogate
surrogates.api.MultiTaskGPSurrogate(data_model, **kwargs)BotorchSurrogates
surrogates.api.BotorchSurrogates(data_model, **kwargs)LinearDeterministicSurrogate
surrogates.api.LinearDeterministicSurrogate(data_model, **kwargs)EmpiricalSurrogate
surrogates.api.EmpiricalSurrogate(data_model, **kwargs)All necessary functions has to be implemented in the model which can then be loaded from cloud pickle.
Attributes
| Name | Type | Description |
|---|---|---|
| model | DeterministicModel | Botorch model instance. |
Methods
| Name | Description |
|---|---|
| loads | Loads the actual model from a base64 encoded pickle bytes object and writes it to the model attribute. |
loads
surrogates.api.EmpiricalSurrogate.loads(data)Loads the actual model from a base64 encoded pickle bytes object and writes it to the model attribute.
RandomForestSurrogate
surrogates.api.RandomForestSurrogate(data_model, **kwargs)BoFire Random Forest model.
The same hyperparameters are available as for the wrapped sklearn RandomForestRegreesor.
Methods
| Name | Description |
|---|---|
| loads | Loads the actual random forest from a base64 encoded pickle bytes object and writes it to the model attribute. |
loads
surrogates.api.RandomForestSurrogate.loads(data)Loads the actual random forest from a base64 encoded pickle bytes object and writes it to the model attribute.
MLPEnsemble
surrogates.api.MLPEnsemble(data_model, **kwargs)PiecewiseLinearGPSurrogate
surrogates.api.PiecewiseLinearGPSurrogate(data_model, **kwargs)