data_models.surrogates.api
data_models.surrogates.api
Classes
| Name | Description |
|---|---|
| Surrogate | |
| SingleTaskGPSurrogate | |
| MultiTaskGPSurrogate | |
| TanimotoGPSurrogate | |
| RandomForestSurrogate | |
| MLPEnsemble | |
| SelectionSurrogate | Surrogate that chooses one of several complete surrogates by cross-validation. |
| LBFGSB | L-BFGS-B, the optimizer that fits a Gaussian process’s hyperparameters by |
| BotorchSurrogates | “List of botorch surrogates. |
Surrogate
data_models.surrogates.api.Surrogate()Attributes
| Name | Description |
|---|---|
| input_preprocessing_specs | Pre-model tensorization: every categorical is ordinal-encoded (the in-model |
Methods
| Name | Description |
|---|---|
| is_output_implemented | Abstract method to check output type for surrogate models |
is_output_implemented
data_models.surrogates.api.Surrogate.is_output_implemented(my_type)Abstract method to check output type for surrogate models Args: outputs: objective functions for the surrogate my_type: continuous or categorical output Returns: bool: True if the output type is valid for the surrogate chosen, False otherwise
SingleTaskGPSurrogate
data_models.surrogates.api.SingleTaskGPSurrogate()Methods
| Name | Description |
|---|---|
| additive_map_saas | Single-task GP for many inputs of which only a few are expected to matter. |
| is_output_implemented | Abstract method to check output type for surrogate models |
| linear | Single-task GP whose response is linear in the inputs. |
| mixed | Single-task GP for continuous and categorical inputs, as BoTorch’s |
| options | Single-task GPs that differ in kernel and priors, as options to choose from. |
| polynomial | Single-task GP whose response is a polynomial in the inputs. |
| robust | Single-task GP that detects outliers and discounts them: BoTorch’s |
| validate_sparse_outlier_likelihood | Outlier noise levels are fitted for one output only. |
additive_map_saas
data_models.surrogates.api.SingleTaskGPSurrogate.additive_map_saas(
inputs,
outputs,
n_taus=4,
*,
engineered_features=None,
)Single-task GP for many inputs of which only a few are expected to matter.
The maximum-a-posteriori approximation of the fully Bayesian SAAS model, as BoTorch’s AdditiveMapSaasSingleTaskGP builds it: an additive sparse kernel, a constant mean with a standard normal prior bounded to [-10, 10], and the default likelihood.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features. | required |
| outputs | Outputs | The output feature. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that the model sees as well; the kernel works on them too. If not provided, none. | None |
| n_taus | int | Number of sparse kernels summed up, each at its own sparsity level. | 4 |
Returns
| Name | Type | Description |
|---|---|---|
| SingleTaskGPSurrogate | The surrogate, with an additive MAP-SAAS kernel. |
is_output_implemented
data_models.surrogates.api.SingleTaskGPSurrogate.is_output_implemented(my_type)Abstract method to check output type for surrogate models Args: my_type: continuous or categorical output Returns: bool: True if the output type is valid for the surrogate chosen, False otherwise
linear
data_models.surrogates.api.SingleTaskGPSurrogate.linear(
inputs,
outputs,
*,
engineered_features=None,
)Single-task GP whose response is linear in the inputs.
Equivalent to Bayesian linear regression. The noise has a THREESIX prior with a lower bound of 1e-4; every other field keeps its default.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features. | required |
| outputs | Outputs | The output feature. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that the model sees as well; the kernel works on them too. If not provided, none. | None |
Returns
| Name | Type | Description |
|---|---|---|
| SingleTaskGPSurrogate | The surrogate, with a linear kernel. |
mixed
data_models.surrogates.api.SingleTaskGPSurrogate.mixed(
inputs,
outputs,
*,
engineered_features=None,
)Single-task GP for continuous and categorical inputs, as BoTorch’s MixedSingleTaskGP builds it.
Categorical inputs without descriptor data are encoded as ordinal codes and compared by a Hamming kernel; all other inputs and the engineered features by an RBF kernel with the HVARFNER prior. The kernel is the sum of the two plus their product, each scaled; without other inputs, the scaled Hamming kernel.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features, at least one of them categorical without descriptor data. | required |
| outputs | Outputs | The output feature. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that the model sees as well; the RBF kernel works on them. If not provided, none. | None |
Returns
| Name | Type | Description |
|---|---|---|
| SingleTaskGPSurrogate | The surrogate. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If no categorical input lacks descriptor data, or if an engineered feature replaces the features it is computed from. |
options
data_models.surrogates.api.SingleTaskGPSurrogate.options(
inputs,
outputs,
*,
engineered_features=None,
)Single-task GPs that differ in kernel and priors, as options to choose from.
One for each combination of base kernel (RBF, Matern 1.5, Matern 2.5), set of noise, lengthscale and outputscale priors (MBO, THREESIX, HVARFNER), with and without a scale kernel, and with and without ARD: 36 in all. Every other field keeps its default.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features of every option. | required |
| outputs | Outputs | The output feature of every option. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that every option sees as well; the kernel works on them too. If not provided, none. | None |
Returns
| Name | Type | Description |
|---|---|---|
| List[SingleTaskGPSurrogate] | The options, each with its own kernel and likelihood. |
polynomial
data_models.surrogates.api.SingleTaskGPSurrogate.polynomial(
inputs,
outputs,
power=2,
*,
engineered_features=None,
)Single-task GP whose response is a polynomial in the inputs.
The noise has a THREESIX prior with a lower bound of 1e-4; every other field keeps its default.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features. | required |
| outputs | Outputs | The output feature. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that the model sees as well; the kernel works on them too. If not provided, none. | None |
| power | int | Degree of the polynomial. | 2 |
Returns
| Name | Type | Description |
|---|---|---|
| SingleTaskGPSurrogate | The surrogate, with a polynomial kernel of the given power. |
robust
data_models.surrogates.api.SingleTaskGPSurrogate.robust(
inputs,
outputs,
*,
engineered_features=None,
)Single-task GP that detects outliers and discounts them: BoTorch’s RobustRelevancePursuitSingleTaskGP, with the lengthscales bounded at 0.05 instead of 0.025.
The likelihood adds an extra noise variance for observations treated as outliers to the HVARFNER noise model. The kernel is an RBF kernel with the HVARFNER prior whose lengthscales are at least 0.05, so that the model cannot simply explain the outliers.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inputs | Inputs | The input features. | required |
| outputs | Outputs | The output feature, exactly one. | required |
| engineered_features | Optional[EngineeredFeatures] | Quantities derived from the inputs that the model sees as well; the kernel works on them too. If not provided, none. | None |
Returns
| Name | Type | Description |
|---|---|---|
| SingleTaskGPSurrogate | The surrogate, with a SparseOutlierGaussianLikelihood. |
validate_sparse_outlier_likelihood
data_models.surrogates.api.SingleTaskGPSurrogate.validate_sparse_outlier_likelihood(
)Outlier noise levels are fitted for one output only.
MultiTaskGPSurrogate
data_models.surrogates.api.MultiTaskGPSurrogate()Methods
| Name | Description |
|---|---|
| is_output_implemented | Abstract method to check output type for surrogate models |
is_output_implemented
data_models.surrogates.api.MultiTaskGPSurrogate.is_output_implemented(my_type)Abstract method to check output type for surrogate models Args: my_type: continuous or categorical output Returns: bool: True if the output type is valid for the surrogate chosen, False otherwise
TanimotoGPSurrogate
data_models.surrogates.api.TanimotoGPSurrogate()Methods
| Name | Description |
|---|---|
| is_output_implemented | Abstract method to check output type for surrogate models |
| validate_moleculars | Checks that at least one fingerprint/fragment descriptor encoding is present. |
is_output_implemented
data_models.surrogates.api.TanimotoGPSurrogate.is_output_implemented(my_type)Abstract method to check output type for surrogate models Args: my_type: continuous or categorical output Returns: bool: True if the output type is valid for the surrogate chosen, False otherwise
validate_moleculars
data_models.surrogates.api.TanimotoGPSurrogate.validate_moleculars()Checks that at least one fingerprint/fragment descriptor encoding is present.
RandomForestSurrogate
data_models.surrogates.api.RandomForestSurrogate()Methods
| Name | Description |
|---|---|
| is_output_implemented | Abstract method to check output type for surrogate models |
is_output_implemented
data_models.surrogates.api.RandomForestSurrogate.is_output_implemented(my_type)Abstract method to check output type for surrogate models Args: my_type: continuous or categorical output Returns: bool: True if the output type is valid for the surrogate chosen, False otherwise
MLPEnsemble
data_models.surrogates.api.MLPEnsemble()SelectionSurrogate
data_models.surrogates.api.SelectionSurrogate()Surrogate that chooses one of several complete surrogates by cross-validation.
When fitted, every option is cross-validated on the data, and the one with the best score in metric is fitted on all of the data and makes the predictions. Every option has the inputs and the single continuous output of this surrogate.
Examples
>>> SelectionSurrogate(
... inputs=inputs,
... outputs=outputs,
... options=SingleTaskGPSurrogate.options(inputs, outputs),
... )Methods
| Name | Description |
|---|---|
| validate_options | Check that every option has the inputs and output of this surrogate. |
validate_options
data_models.surrogates.api.SelectionSurrogate.validate_options()Check that every option has the inputs and output of this surrogate.
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If an option’s inputs or outputs differ from this surrogate’s, or if there is more than one output. |
LBFGSB
data_models.surrogates.api.LBFGSB()L-BFGS-B, the optimizer that fits a Gaussian process’s hyperparameters by maximizing the marginal likelihood.
Options left at None keep BoTorch’s defaults: scipy’s for an ordinary fit, and its own (at most 10000 iterations, tolerances of 1e-8) for the relevance pursuit of a GP with a SparseOutlierGaussianLikelihood.
Examples
>>> LBFGSB(maxiter=200)BotorchSurrogates
data_models.surrogates.api.BotorchSurrogates()“List of botorch surrogates.
Behaves similar to a Surrogate.