Example #1
0
    Bopt = bo_optimizer.optimize(test_function, n_iter=nb_iter_bo)
    print(Bopt)

    if display_figures:
        # Plot acquisition function
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_acquisition_sphere(ax, acq_fct, xs=bo_optimizer.acquisition.data[0], opt_x=Bopt.x, true_opt_x=true_min,
                                   elev=10, azim=30, n_elems=100)
        ax.set_title('Acquisition function', fontsize=50)
        plt.show()

        # Plot GP
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_gp_sphere(ax, model, xs=bo_optimizer.acquisition.data[0], opt_x=Bopt.x, true_opt_x=true_min,
                          true_opt_y=true_opt_val, max_colors=max_colors, elev=10, azim=30, n_elems=100)
        ax.set_title('GP mean', fontsize=50)
        plt.show()

        # Plot GP projected on planes
        fig = plt.figure(figsize=(20, 10))
        bo_plot_gp_sphere_planar(fig, model, var_fact=2., xs=bo_optimizer.acquisition.data[0],
                                 ys=bo_optimizer.acquisition.data[1], opt_x=Bopt.x, opt_y=test_function(Bopt.x),
                                 true_opt_x=true_min, true_opt_y=true_opt_val, max_colors=max_colors, n_elems=100)
        plt.title('GP mean and variance', fontsize=50)
        plt.show()

    if display_figures:
        # Plot observations on the sphere
        # 3D figure
        fig = plt.figure(figsize=(5, 5))
Example #2
0
                                   opt_x=best_x[-1][None],
                                   true_opt_x=true_min,
                                   elev=10,
                                   azim=30,
                                   n_elems=100)
        ax.set_title('Acquisition function', fontsize=20)
        plt.show()

        # Plot GP
        fig = plt.figure(figsize=(5, 5))
        ax = Axes3D(fig)
        bo_plot_gp_sphere(ax,
                          model,
                          xs=x_eval,
                          opt_x=best_x[-1][None],
                          true_opt_x=true_min,
                          true_opt_y=true_opt_val,
                          max_colors=max_colors,
                          elev=10,
                          azim=30,
                          n_elems=100)
        ax.set_title('GP mean', fontsize=20)
        plt.show()

        # Plot GP projected on planes
        fig = plt.figure(figsize=(10, 5))
        bo_plot_gp_sphere_planar(fig,
                                 model,
                                 var_fact=2.,
                                 xs=x_eval,
                                 ys=y_eval,
                                 opt_x=best_x[-1][None],