hyp.mean = np.array([]) sn = 0.1 hyp.lik = np.array([np.log(sn)]) ##----------------------------------------------------------## ## STANDARD GP (prediction) ## ##----------------------------------------------------------## xs = np.arange(2004+1./24.,2024-1./24.,1./12.) # TEST POINTS xs = xs.reshape(len(xs),1) vargout = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,xs) ym = vargout[0]; ys2 = vargout[1] m = vargout[2]; s2 = vargout[3] plotter(xs,ym,ys2,x,y)#,[1955, 2030, 310, 420]) ##----------------------------------------------------------## ## STANDARD GP (training) ## ## OPTIMIZE HYPERPARAMETERS ## ##----------------------------------------------------------## ## -> parameter training using (off the shelf) conjugent gradient (CG) optimization (NOTE: SCG is faster) from time import clock t0 = clock() vargout = min_wrapper(hyp,gp,'SCG',inffunc,meanfunc,covfunc,likfunc,x,y,None,None,True) t1 = clock() hyp = vargout[0] vargout = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,xs) ym = vargout[0]; ys2 = vargout[1] m = vargout[2]; s2 = vargout[3]
sn = 0.1 hyp.lik = np.array([np.log(sn)]) ##----------------------------------------------------------## ## STANDARD GP (prediction) ## ##----------------------------------------------------------## xs = np.arange(2004 + 1. / 24., 2024 - 1. / 24., 1. / 12.) # TEST POINTS xs = xs.reshape(len(xs), 1) vargout = gp(hyp, inffunc, meanfunc, covfunc, likfunc, x, y, xs) ym = vargout[0] ys2 = vargout[1] m = vargout[2] s2 = vargout[3] plotter(xs, ym, ys2, x, y) #,[1955, 2030, 310, 420]) ##----------------------------------------------------------## ## STANDARD GP (training) ## ## OPTIMIZE HYPERPARAMETERS ## ##----------------------------------------------------------## ## -> parameter training using (off the shelf) conjugent gradient (CG) optimization (NOTE: SCG is faster) from time import clock t0 = clock() vargout = min_wrapper(hyp, gp, 'SCG', inffunc, meanfunc, covfunc, likfunc, x, y, None, None, True) t1 = clock() hyp = vargout[0] vargout = gp(hyp, inffunc, meanfunc, covfunc, likfunc, x, y, xs) ym = vargout[0] ys2 = vargout[1]
##----------------------------------------------------------## ## STANDARD GP (example 1) ## ##----------------------------------------------------------## print '...example 1: prediction...' ## PREDICTION t0 = clock() vargout = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,xstar) t1 = clock() ym = vargout[0]; ys2 = vargout[1]; m = vargout[2]; s2 = vargout[3] print 'Time for prediction =',t1-t0 ## PLOT results if PLOT: plotter(xstar,ym,s2,x,y,[-2, 2, -0.9, 3.9]) ## GET negative log marginal likelihood [nlml, post] = gp(hyp,inffunc,meanfunc,covfunc,likfunc,x,y,None,None,False) print "nlml =", nlml ##----------------------------------------------------------## ## STANDARD GP (example 2) ## ##----------------------------------------------------------## print '...example 2: prediction...' ## USE another covariance function -> for use of composite covariance functions see demoMaunaLoa.py covfunc = [ ['kernels.covSEiso'] ] ### SET (hyper)parameters hyp2 = hyperParameters()
##----------------------------------------------------------## print '...example 1: prediction...' ## PREDICTION t0 = clock() vargout = gp(hyp, inffunc, meanfunc, covfunc, likfunc, x, y, xstar) t1 = clock() ym = vargout[0] ys2 = vargout[1] m = vargout[2] s2 = vargout[3] print 'Time for prediction =', t1 - t0 ## PLOT results if PLOT: plotter(xstar, ym, s2, x, y, [-2, 2, -0.9, 3.9]) ## GET negative log marginal likelihood [nlml, post] = gp(hyp, inffunc, meanfunc, covfunc, likfunc, x, y, None, None, False) print "nlml =", nlml ##----------------------------------------------------------## ## STANDARD GP (example 2) ## ##----------------------------------------------------------## print '...example 2: prediction...' ## USE another covariance function -> for use of composite covariance functions see demoMaunaLoa.py covfunc = [['kernels.covSEiso']] ### SET (hyper)parameters hyp2 = hyperParameters()