My current models is as follows;
with pm.Model() as model: l = pm.Gamma("l", alpha=2, beta=1) offset = pm.Gamma("offset", alpha=2, beta=1) nu = pm.HalfCauchy("nu", beta=1) cov = nu ** 2 * pm.gp.cov.Polynomial(X.shape, l, 2, offset) gp = pm.gp.Marginal(cov_func=cov) sigma = pm.HalfCauchy("sigma", beta=1) y_ = gp.marginal_likelihood("y", X=X, y=Y, noise=sigma) map_trace = [pm.find_MAP()]
with model: f_pred = gp.conditional('f_pred', X_New)
with model: pred_samples = pm.sample_posterior_predictive(map_trace, vars=[f_pred], samples=2000) y_pred_custom, uncer = pred_samples['f_pred'].mean(axis=0), pred_samples['f_pred'].std(axis=0)
This works okay.
But, when I try to predict on some new data, say X_New2, it throws the error
Variable name f_pred already exists. from the gp.conditional statement.
I tried using data container (shared variables) for this, but I cannot seem to configure that properly.
Can someone point me in the right direction as to how I can use this model to predict on different data / datasets?