#NEWLINE# def __init__( self , X , Y , kernel , likelihood , mean_function = None , inference_method = None , name = 'gp' , Y_metadata = None , normalizer = False ) : #NEWLINE# #INDENT# super ( GP , self ) . __init__ ( name ) #NEWLINE# assert ( X . ndim == 2 ) #NEWLINE# if isinstance ( X , ( ObsAr , VariationalPosterior ) ) : #NEWLINE# #INDENT# self . X = X . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . X = ObsAr ( X ) #NEWLINE# #UNINDENT# ( self . num_data , self . input_dim ) = self . X . shape #NEWLINE# assert ( Y . ndim == 2 ) #NEWLINE# logger . info ( 'initializing Y' ) #NEWLINE# if ( normalizer is True ) : #NEWLINE# #INDENT# self . normalizer = MeanNorm ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( normalizer is False ) : #NEWLINE# #INDENT# self . normalizer = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . normalizer = normalizer #NEWLINE# #UNINDENT# #UNINDENT# if ( self . normalizer is not None ) : #NEWLINE# #INDENT# self . normalizer . scale_by ( Y ) #NEWLINE# self . Y_normalized = ObsAr ( self . normalizer . normalize ( Y ) ) #NEWLINE# self . Y = Y #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( Y , np . ndarray ) : #NEWLINE# #INDENT# self . Y = ObsAr ( mean_function ) #NEWLINE# self . Y_normalized = self . Y #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . Y = Y #NEWLINE# #UNINDENT# #UNINDENT# if ( Y . shape [ 0 ] != self . num_data ) : #NEWLINE# #INDENT# warnings . warn ( 'There are more rows in your input data X,                          than in your output data Y, be VERY sure this is what you want' ) #NEWLINE# #UNINDENT# ( _ , self . output_dim ) = self . Y . shape #NEWLINE# assert ( ( Y_metadata is None ) or isinstance ( Y_metadata , dict ) ) #NEWLINE# self . Y_metadata = Y_metadata #NEWLINE# assert isinstance ( kernel , kern . Kern ) #NEWLINE# self . kern = kernel #NEWLINE# assert isinstance ( likelihood , likelihoods . Likelihood ) #NEWLINE# self . likelihood = likelihood #NEWLINE# if ( self . kern . _effective_input_dim != self . X . shape [ 1 ] ) : #NEWLINE# #INDENT# warnings . warn ( 'Your kernel has a different input dimension {} then the given X dimension {}. Be very sure this is what you want and you have not forgotten to set the right input dimenion in your kernel' . format ( self . kern . _effective_input_dim , self . X . shape [ 1 ] ) ) #NEWLINE# #UNINDENT# self . mean_function = mean_function #NEWLINE# if ( mean_function is not None ) : #NEWLINE# #INDENT# assert isinstance ( self . mean_function , Mapping ) #NEWLINE# assert ( mean_function . input_dim == self . input_dim ) #NEWLINE# assert ( mean_function . output_dim == self . output_dim ) #NEWLINE# self . link_parameter ( mean_function ) #NEWLINE# #UNINDENT# logger . info ( 'initializing inference method' ) #NEWLINE# if ( inference_method is None ) : #NEWLINE# #INDENT# if ( isinstance ( likelihood , likelihoods . Gaussian ) or isinstance ( likelihood , likelihoods . MixedNoise ) ) : #NEWLINE# #INDENT# inference_method = exact_gaussian_inference . ExactGaussianInference ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# inference_method = expectation_propagation . EP ( ) #NEWLINE# print ( ( ( 'defaulting to ' + str ( inference_method ) ) + ' for latent function inference' ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . inference_method = inference_method #NEWLINE# logger . info ( 'adding kernel and likelihood as parameters' ) #NEWLINE# self . link_parameter ( self . kern ) #NEWLINE# self . link_parameter ( self . likelihood ) #NEWLINE# self . posterior = None