How to make out-of-sample predictions with pymc model

Hi everyone! I am kind of new to pymc and tech in general so sorry if this question is not very good.

I’ve created a Bayesian Model with a Gaussian Process kernel. I also split my data into a training and a test set. Here is the code where I put the data into the model (under “with pm.model as model:”)
# Link the latent function to the observed data
y_ = gp.prior(“y”, X=X_train, shape=(n,))
# Add the likelihood
pm.Normal(“obs”, mu=y_, sigma=sigma, observed=y_train)

Afterwards, I want to use the bayesian model to make predictions on my test data, but I cannot figure out how to do so with sample_posterior_predictive, or do so such that I can make predictions while having a quantification of uncertainty, with the Bayesian model. Can someone explain how to do this? I tried to use pymc.set_data, but either it is no longer working or I am not implementing it correctly. Thanks in advance!

You may want to look into the conditional method for the GP.

Within your model block, you will want to place a conditional distribution over the value of the GP at the test set. Then, the test values will be sampled along with the parameters of the GP.

You can then use the posterior intervals over the test point GP values as a standard measure of uncertainty.

2 Likes