Guassian process regression, Example 1: attribute GP nor found


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

However I get an exception: module ‘’ has no attribute ‘GP’
on this line in the example code:
y_obs =*(‘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 =, ls=0.1)

    # Specify the GP.  The default mean function is `Zero`.
    gp =

    # 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)

Thanks John, this is working now!

1 Like