def __init__(self,inf=exact,cov=1.0*se(ell=1.0), mean=zero(),lik=gauss(sn=1.0),X=None,y=None): """ Set up a gp, perform inference if X and y are provided. """ self.inf = inf # inference method self.cov,self.mean,self.lik = cov,mean,lik # covariance,mean,likelihood self.post = None # init posterior approximation if X!=None and y!=None: self.post = self.inference(X,y) # do inference
def test_zero(self,thr=1e-6): """ Test zero mean. """ n,D,X = self.n,self.D,self.X m = mean.zero() self.run_verifications(m,thr) d = np.linalg.norm( m(X) ) self.assertLessEqual(d,thr)
def __init__(self, inf=exact, cov=1.0 * se(ell=1.0), mean=zero(), lik=gauss(sn=1.0), X=None, y=None): """ Set up a gp, perform inference if X and y are provided. """ self.inf = inf # inference method self.cov, self.mean, self.lik = cov, mean, lik # covariance,mean,likelihood self.post = None # init posterior approximation if X != None and y != None: self.post = self.inference(X, y) # do inference
def test_ep(self,thr=1e-4): """ Test expectation propagation approximate inference. """ im = inf.ep cf,mf,lf = 1.1*cov.se(ell=0.8),mean.zero(),lik.erf() self.run_verifications(im,cf,mf,lf,thr) lf = lik.gauss(sn=0.2) self.run_verifications(im,cf,mf,lf,thr) mf = 2.3*mean.one() self.run_verifications(im,cf,mf,lf,thr) cf = 1.3*cov.se(ell=[0.8,0.7,0.3]) self.run_verifications(im,cf,mf,lf,thr) mf = 1.3*mean.linear(a=[0.8,0.7,0.3]) self.run_verifications(im,cf,mf,lf,thr)
def test_exact(self,thr=1e-4): """ Test exact inference. """ im = inf.exact cf,mf,lf = 1.1*cov.se(ell=0.8),mean.zero(),lik.gauss(sn=1e-5) self.run_verifications(im,cf,mf,lf,thr) lf = lik.gauss(sn=0.2) self.run_verifications(im,cf,mf,lf,thr) mf = 2.3*mean.one() self.run_verifications(im,cf,mf,lf,thr) cf = 1.3*cov.se(ell=[0.8,0.7,0.3]) self.run_verifications(im,cf,mf,lf,thr) mf = 1.3*mean.linear(a=[0.8,0.7,0.3]) self.run_verifications(im,cf,mf,lf,thr)