Example #1
0
class Gaussian_Process_Regression:
    '''Performs GPR (used as approximation architecture)'''
    def __init__(self):
        length_scale = 1
        self.kernel = RBF(length_scale) * (1 / sqrt(2 * pi *
                                                    (length_scale**2)))
        self.gp = GaussianProcessRegressor(kernel=self.kernel,
                                           alpha=1e-2,
                                           n_restarts_optimizer=6,
                                           normalize_y=True)

    def fit(self, training_data, target_values):
        '''Returns the prediction function of the GPR'''
        self.gp.fit(training_data, target_values)
        return self

    def predict(self, test_point):
        return self.gp.predict(test_point)

    #TODO: DELETE? (implemented in gpr.py (direct modification of sklearn files))
    def jacobian(self, test_point):
        '''Returns the jacobian of the mean of the predictive distribution wrt to the decisions of the testpoint'''
        return self.gp.jacobian_RBF(test_point)[4:]