def plot_convergence(Xdata,best_Y, filename = None):
    '''
    Plots to evaluate the convergence of standard Bayesian optimization algorithms
    '''
    n = Xdata.shape[0]
    aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2
    distances = np.sqrt(aux.sum(axis=1))

    ## Distances between consecutive x's
    plt.figure(figsize=(10,5))
    plt.subplot(1, 2, 1)
    plt.plot(list(range(n-1)), distances, '-ro')
    plt.xlabel('Iteration')
    plt.ylabel('d(x[n], x[n-1])')
    plt.title('Distance between consecutive x\'s')
    grid(True)

    # Estimated m(x) at the proposed sampling points
    plt.subplot(1, 2, 2)
    plt.plot(list(range(n)),best_Y,'-o')
    plt.title('Value of the best selected sample')
    plt.xlabel('Iteration')
    plt.ylabel('Best y')
    grid(True)

    if filename!=None:
        savefig(filename)
    else:
        plt.show()
def plot_convergence ( Xdata , best_Y , filename = None ) : n = Xdata . shape [ 0 ] aux = ( Xdata [ 1 : n , : ] - Xdata [ 0 : n - 1 , : ] ) ** 2 distances = np . sqrt ( aux . sum ( axis = 1 ) ) plt . figure ( figsize = ( 10 , 5 ) ) plt . subplot ( 1 , 2 , 1 ) plt . plot ( list ( range ( n - 1 ) ) , distances , '-ro' ) plt . xlabel ( 'Iteration' ) plt . ylabel ( 'd(x[n], x[n-1])' ) plt . title ( 'Distance between consecutive x\'s' ) grid ( True ) plt . subplot ( 1 , 2 , 2 ) plt . plot ( list ( range ( n ) ) , best_Y , '-o' ) plt . title ( 'Value of the best selected sample' ) plt . xlabel ( 'Iteration' ) plt . ylabel ( 'Best y' ) grid ( True ) if filename != None : savefig ( filename ) else : plt . show ( )
Plots to evaluate the convergence of standard Bayesian optimization algorithms