#NEWLINE# def test( self ) : #NEWLINE# #INDENT# X_lower = np . array ( [ 0 ] ) #NEWLINE# X_upper = np . array ( [ 1 ] ) #NEWLINE# X = init_random_uniform ( X_lower , X_upper , 10 ) #NEWLINE# Y = np . sin ( X ) #NEWLINE# kernel = george . kernels . Matern52Kernel ( np . ones ( [ 1 ] ) , ndim = 1 ) #NEWLINE# prior = TophatPrior ( ( - 2 ) , 2 ) #NEWLINE# model = GaussianProcess ( kernel , prior = prior ) #NEWLINE# model . train ( X , Y ) #NEWLINE# x_test = init_random_uniform ( X_lower , X_upper , 3 ) #NEWLINE# ( m , v ) = model . predict ( x_test ) #NEWLINE# assert ( len ( m . shape ) == 2 ) #NEWLINE# assert ( m . shape [ 0 ] == x_test . shape [ 0 ] ) #NEWLINE# assert ( m . shape [ 1 ] == 1 ) #NEWLINE# assert ( len ( v . shape ) == 2 ) #NEWLINE# assert ( v . shape [ 0 ] == x_test . shape [ 0 ] ) #NEWLINE# assert ( v . shape [ 1 ] == x_test . shape [ 0 ] ) #NEWLINE# x_ = np . linspace ( X_lower , X_upper , 10 ) #NEWLINE# x_ = x_ [ : , np . newaxis ] #NEWLINE# funcs = model . sample_functions ( x_ , n_funcs = 2 ) #NEWLINE# assert ( len ( funcs . shape ) == 2 ) #NEWLINE# assert ( funcs . shape [ 0 ] == 2 ) #NEWLINE# assert ( funcs . shape [ 1 ] == x_ . shape [ 0 ] ) #NEWLINE# x_test1 = np . array ( [ np . random . rand ( 1 ) ] ) #NEWLINE# x_test2 = np . random . rand ( 10 ) [ : , np . newaxis ] #NEWLINE# var = model . predict_variance ( x_test1 , x_test2 ) #NEWLINE# assert ( len ( var . shape ) == 2 ) #NEWLINE# assert ( var . shape [ 0 ] == x_test2 . shape [ 0 ] ) #NEWLINE# assert ( var . shape [ 1 ] == 1 ) #NEWLINE# acq_func = EI ( model , X_upper = X_upper , X_lower = X_lower ) #NEWLINE# acq_func . update ( model ) #NEWLINE# acq_func ( x_test ) #NEWLINE# acq_func = PI ( model , X_upper = X_upper , X_lower = X_lower ) #NEWLINE# acq_func . update ( model ) #NEWLINE# acq_func ( x_test ) #NEWLINE# acq_func = LCB ( model , X_upper = X_upper , X_lower = X_lower ) #NEWLINE# acq_func . update ( model ) #NEWLINE# acq_func ( x_test ) #NEWLINE# acq_func = InformationGain ( model , X_upper = X_upper , X_lower = X_lower ) #NEWLINE# acq_func . update ( model ) #NEWLINE# acq_func ( x_test ) #NEWLINE# rec = BestObservation ( model , X_lower , x_test2 ) #NEWLINE# ( inc , inc_val ) = rec . estimate_incumbent ( None ) #NEWLINE# assert ( len ( inc . shape ) == 2 ) #NEWLINE# assert ( inc . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc . shape [ 1 ] == X_upper . shape [ 0 ] ) #NEWLINE# assert ( len ( inc_val . shape ) == 2 ) #NEWLINE# assert ( inc_val . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc_val . shape [ 1 ] == 1 ) #NEWLINE# rec = PosteriorMeanOptimization ( model , X_lower , X_upper ) #NEWLINE# startpoints = init_random_uniform ( X_lower , X_upper , 4 ) #NEWLINE# ( inc , inc_val ) = rec . estimate_incumbent ( startpoints ) #NEWLINE# assert ( len ( inc . shape ) == 2 ) #NEWLINE# assert ( inc . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc . shape [ 1 ] == X_upper . shape [ 0 ] ) #NEWLINE# assert ( len ( inc_val . shape ) == 2 ) #NEWLINE# assert ( inc_val . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc_val . shape [ 1 ] == 1 ) #NEWLINE# rec = PosteriorMeanAndStdOptimization ( model , X_lower , X_upper ) #NEWLINE# startpoints = init_random_uniform ( X_lower , X_upper , 4 ) #NEWLINE# ( inc , inc_val ) = rec . estimate_incumbent ( startpoints ) #NEWLINE# assert ( len ( inc . shape ) == 2 ) #NEWLINE# assert ( inc . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc . shape [ 1 ] == X_upper . shape [ 0 ] ) #NEWLINE# assert ( len ( inc_val . shape ) == 2 ) #NEWLINE# assert ( inc_val . shape [ 0 ] == 1 ) #NEWLINE# assert ( inc_val . shape [ 1 ] == 1 )