This is an example similar to an example for applying 2d gaussian process by @fonnesbeck. X_.shape=(10970, 2) and Y_.shape = (10970,). After running it I get this error at the line related to posterior predictive:
if samples.shape[0] == 1 and size == 1:
IndexError: tuple index out of range
Wondering if you could help me to resolve it?thanks!
#%%
X_shared=th.shared(X_)
Y_shared=th.shared(Y_)
#%%
nd = 30
z1, z2 = np.meshgrid(np.linspace(X_[:,0].min(), X_[:,0].max(), nd), np.linspace(X_[:,1].min(), X_[:,1].max(), nd))
Z = np.concatenate([z1.reshape(nd*nd, 1), z2.reshape(nd*nd, 1)], 1)
nd = 15
xu1, xu2 = np.meshgrid(np.linspace(X_[:,0].min(), X_[:,0].max(), nd), np.linspace(X_[:,1].min(), X_[:,1].max(), nd))
Xu = np.concatenate([xu1.reshape(nd*nd, 1), xu2.reshape(nd*nd, 1)], 1)
#%%
with pm.Model() as spatial_model:
l = pm.HalfCauchy("l", beta=3, shape=(2,))
sf2 = pm.HalfCauchy("sf2", beta=3)
sn2 = pm.HalfCauchy("sn2", beta=3)
# K = pm.gp.cov.ExpQuad(2, l) * sf2**2
K = pm.gp.cov.Matern32(2,l) * sf2**2
gp_spatial = pm.gp.MarginalSparse(cov_func=K, approx="FITC")
obs = gp_spatial.marginal_likelihood("obs", X=X_shared, Xu=Xu, y=Y_shared, noise=sn2)
trace = pm.sample(cores=1)
#%%
with spatial_model:
f_pred = gp_spatial.conditional('f_pred2', Z)
samples = pm.sample_posterior_predictive([trace], vars=[f_pred], samples=100)
#%%