x1 = np.sort(25 * np.random.rand(1, N) - 25 * np.random.rand(1, N)).reshape(N, 1) x2 = np.sort(25 * np.random.rand(1, N) - 25 * np.random.rand(1, N)).reshape(N, 1) x1s = np.linspace(-24, 24, num=300).reshape(300, 1) x2s = np.linspace(-24, 24, num=300).reshape(300, 1) x = np.hstack((x1, x2)) xs = np.hstack((x1s, x2s)) y = x1**2 - 10 * x1 * (np.sin(x2))**3 + np.random.normal(scale=10, size=(N, 1)) ys = x1s**2 - 10 * x1s * (np.sin(x2s))**3 hyp = np.array([[-3.0], [-4.0], [6.0]]) # Perform standard Guassian Process GPR = GP.GPRegression(x, y, noise=True) GPR.SetKernel('Gaussian') GPR.SetHyp(hyp) start = time.time() GPR.OptimizeHyp(maxnumlinesearch=20, random_starts=4) end = time.time() print('Standard GP done in %.8f seconds' % (end - start)) gp_opttime = end - start GPR.GPR() GPR.Predict(xs) # Perform a Structured Kernel Interpolation regression KISSGP = GP.GPRegression(x, y, noise=True) KISSGP.GenerateGrid([m, m]) KISSGP.Interpolate(scheme='cubic') KISSGP.SetKernel('Gaussian')
''' x1 = np.sort(np.random.normal(scale=10,size=(1,N))).reshape(N,1) x2 = np.sort(np.random.normal(scale=10,size=(1,N))).reshape(N,1) ''' x1 = np.sort(25 * np.random.rand(1, N) - 25 * np.random.rand(1, N)).reshape(N, 1) x2 = np.sort(25 * np.random.rand(1, N) - 25 * np.random.rand(1, N)).reshape(N, 1) x1s = np.linspace(-28, 28, num=300).reshape(300, 1) x2s = np.linspace(-28, 28, num=300).reshape(300, 1) x = np.hstack((x1, x2)) xs = np.hstack((x1s, x2s)) y = x1**2 - 10 * x1 * (np.sin(x2))**3 + np.random.normal(scale=10, size=(N, 1)) Model1 = GP.GPRegression(x, y, noise=True) Model1.GenerateGrid([m, m]) Model1.Interpolate(scheme='cubic') Model1.SetKernel('Gaussian') start = time.time() #Model1.OptimizeHyp(maxnumlinesearch=40,random_starts=1) end = time.time() Model1.KISSGP() Model1.Predict(xs) print('Kiss-GP done in %.8f seconds' % (end - start)) K = Model1.Kuu W = Model1.W D = 2