Guassian process regression, Example 1: attribute GP nor found

Hi,

In my local python environment am trying to run Gaussian Process Regression — PyMC3 3.1rc3 documentation

However I get an exception: module ‘pymc3.gp’ has no attribute ‘GP’
on this line in the example code:
y_obs = pm.gp.GP*(‘y_obs’, cov_func=f_cov, sigma=s2_n, observed={‘X’:X, ‘Y’:y})

So my question is: what am I doing wrong?

Kind regards,
Herman Meijer

Hi Herman,

That’s a very old example, and out of date. Try instead the Marginal Likelihood GP examples in the current documentation.

The syntax in PyMC 3.11 is:

import numpy as np
import pymc3 as pm

# A one dimensional column vector of inputs.
X = np.linspace(0, 1, 10)[:,None]

with pm.Model() as marginal_gp_model:
    # Specify the covariance function.
    cov_func = pm.gp.cov.ExpQuad(1, ls=0.1)

    # Specify the GP.  The default mean function is `Zero`.
    gp = pm.gp.Marginal(cov_func=cov_func)

    # The scale of the white noise term can be provided,
    sigma = pm.HalfCauchy("sigma", beta=5)
    y_ = gp.marginal_likelihood("y", X=X, y=y, noise=sigma)
3 Likes

Thanks John, this is working now!

1 Like