What is the usage of condition_on_observations? #2025
-
Hi everyone, According to my understanding after reading the comment in the library and the code, the condition_on_observation function is used to update the model for the new observation.
I would be extremely thankful for any help that can be offered. I tried doing a small experiment to check it. Why are the results different in CASE 1 and CASE 2? In CASE 1: I initially train the GP on a set of data points [0.02, 0.1, 0.15, 0.25, 0.3, 0.35, 0.4, 0.5]. init_x = torch.tensor([0.02, 0.1, 0.15, 0.25, 0.3, 0.35, 0.4, 0.5], dtype=torch.double).unsqueeze(-1) bounds = torch.tensor([[-2.], [10.]]) #bounds for 2D: torch.tensor([[0., 1.], [10.,2.]]) from botorch.models import SingleTaskGP single_model = SingleTaskGP(init_x, init_y) from botorch import fit_gpytorch_model with torch.no_grad():
########################################################################################### In CASE 2: I initially train the GP on a set of data points [0.02, 0.1, 0.15, 0.25, 0.3, 0.35]. init_x = torch.tensor([0.02, 0.1, 0.15, 0.25, 0.3, 0.35], dtype=torch.double).unsqueeze(-1) bounds = torch.tensor([[-2.], [10.]]) #bounds for 2D: torch.tensor([[0., 1.], [10.,2.]]) from botorch.models import SingleTaskGP single_model = SingleTaskGP(init_x, init_y) single_model.parameters from botorch import fit_gpytorch_model with torch.no_grad():
extra_x = torch.tensor([0.4, 0.5], dtype=torch.double).unsqueeze(-1) model_conditioned = single_model.condition_on_observations(extra_x, extra_y) with torch.no_grad():
mll_conditioned = ExactMarginalLogLikelihood(model_conditioned.likelihood, model_conditioned) with torch.no_grad():
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Sam4896
This is what we typically do. If you check the tutorials on the website, all of them will be doing this rather than using
There's the |
Beta Was this translation helpful? Give feedback.
Hi @Sam4896
condition_on_observations
is primarily used when fantasizing from the model, e.g., when using a knowledge gradient type acquisition function.This is what we typically do. If you check the tutorials on the website, all of them will be doing this rather than using
condition_on_observations
.There's the
fantasize
usage mentioned above. Othe…