@@ -0,0 +1,2139 @@
+%22%22%22%0ASimple demo which performs Bayesian optimization on a single objective function%0Aand visualizes the search process while doing so.%0A%22%22%22%0A%0Aimport numpy as np%0Aimport matplotlib.pyplot as pl%0A%0Aimport pygp%0Aimport pygp.plotting as pp%0Aimport pybo%0A%0A%0Adef callback(info, x, f, model, bounds, index):%0A    %22%22%22%0A    Plot the current posterior and the index.%0A    %22%22%22%0A    z0 = np.linspace(f.bounds%5B0, 0%5D, f.bounds%5B0, 1%5D, 200)%0A    z1 = np.linspace(f.bounds%5B1, 0%5D, f.bounds%5B1, 1%5D, 200)%0A    Z0, Z1 = np.meshgrid(z0, z1)%0A    Z = np.c_%5BZ0.flat, Z1.flat%5D%0A%0A    F = f.get_f(Z).reshape(Z0.shape)%0A    I = index(Z).reshape(Z0.shape)%0A%0A    X = info%5B'x'%5D%0A    xbest = info%5B-1%5D%5B'xbest'%5D%0A%0A    pl.figure(1)%0A    pl.clf()%0A%0A    pl.subplot(221)%0A    pl.contour(Z0, Z1, F, cmap='coolwarm')%0A    pl.axis(f.bounds.flatten())%0A    pl.gca().set_xticklabels(%5B%5D)%0A    pl.gca().set_yticklabels(%5B%5D)%0A    pl.ylabel('true function')%0A%0A    pl.scatter(x%5B0%5D, x%5B1%5D, marker='o', s=20, color='k', zorder=2)%0A    pl.scatter(X%5B:, 0%5D, X%5B:, 1%5D, facecolors='none', marker='o', s=20, lw=1,%0A               color='k', zorder=2)%0A    pl.scatter(xbest%5B0%5D, xbest%5B1%5D, marker='+', s=50, lw=2, color='k', zorder=2)%0A%0A    pl.subplot(223)%0A    pl.contour(Z0, Z1, I, cmap='coolwarm')%0A    pl.axis(f.bounds.flatten())%0A    pl.gca().set_xticklabels(%5B%5D)%0A    pl.gca().set_yticklabels(%5B%5D)%0A    pl.ylabel('acquisition')%0A%0A    pl.scatter(x%5B0%5D, x%5B1%5D, marker='o', s=20, color='k', zorder=2)%0A%0A    if not all(np.isnan(info%5B'fbest'%5D)):%0A        pl.subplot(122)%0A        pl.semilogy(f.fmax - info%5B'fbest'%5D, lw=2)%0A        pl.axis('tight')%0A        pl.title('regret of recommendation')%0A%0A    pl.draw()%0A    pl.show(block=False)%0A%0A%0Aif __name__ == '__main__':%0A    T = 100%0A    sigma = 1e-6%0A    gp = pygp.BasicGP(sigma, 1.0, 0.1, ndim=2, kernel='matern3')%0A    f = pybo.functions.Branin(sigma)%0A%0A    info = pybo.solve_bayesopt(f,%0A                               f.bounds,%0A                               policy='ucb',%0A                               inference='smc',%0A                               callback=callback)%0A%0A    # this makes sure that if we run the demo from the command line that it%0A    # stops on the final plot before closing.%0A    pl.show()%0A

Add a branin demo.