Posterior Handler
LikelihoodBuilder
module-attribute
Type alias for likelihood builders, which take the number of datapoints as input and return a likelihood object initialised with the given number of datapoints.
PosteriorHandler
dataclass
PosteriorHandler(prior, likelihood_builder, optimization_objective, optimizer, num_optimization_iters)
Class for handling the creation and updating of a GP posterior as new data is observed.
Attributes:
-
prior
(AbstractPrior
) βprior to use when forming the posterior.
-
likelihood_builder
(LikelihoodBuilder
) βfunction which takes the number of datapoints as input and returns a likelihood object initialised with the given number of datapoints.
-
optimization_objective
(Objective
) βobjective to use for optimizing the posterior hyperparameters.
-
optimizer
(GradientTransformation
) βan optax optimizer to use for optimizing the posterior hyperparameters.
-
num_optimization_iterations
(GradientTransformation
) βthe number of iterations to optimize the posterior hyperparameters for.
get_posterior
Initialise (and optionally optimize) a posterior using the given dataset.
Parameters:
-
dataset
(Dataset
) βdataset to get posterior for.
-
optimize
(bool
) βwhether to optimize the posterior hyperparameters.
-
key
(Optional[KeyArray]
, default:None
) βa JAX PRNG key which is used for optimizing the posterior hyperparameters.
Returns:
-
AbstractPosterior
βPosterior for the given dataset.
update_posterior
Update the given posterior with the given dataset. This needs to be done when
the number of datapoints in the (training) dataset of the posterior changes, as
the AbstractLikelihood
class requires the number of datapoints to be specified.
Hyperparameters may or may not be optimized, depending on the value of the
optimize
parameter. Note that the updated poterior will be initialised with
the same prior hyperparameters as the previous posterior, but the likelihood
will be re-initialised with the new number of datapoints, and hyperparameters
set as in the likelihood_builder
function.
Parameters:
-
dataset
(Dataset
) βdataset to get posterior for.
-
previous_posterior
(AbstractPosterior
) βposterior being updated. This is supplied as one may wish to simply increase the number of datapoints in the likelihood, without optimizing the posterior hyperparameters, in which case the previous posterior can be used to obtain the previously set prior hyperparameters.
-
optimize
(bool
) βwhether to optimize the posterior hyperparameters.
-
key
(Optional[KeyArray]
, default:None
) βA JAX PRNG key which is used for optimizing the posterior hyperparameters.