<s> """<STR_LIT>""" <EOL> try : <EOL> from matplotlib import pyplot as pb <EOL> except : <EOL> pass <EOL> import numpy as np <EOL> import GPy <EOL> def olympic_marathon_men ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . olympic_marathon_men ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] ) <EOL> m . kern . lengthscale = <NUM_LIT> <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , max_iters = <NUM_LIT:200> ) <EOL> if plot : <EOL> m . plot ( plot_limits = ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> return m <EOL> def coregionalization_toy ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> X1 = np . random . rand ( <NUM_LIT:50> , <NUM_LIT:1> ) * <NUM_LIT:8> <EOL> X2 = np . random . rand ( <NUM_LIT:30> , <NUM_LIT:1> ) * <NUM_LIT:5> <EOL> Y1 = np . sin ( X1 ) + np . random . randn ( * X1 . shape ) * <NUM_LIT> <EOL> Y2 = np . sin ( X2 ) + np . random . randn ( * X2 . shape ) * <NUM_LIT> + <NUM_LIT> <EOL> m = GPy . models . GPCoregionalizedRegression ( X_list = [ X1 , X2 ] , Y_list = [ Y1 , Y2 ] ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , max_iters = <NUM_LIT:100> ) <EOL> if plot : <EOL> slices = GPy . util . multioutput . get_slices ( [ X1 , X2 ] ) <EOL> m . plot ( fixed_inputs = [ ( <NUM_LIT:1> , <NUM_LIT:0> ) ] , which_data_rows = slices [ <NUM_LIT:0> ] , Y_metadata = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> m . plot ( fixed_inputs = [ ( <NUM_LIT:1> , <NUM_LIT:1> ) ] , which_data_rows = slices [ <NUM_LIT:1> ] , Y_metadata = { '<STR_LIT>' : <NUM_LIT:1> } , ax = pb . gca ( ) ) <EOL> return m <EOL> def coregionalization_sparse ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> X1 = np . random . rand ( <NUM_LIT:50> , <NUM_LIT:1> ) * <NUM_LIT:8> <EOL> X2 = np . random . rand ( <NUM_LIT:30> , <NUM_LIT:1> ) * <NUM_LIT:5> <EOL> Y1 = np . sin ( X1 ) + np . random . randn ( * X1 . shape ) * <NUM_LIT> <EOL> Y2 = np . sin ( X2 ) + np . random . randn ( * X2 . shape ) * <NUM_LIT> + <NUM_LIT> <EOL> m = GPy . models . SparseGPCoregionalizedRegression ( X_list = [ X1 , X2 ] , Y_list = [ Y1 , Y2 ] ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , max_iters = <NUM_LIT:100> ) <EOL> if plot : <EOL> slices = GPy . util . multioutput . get_slices ( [ X1 , X2 ] ) <EOL> m . plot ( fixed_inputs = [ ( <NUM_LIT:1> , <NUM_LIT:0> ) ] , which_data_rows = slices [ <NUM_LIT:0> ] , Y_metadata = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> m . plot ( fixed_inputs = [ ( <NUM_LIT:1> , <NUM_LIT:1> ) ] , which_data_rows = slices [ <NUM_LIT:1> ] , Y_metadata = { '<STR_LIT>' : <NUM_LIT:1> } , ax = pb . gca ( ) ) <EOL> pb . ylim ( - <NUM_LIT:3> , ) <EOL> return m <EOL> def epomeo_gpx ( max_iters = <NUM_LIT:200> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . epomeo_gpx ( ) <EOL> num_data_list = [ ] <EOL> for Xpart in data [ '<STR_LIT:X>' ] : <EOL> num_data_list . append ( Xpart . shape [ <NUM_LIT:0> ] ) <EOL> num_data_array = np . array ( num_data_list ) <EOL> num_data = num_data_array . sum ( ) <EOL> Y = np . zeros ( ( num_data , <NUM_LIT:2> ) ) <EOL> t = np . zeros ( ( num_data , <NUM_LIT:2> ) ) <EOL> start = <NUM_LIT:0> <EOL> for Xpart , index in zip ( data [ '<STR_LIT:X>' ] , range ( len ( data [ '<STR_LIT:X>' ] ) ) ) : <EOL> end = start + Xpart . shape [ <NUM_LIT:0> ] <EOL> t [ start : end , : ] = np . hstack ( ( Xpart [ : , <NUM_LIT:0> : <NUM_LIT:1> ] , <EOL> index * np . ones ( ( Xpart . shape [ <NUM_LIT:0> ] , <NUM_LIT:1> ) ) ) ) <EOL> Y [ start : end , : ] = Xpart [ : , <NUM_LIT:1> : <NUM_LIT:3> ] <EOL> num_inducing = <NUM_LIT:200> <EOL> Z = np . hstack ( ( np . linspace ( t [ : , <NUM_LIT:0> ] . min ( ) , t [ : , <NUM_LIT:0> ] . max ( ) , num_inducing ) [ : , None ] , <EOL> np . random . randint ( <NUM_LIT:0> , <NUM_LIT:4> , num_inducing ) [ : , None ] ) ) <EOL> k1 = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> k2 = GPy . kern . Coregionalize ( output_dim = <NUM_LIT:5> , rank = <NUM_LIT:5> ) <EOL> k = k1 ** k2 <EOL> m = GPy . models . SparseGPRegression ( t , Y , kernel = k , Z = Z , normalize_Y = True ) <EOL> m . constrain_fixed ( '<STR_LIT>' , <NUM_LIT:1.> ) <EOL> m . inducing_inputs . constrain_fixed ( ) <EOL> m . Gaussian_noise . variance . constrain_bounded ( <NUM_LIT> , <NUM_LIT> ) <EOL> m . optimize ( max_iters = max_iters , messages = True ) <EOL> return m <EOL> def multiple_optima ( gene_number = <NUM_LIT> , resolution = <NUM_LIT> , model_restarts = <NUM_LIT:10> , seed = <NUM_LIT> , max_iters = <NUM_LIT> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> length_scales = np . linspace ( <NUM_LIT:0.1> , <NUM_LIT> , resolution ) <EOL> log_SNRs = np . linspace ( - <NUM_LIT> , <NUM_LIT> , resolution ) <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . della_gatta_TRP63_gene_expression ( data_set = '<STR_LIT>' , gene_number = gene_number ) <EOL> data [ '<STR_LIT:Y>' ] = data [ '<STR_LIT:Y>' ] - np . mean ( data [ '<STR_LIT:Y>' ] ) <EOL> lls = GPy . examples . regression . _contour_data ( data , length_scales , log_SNRs , GPy . kern . RBF ) <EOL> if plot : <EOL> pb . contour ( length_scales , log_SNRs , np . exp ( lls ) , <NUM_LIT:20> , cmap = pb . cm . jet ) <EOL> ax = pb . gca ( ) <EOL> pb . xlabel ( '<STR_LIT>' ) <EOL> pb . ylabel ( '<STR_LIT>' ) <EOL> xlim = ax . get_xlim ( ) <EOL> ylim = ax . get_ylim ( ) <EOL> models = [ ] <EOL> optim_point_x = np . empty ( <NUM_LIT:2> ) <EOL> optim_point_y = np . empty ( <NUM_LIT:2> ) <EOL> np . random . seed ( seed = seed ) <EOL> for i in range ( <NUM_LIT:0> , model_restarts ) : <EOL> kern = GPy . kern . RBF ( <NUM_LIT:1> , variance = np . random . uniform ( <NUM_LIT> , <NUM_LIT:1> ) , lengthscale = np . random . uniform ( <NUM_LIT:5> , <NUM_LIT:50> ) ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] , kernel = kern ) <EOL> m . likelihood . variance = np . random . uniform ( <NUM_LIT> , <NUM_LIT:1> ) <EOL> optim_point_x [ <NUM_LIT:0> ] = m . rbf . lengthscale <EOL> optim_point_y [ <NUM_LIT:0> ] = np . log10 ( m . rbf . variance ) - np . log10 ( m . likelihood . variance ) ; <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , xtol = <NUM_LIT> , ftol = <NUM_LIT> , max_iters = max_iters ) <EOL> optim_point_x [ <NUM_LIT:1> ] = m . rbf . lengthscale <EOL> optim_point_y [ <NUM_LIT:1> ] = np . log10 ( m . rbf . variance ) - np . log10 ( m . likelihood . variance ) ; <EOL> if plot : <EOL> pb . arrow ( optim_point_x [ <NUM_LIT:0> ] , optim_point_y [ <NUM_LIT:0> ] , optim_point_x [ <NUM_LIT:1> ] - optim_point_x [ <NUM_LIT:0> ] , optim_point_y [ <NUM_LIT:1> ] - optim_point_y [ <NUM_LIT:0> ] , label = str ( i ) , head_length = <NUM_LIT:1> , head_width = <NUM_LIT:0.5> , fc = '<STR_LIT:k>' , ec = '<STR_LIT:k>' ) <EOL> models . append ( m ) <EOL> if plot : <EOL> ax . set_xlim ( xlim ) <EOL> ax . set_ylim ( ylim ) <EOL> return m <EOL> def _contour_data ( data , length_scales , log_SNRs , kernel_call = GPy . kern . RBF ) : <EOL> """<STR_LIT>""" <EOL> lls = [ ] <EOL> total_var = np . var ( data [ '<STR_LIT:Y>' ] ) <EOL> kernel = kernel_call ( <NUM_LIT:1> , variance = <NUM_LIT:1.> , lengthscale = <NUM_LIT:1.> ) <EOL> model = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] , kernel = kernel ) <EOL> for log_SNR in log_SNRs : <EOL> SNR = <NUM_LIT> ** log_SNR <EOL> noise_var = total_var / ( <NUM_LIT:1.> + SNR ) <EOL> signal_var = total_var - noise_var <EOL> model . kern [ '<STR_LIT>' ] = signal_var <EOL> model . likelihood . variance = noise_var <EOL> length_scale_lls = [ ] <EOL> for length_scale in length_scales : <EOL> model [ '<STR_LIT>' ] = length_scale <EOL> length_scale_lls . append ( model . log_likelihood ( ) ) <EOL> lls . append ( length_scale_lls ) <EOL> return np . array ( lls ) <EOL> def olympic_100m_men ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . olympic_100m_men ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] ) <EOL> m . rbf . lengthscale = <NUM_LIT:10> <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , max_iters = <NUM_LIT:200> ) <EOL> if plot : <EOL> m . plot ( plot_limits = ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> return m <EOL> def toy_rbf_1d ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . toy_rbf_1d ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' ) <EOL> if plot : <EOL> m . plot ( ) <EOL> return m <EOL> def toy_rbf_1d_50 ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . toy_rbf_1d_50 ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' ) <EOL> if plot : <EOL> m . plot ( ) <EOL> return m <EOL> def toy_poisson_rbf_1d_laplace ( optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> optimizer = '<STR_LIT>' <EOL> x_len = <NUM_LIT:100> <EOL> X = np . linspace ( <NUM_LIT:0> , <NUM_LIT:10> , x_len ) [ : , None ] <EOL> f_true = np . random . multivariate_normal ( np . zeros ( x_len ) , GPy . kern . RBF ( <NUM_LIT:1> ) . K ( X ) ) <EOL> Y = np . array ( [ np . random . poisson ( np . exp ( f ) ) for f in f_true ] ) [ : , None ] <EOL> kern = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> poisson_lik = GPy . likelihoods . Poisson ( ) <EOL> laplace_inf = GPy . inference . latent_function_inference . Laplace ( ) <EOL> m = GPy . core . GP ( X , Y , kernel = kern , likelihood = poisson_lik , inference_method = laplace_inf ) <EOL> if optimize : <EOL> m . optimize ( optimizer ) <EOL> if plot : <EOL> m . plot ( ) <EOL> pb . plot ( X , np . exp ( f_true ) , '<STR_LIT>' , linewidth = <NUM_LIT:2> ) <EOL> return m <EOL> def toy_ARD ( max_iters = <NUM_LIT:1000> , kernel_type = '<STR_LIT>' , num_samples = <NUM_LIT> , D = <NUM_LIT:4> , optimize = True , plot = True ) : <EOL> X1 = np . sin ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) * <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> X2 = np . cos ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) * <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> X3 = np . exp ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) , <NUM_LIT:0> ) ) <EOL> X4 = np . log ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) , <NUM_LIT:0> ) ) <EOL> X = np . hstack ( ( X1 , X2 , X3 , X4 ) ) <EOL> Y1 = np . asarray ( <NUM_LIT:2> * X [ : , <NUM_LIT:0> ] + <NUM_LIT:3> ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Y2 = np . asarray ( <NUM_LIT:4> * ( X [ : , <NUM_LIT:2> ] - <NUM_LIT> * X [ : , <NUM_LIT:0> ] ) ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Y = np . hstack ( ( Y1 , Y2 ) ) <EOL> Y = np . dot ( Y , np . random . rand ( <NUM_LIT:2> , D ) ) ; <EOL> Y = Y + <NUM_LIT> * np . random . randn ( Y . shape [ <NUM_LIT:0> ] , Y . shape [ <NUM_LIT:1> ] ) <EOL> Y -= Y . mean ( ) <EOL> Y /= Y . std ( ) <EOL> if kernel_type == '<STR_LIT>' : <EOL> kernel = GPy . kern . Linear ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> elif kernel_type == '<STR_LIT>' : <EOL> kernel = GPy . kern . RBF_inv ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> else : <EOL> kernel = GPy . kern . RBF ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> kernel += GPy . kern . White ( X . shape [ <NUM_LIT:1> ] ) + GPy . kern . Bias ( X . shape [ <NUM_LIT:1> ] ) <EOL> m = GPy . models . GPRegression ( X , Y , kernel ) <EOL> if optimize : <EOL> m . optimize ( optimizer = '<STR_LIT>' , max_iters = max_iters ) <EOL> if plot : <EOL> m . kern . plot_ARD ( ) <EOL> return m <EOL> def toy_ARD_sparse ( max_iters = <NUM_LIT:1000> , kernel_type = '<STR_LIT>' , num_samples = <NUM_LIT> , D = <NUM_LIT:4> , optimize = True , plot = True ) : <EOL> X1 = np . sin ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) * <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> X2 = np . cos ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) * <NUM_LIT:10> , <NUM_LIT:0> ) ) <EOL> X3 = np . exp ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) , <NUM_LIT:0> ) ) <EOL> X4 = np . log ( np . sort ( np . random . rand ( num_samples , <NUM_LIT:1> ) , <NUM_LIT:0> ) ) <EOL> X = np . hstack ( ( X1 , X2 , X3 , X4 ) ) <EOL> Y1 = np . asarray ( <NUM_LIT:2> * X [ : , <NUM_LIT:0> ] + <NUM_LIT:3> ) [ : , None ] <EOL> Y2 = np . asarray ( <NUM_LIT:4> * ( X [ : , <NUM_LIT:2> ] - <NUM_LIT> * X [ : , <NUM_LIT:0> ] ) ) [ : , None ] <EOL> Y = np . hstack ( ( Y1 , Y2 ) ) <EOL> Y = np . dot ( Y , np . random . rand ( <NUM_LIT:2> , D ) ) ; <EOL> Y = Y + <NUM_LIT> * np . random . randn ( Y . shape [ <NUM_LIT:0> ] , Y . shape [ <NUM_LIT:1> ] ) <EOL> Y -= Y . mean ( ) <EOL> Y /= Y . std ( ) <EOL> if kernel_type == '<STR_LIT>' : <EOL> kernel = GPy . kern . Linear ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> elif kernel_type == '<STR_LIT>' : <EOL> kernel = GPy . kern . RBF_inv ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> else : <EOL> kernel = GPy . kern . RBF ( X . shape [ <NUM_LIT:1> ] , ARD = <NUM_LIT:1> ) <EOL> X_variance = np . ones ( X . shape ) * <NUM_LIT:0.5> <EOL> m = GPy . models . SparseGPRegression ( X , Y , kernel , X_variance = X_variance ) <EOL> if optimize : <EOL> m . optimize ( optimizer = '<STR_LIT>' , max_iters = max_iters ) <EOL> if plot : <EOL> m . kern . plot_ARD ( ) <EOL> return m <EOL> def robot_wireless ( max_iters = <NUM_LIT:100> , kernel = None , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . robot_wireless ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:Y>' ] , data [ '<STR_LIT:X>' ] , kernel = kernel ) <EOL> if optimize : <EOL> m . optimize ( max_iters = max_iters ) <EOL> Xpredict = m . predict ( data [ '<STR_LIT>' ] ) [ <NUM_LIT:0> ] <EOL> if plot : <EOL> pb . plot ( data [ '<STR_LIT>' ] [ : , <NUM_LIT:0> ] , data [ '<STR_LIT>' ] [ : , <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> pb . plot ( Xpredict [ : , <NUM_LIT:0> ] , Xpredict [ : , <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> pb . axis ( '<STR_LIT>' ) <EOL> pb . title ( '<STR_LIT>' ) <EOL> pb . legend ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> sse = ( ( data [ '<STR_LIT>' ] - Xpredict ) ** <NUM_LIT:2> ) . sum ( ) <EOL> print ( ( '<STR_LIT>' + str ( sse ) ) ) <EOL> return m <EOL> def silhouette ( max_iters = <NUM_LIT:100> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> try : import pods <EOL> except ImportError : <EOL> print ( '<STR_LIT>' ) <EOL> return <EOL> data = pods . datasets . silhouette ( ) <EOL> m = GPy . models . GPRegression ( data [ '<STR_LIT:X>' ] , data [ '<STR_LIT:Y>' ] ) <EOL> if optimize : <EOL> m . optimize ( messages = True , max_iters = max_iters ) <EOL> print ( m ) <EOL> return m <EOL> def sparse_GP_regression_1D ( num_samples = <NUM_LIT> , num_inducing = <NUM_LIT:5> , max_iters = <NUM_LIT:100> , optimize = True , plot = True , checkgrad = False ) : <EOL> """<STR_LIT>""" <EOL> X = np . random . uniform ( - <NUM_LIT> , <NUM_LIT> , ( num_samples , <NUM_LIT:1> ) ) <EOL> Y = np . sin ( X ) + np . random . randn ( num_samples , <NUM_LIT:1> ) * <NUM_LIT> <EOL> rbf = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> m = GPy . models . SparseGPRegression ( X , Y , kernel = rbf , num_inducing = num_inducing ) <EOL> if checkgrad : <EOL> m . checkgrad ( ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( ) <EOL> return m <EOL> def sparse_GP_regression_2D ( num_samples = <NUM_LIT> , num_inducing = <NUM_LIT:50> , max_iters = <NUM_LIT:100> , optimize = True , plot = True , nan = False ) : <EOL> """<STR_LIT>""" <EOL> np . random . seed ( <NUM_LIT> ) <EOL> X = np . random . uniform ( - <NUM_LIT> , <NUM_LIT> , ( num_samples , <NUM_LIT:2> ) ) <EOL> Y = np . sin ( X [ : , <NUM_LIT:0> : <NUM_LIT:1> ] ) * np . sin ( X [ : , <NUM_LIT:1> : <NUM_LIT:2> ] ) + np . random . randn ( num_samples , <NUM_LIT:1> ) * <NUM_LIT> <EOL> if nan : <EOL> inan = np . random . binomial ( <NUM_LIT:1> , <NUM_LIT> , size = Y . shape ) <EOL> Y [ inan ] = np . nan <EOL> rbf = GPy . kern . RBF ( <NUM_LIT:2> ) <EOL> m = GPy . models . SparseGPRegression ( X , Y , kernel = rbf , num_inducing = num_inducing ) <EOL> m [ '<STR_LIT>' ] = <NUM_LIT> <EOL> m . checkgrad ( ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , messages = <NUM_LIT:1> , max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( ) <EOL> print ( m ) <EOL> return m <EOL> def uncertain_inputs_sparse_regression ( max_iters = <NUM_LIT:200> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> fig , axes = pb . subplots ( <NUM_LIT:1> , <NUM_LIT:2> , figsize = ( <NUM_LIT:12> , <NUM_LIT:5> ) , sharex = True , sharey = True ) <EOL> S = np . ones ( ( <NUM_LIT:20> , <NUM_LIT:1> ) ) <EOL> X = np . random . uniform ( - <NUM_LIT> , <NUM_LIT> , ( <NUM_LIT:20> , <NUM_LIT:1> ) ) <EOL> Y = np . sin ( X ) + np . random . randn ( <NUM_LIT:20> , <NUM_LIT:1> ) * <NUM_LIT> <EOL> Z = np . random . uniform ( - <NUM_LIT> , <NUM_LIT> , ( <NUM_LIT:7> , <NUM_LIT:1> ) ) <EOL> k = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> m = GPy . models . SparseGPRegression ( X , Y , kernel = k , Z = Z ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , messages = <NUM_LIT:1> , max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( ax = axes [ <NUM_LIT:0> ] ) <EOL> axes [ <NUM_LIT:0> ] . set_title ( '<STR_LIT>' ) <EOL> print ( m ) <EOL> m = GPy . models . SparseGPRegression ( X , Y , kernel = GPy . kern . RBF ( <NUM_LIT:1> ) , Z = Z , X_variance = S ) <EOL> if optimize : <EOL> m . optimize ( '<STR_LIT>' , messages = <NUM_LIT:1> , max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( ax = axes [ <NUM_LIT:1> ] ) <EOL> axes [ <NUM_LIT:1> ] . set_title ( '<STR_LIT>' ) <EOL> fig . canvas . draw ( ) <EOL> print ( m ) <EOL> return m <EOL> def simple_mean_function ( max_iters = <NUM_LIT:100> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> mf = GPy . core . Mapping ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> mf . f = np . sin <EOL> mf . update_gradients = lambda a , b : None <EOL> X = np . linspace ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:50> ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Y = np . sin ( X ) + <NUM_LIT:0.5> * np . cos ( <NUM_LIT:3> * X ) + <NUM_LIT:0.1> * np . random . randn ( * X . shape ) <EOL> k = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> lik = GPy . likelihoods . Gaussian ( ) <EOL> m = GPy . core . GP ( X , Y , kernel = k , likelihood = lik , mean_function = mf ) <EOL> if optimize : <EOL> m . optimize ( max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( plot_limits = ( - <NUM_LIT:10> , <NUM_LIT:15> ) ) <EOL> return m <EOL> def parametric_mean_function ( max_iters = <NUM_LIT:100> , optimize = True , plot = True ) : <EOL> """<STR_LIT>""" <EOL> mf = GPy . core . Mapping ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> mf . f = np . sin <EOL> X = np . linspace ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:50> ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Y = np . sin ( X ) + <NUM_LIT:0.5> * np . cos ( <NUM_LIT:3> * X ) + <NUM_LIT:0.1> * np . random . randn ( * X . shape ) + <NUM_LIT:3> * X <EOL> mf = GPy . mappings . Linear ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> k = GPy . kern . RBF ( <NUM_LIT:1> ) <EOL> lik = GPy . likelihoods . Gaussian ( ) <EOL> m = GPy . core . GP ( X , Y , kernel = k , likelihood = lik , mean_function = mf ) <EOL> if optimize : <EOL> m . optimize ( max_iters = max_iters ) <EOL> if plot : <EOL> m . plot ( ) <EOL> return m </s>
