Thompson Sampling
gpjax.decision_making.utility_functions.thompson_sampling
ThompsonSampling
dataclass
Bases: AbstractSinglePointUtilityFunctionBuilder
Form a utility function by drawing an approximate sample from the posterior, using decoupled sampling as introduced in Wilson et. al. (2020). Note that we return the negative of the sample as the utility function, as utility functions are maximised.
Note that this is a single batch utility function, as it doesn't support classical
batching. However, Thompson sampling can be used in a batched setting by drawing a
batch of different samples from the GP posterior. This can be done by calling
build_utility_function
with different keys, an example of which can be seen in the
ask
method of the UtilityDrivenDecisionMaker
class. The samples can then be
optimised sequentially.
Attributes:
Name | Type | Description |
---|---|---|
num_features |
int
|
The number of random Fourier features to use when drawing the approximate sample from the posterior. Defaults to 100. |
num_features: int = 100
class-attribute
instance-attribute
check_objective_present(posteriors: Mapping[str, AbstractPosterior], datasets: Mapping[str, Dataset]) -> None
Check that the objective posterior and dataset are present in the posteriors and datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
posteriors |
Mapping[str, AbstractPosterior]
|
Dictionary of posteriors to be |
required |
datasets |
Mapping[str, Dataset]
|
Dictionary of datasets which may be used |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the objective posterior or dataset are not present in the |
__post_init__()
build_utility_function(posteriors: Mapping[str, ConjugatePosterior], datasets: Mapping[str, Dataset], key: KeyArray) -> SinglePointUtilityFunction
Draw an approximate sample from the posterior of the objective model and return the negative of this sample as a utility function, as utility functions are maximised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
posteriors |
Mapping[str, AbstractPosterior]
|
Dictionary of posteriors to be |
required |
datasets |
Mapping[str, Dataset]
|
Dictionary of datasets which may be used |
required |
key |
KeyArray
|
JAX PRNG key used for random number generation. This can be |
required |
Returns:
Name | Type | Description |
---|---|---|
SinglePointUtilityFunction |
SinglePointUtilityFunction
|
An appproximate sample from the objective model |
SinglePointUtilityFunction
|
posterior to to be maximised in order to decide which point to query |
|
SinglePointUtilityFunction
|
next. |