# Path: examples/context.py

# 
# Path: examples/datautils.py
# def step(x):
# 	y = x.copy()
# 	y[y < 0.0] = 0.0
# 	y[y > 0.0] = 1.0
# 	return y + 0.05*np.random.randn(x.shape[0], 1)
# 
# def spiral(no_samples, noise=0.0):
# 	def genSpiral(N, delta):
# 		X = np.zeros((N, 2))
# 		for i in range(N):
# 			r = i * 5.0 / N
# 			t = 1.75 * i / N * 2.0 * np.pi + delta
# 			x = r * np.sin(t) + (2*np.random.rand() - 1) * noise
# 			y = r * np.cos(t) + (2*np.random.rand() - 1) * noise
# 			X[i, :] = np.array([x, y])
# 		return X
# 
# 	N = int(no_samples / 2.0)
# 	pos_x = genSpiral(N, 0)
# 	neg_x = genSpiral(N, np.pi)
# 	x = np.vstack((pos_x, neg_x))
# 	y = np.ones((2*N, 1))
# 	y[N:] = -1
# 	return x, y
# 
# Path: examples/context.py



import numpy as np
import pdb
import matplotlib.pylab as plt
from scipy import special
from .context import aep
from .datautils import step, spiral
from .context import config
        plt.contour(xx, yy, mf.reshape(*xx.shape),
                    [0], colors='k', linewidths=1.8, zorder=100)

    Xtrain = np.loadtxt('./examples/data/banana_X_train.txt', delimiter=',')
    Ytrain = np.loadtxt('./examples/data/banana_Y_train.txt',
                        delimiter=',').reshape(-1, 1)
    Ytrain[np.where(Ytrain == 0)[0]] = -1
    M = 30
    hidden_size = [2]
    model = aep.SDGPR(Xtrain, Ytrain, M, hidden_size, lik='Probit')
    mb_size = int(Xtrain.shape[0] / 4)
    model.optimise(method='adam', alpha=1.0, maxiter=100000,
                   mb_size=mb_size, adam_lr=0.001)
    plot(model)
    plt.show()
    plt.savefig('/tmp/aep_dgpc_banana_stoc.pdf')


def run_step_1D():
    np.random.seed(42)

    def step(x):
        y = x.copy()
        y[y < 0.0] = 0.0
        y[y > 0.0] = 1.0
        return y + 0.02 * np.random.randn(x.shape[0], 1)

    print "create dataset ..."
    N = 100
    X = np.random.rand(N, 1) * 3 - 1.5

# Path: examples/context.py

# 
# Path: examples/datautils.py
# def step(x):
# 	y = x.copy()
# 	y[y < 0.0] = 0.0
# 	y[y > 0.0] = 1.0
# 	return y + 0.05*np.random.randn(x.shape[0], 1)
# 
# def spiral(no_samples, noise=0.0):
# 	def genSpiral(N, delta):
# 		X = np.zeros((N, 2))
# 		for i in range(N):
# 			r = i * 5.0 / N
# 			t = 1.75 * i / N * 2.0 * np.pi + delta
# 			x = r * np.sin(t) + (2*np.random.rand() - 1) * noise
# 			y = r * np.cos(t) + (2*np.random.rand() - 1) * noise
# 			X[i, :] = np.array([x, y])
# 		return X
# 
# 	N = int(no_samples / 2.0)
# 	pos_x = genSpiral(N, 0)
# 	neg_x = genSpiral(N, np.pi)
# 	x = np.vstack((pos_x, neg_x))
# 	y = np.ones((2*N, 1))
# 	y[N:] = -1
# 	return x, y
# 
# Path: examples/context.py



# Path: examples/dgpr_aep_examples.py
import numpy as np
import pdb
import matplotlib.pylab as plt
from scipy import special
from .context import aep
from .datautils import step, spiral
from .context import config

        plt.contour(xx, yy, mf.reshape(*xx.shape),
                    [0], colors='k', linewidths=1.8, zorder=100)

    Xtrain = np.loadtxt('./examples/data/banana_X_train.txt', delimiter=',')
    Ytrain = np.loadtxt('./examples/data/banana_Y_train.txt',
                        delimiter=',').reshape(-1, 1)
    Ytrain[np.where(Ytrain == 0)[0]] = -1
    M = 30
    hidden_size = [2]
    model = aep.SDGPR(Xtrain, Ytrain, M, hidden_size, lik='Probit')
    mb_size = int(Xtrain.shape[0] / 4)
    model.optimise(method='adam', alpha=1.0, maxiter=100000,
                   mb_size=mb_size, adam_lr=0.001)
    plot(model)
    plt.show()
    plt.savefig('/tmp/aep_dgpc_banana_stoc.pdf')


def run_step_1D():
    np.random.seed(42)

    def step(x):
        y = x.copy()
        y[y < 0.0] = 0.0
        y[y > 0.0] = 1.0
        return y + 0.02 * np.random.randn(x.shape[0], 1)

    print "create dataset ..."
    N = 100
    X = np.random.rand(N, 1) * 3 - 1.5

    Y = step(X) - 0.5