`predictt` in PyMC5?

Hi,

I am migrating my old codebase from PyMC 3.8 to PyMC 5.0.2. The function predictt() from pm.gp.Marginal is no longer working. See below:

with pm.Model() as model:
    # reconstruct Gaussian process regression trained earlier
    ls = gp_maxapos['ls']
    cov = pm.gp.cov.ExpQuad(3, ls=ls)
    gp = pm.gp.Marginal(cov_func=cov)
    gp_pred = gp.marginal_likelihood('gp_pred', X=X_train, y=y_train, sigma=0.01)
    
   # prepare the input tensor
    a = pm.Normal('a', mu=np.mean(ranges['a']), sigma=10.0)
    b = pm.Normal('b', mu=np.mean(ranges['b']), sigma=10.0)
    x = pytensor.shared(df_data['x'].to_numpy())
    X = pt.stack([x, pt.ones_like(x) * a, pt.ones_like(x) * b]).T
    
    # define the output tensor
    mu = pm.Deterministic('mu', gp.predictt(X)[0]) # NO LONGER WORKS!
    f_pred = pm.Normal('f_pred', mu=mu, sigma=df_data['ferr'], observed=df_data['f'])
    
    # sampling
    trace = pm.sample(500, tune=1000, start=dict(), cores=4)

Is there any guide on how I should write it for PyMC5?

My understanding from PyMC3 was that, gp.predict() was used to evaluate the predicted numerical values, whereas gp.predictt() preserved the “tensor-ness” such that sampling could be performed (in this case, samples of a and b).

Thank you.

I believe I have found the solution.

Replace predictt by _predict_at.

1 Like

Hi @Fanurs, yes that’s the same function. The t was for theano, but “tensor” is just as good an interpretation. This function though was meant to be used with MAP inference. If you are using MCMC it’d be better to use gp.conditional (like @fonnesbeck said here Using Gaussian Process model to make inference? - #2 by fonnesbeck)

1 Like