class_docstr: Compare test fits of models Marginal and MarginalApprox.
class_docstr_tok: ["Compare","test","fits","of","models","Marginal","and","MarginalApprox","."]
code: def setup_method(self):
      self.sigma = 0.1
      self.x = np.linspace(-5, 5, 30)
      self.y = np.random.normal(0.25 * self.x, self.sigma)
      with pm.Model() as model:
          cov_func = pm.gp.cov.Linear(1, c=0.0)
          c = pm.Normal(
              "c", mu=20.0, sigma=100.0
          )  # far from true value
          mean_func = pm.gp.mean.Constant(c)
          self.gp = pm.gp.Marginal(
              mean_func=mean_func, cov_func=cov_func
          )
          sigma = pm.HalfNormal("sigma", sigma=100)
          self.gp.marginal_likelihood(
              "lik", self.x[:, None], self.y, sigma
          )
          self.map_full = pm.find_MAP(
              method="bfgs"
          )  # bfgs seems to work much better than lbfgsb
  
      self.x_new = np.linspace(-6, 6, 20)
  
      # Include additive Gaussian noise, return diagonal of predicted covariance matrix
      with model:
          self.pred_mu, self.pred_var = self.gp.predict(
              self.x_new[:, None],
              point=self.map_full,
              pred_noise=True,
              diag=True,
          )
  
      # Dont include additive Gaussian noise, return full predicted covariance matrix
      with model:
          self.pred_mu, self.pred_covar = self.gp.predict(
              self.x_new[:, None],
              point=self.map_full,
              pred_noise=False,
              diag=False,
          )
  
imports: from functools import reduce
  from operator import add
  import numpy
  import numpy.testing
  import pytest
  import pymc
  from pymc.math import cartesian
label_desc: Use image node_id 1 for calling the TestMarginalVsMarginalApprox obj's underlying member method code with example usage: obj.setup_method() without return types