GaussianProcessSurrogate¶
- class baybe.surrogates.gaussian_process.core.GaussianProcessSurrogate[source]¶
Bases:
Surrogate
A Gaussian process surrogate model.
Public methods
__init__
([kernel_or_factory])Method generated by attrs for class GaussianProcessSurrogate.
fit
(searchspace, train_x, train_y)Train the surrogate model on the provided data.
from_dict
(dictionary)Create an object from its dictionary representation.
from_json
(string)Create an object from its JSON representation.
Create a Gaussian process surrogate from one of the defined presets.
posterior
(candidates)Evaluate the surrogate model at the given candidate points.
Create the botorch-ready representation of the model.
to_dict
()Create an object's dictionary representation.
to_json
()Create an object's JSON representation.
Public attributes and properties
The factory used to create the kernel of the Gaussian process.
Class variable encoding whether or not a joint posterior is calculated.
Class variable encoding whether or not the surrogate supports transfer learning.
- __init__(kernel_or_factory: Kernel | KernelFactory = NOTHING)¶
Method generated by attrs for class GaussianProcessSurrogate.
For details on the parameters, see Public attributes and properties.
- fit(searchspace: SearchSpace, train_x: Tensor, train_y: Tensor)¶
Train the surrogate model on the provided data.
- Parameters:
searchspace (SearchSpace) – The search space in which experiments are conducted.
train_x (Tensor) – The training data points.
train_y (Tensor) – The training data labels.
- Raises:
ValueError – If the search space contains task parameters but the selected surrogate model type does not support transfer learning.
NotImplementedError – When using a continuous search space and a non-GP model.
- Return type:
None
- classmethod from_preset()[source]¶
Create a Gaussian process surrogate from one of the defined presets.
- Return type:
- posterior(candidates: Tensor)¶
Evaluate the surrogate model at the given candidate points.
- Parameters:
candidates (Tensor) – The candidate points, represented as a tensor of shape
(*t, q, d)
, wheret
denotes the “t-batch” shape,q
denotes the “q-batch” shape, andd
is the input dimension. For more details about batch shapes, see: https://botorch.org/docs/batching- Return type:
tuple[Tensor, Tensor]
- Returns:
The posterior means and posterior covariance matrices of the t-batched candidate points.
- to_json()¶
Create an object’s JSON representation.
- Return type:
- Returns:
The JSON representation as a string.
-
joint_posterior:
ClassVar
[bool
] = True¶ Class variable encoding whether or not a joint posterior is calculated.
-
kernel_factory:
KernelFactory
¶ The factory used to create the kernel of the Gaussian process.
Accepts either a
baybe.kernels.base.Kernel
or akernel_factory.KernelFactory
. When passing abaybe.kernels.base.Kernel
, it gets automatically wrapped into akernel_factory.PlainKernelFactory
.