(self, X, y, do_optimize=True)
Computes the Cholesky decomposition of the covariance of X and
        estimates the GP hyperparameters by optimizing the marginal
        loglikelihood. The prior mean of the GP is set to the empirical
        mean of X.

        Parameters
        ----------
        X: np.ndarray (N, D)
            Input data points. The dimensionality of X is (N, D),
            with N as the number of points and D is the number of features.
        y: np.ndarray (N,)
            The corresponding target values.
        do_optimize: boolean
            If set to true the hyperparameters are optimized otherwise
            the default hyperparameters of the kernel are used.
Computes the Cholesky decomposition of the covariance of X and
        estimates the GP hyperparameters by optimizing the marginal
        loglikelihood. The prior mean of the GP is set to the empirical
        mean of X.
Computes the Cholesky decomposition of the covariance of X and estimates the GP hyperparameters by optimizing the marginal loglikelihood . The prior mean of the GP is set to the empirical mean of X .
def train(self, X, y, do_optimize=True):
        """
        Computes the Cholesky decomposition of the covariance of X and
        estimates the GP hyperparameters by optimizing the marginal
        loglikelihood. The prior mean of the GP is set to the empirical
        mean of X.

        Parameters
        ----------
        X: np.ndarray (N, D)
            Input data points. The dimensionality of X is (N, D),
            with N as the number of points and D is the number of features.
        y: np.ndarray (N,)
            The corresponding target values.
        do_optimize: boolean
            If set to true the hyperparameters are optimized otherwise
            the default hyperparameters of the kernel are used.
        """

        if self.normalize_input:
            # Normalize input to be in [0, 1]
            self.X, self.lower, self.upper = normalization.zero_one_normalization(X, self.lower, self.upper)
        else:
            self.X = X

        if self.normalize_output:
            # Normalize output to have zero mean and unit standard deviation
            self.y, self.y_mean, self.y_std = normalization.zero_mean_unit_var_normalization(y)
            if self.y_std == 0:
                raise ValueError("Cannot normalize output. All targets have the same value")
        else:
            self.y = y

        # Use the empirical mean of the data as mean for the GP
        self.mean = np.mean(self.y, axis=0)

        self.gp = george.GP(self.kernel, mean=self.mean)

        if do_optimize:
            self.hypers = self.optimize()
            self.gp.kernel.set_parameter_vector(self.hypers[:-1])
            self.noise = np.exp(self.hypers[-1])  # sigma^2
        else:
            self.hypers = self.gp.kernel.get_parameter_vector()
            self.hypers = np.append(self.hypers, np.log(self.noise))

        logger.debug("GP Hyperparameters: " + str(self.hypers))

        try:
            self.gp.compute(self.X, yerr=np.sqrt(self.noise))
        except np.linalg.LinAlgError:
            self.noise *= 10
            self.gp.compute(self.X, yerr=np.sqrt(self.noise))

        self.is_trained = True
def train ( self , X , y , do_optimize = True ) : if self . normalize_input : # Normalize input to be in [0, 1] self . X , self . lower , self . upper = normalization . zero_one_normalization ( X , self . lower , self . upper ) else : self . X = X if self . normalize_output : # Normalize output to have zero mean and unit standard deviation self . y , self . y_mean , self . y_std = normalization . zero_mean_unit_var_normalization ( y ) if self . y_std == 0 : raise ValueError ( "Cannot normalize output. All targets have the same value" ) else : self . y = y # Use the empirical mean of the data as mean for the GP self . mean = np . mean ( self . y , axis = 0 ) self . gp = george . GP ( self . kernel , mean = self . mean ) if do_optimize : self . hypers = self . optimize ( ) self . gp . kernel . set_parameter_vector ( self . hypers [ : - 1 ] ) self . noise = np . exp ( self . hypers [ - 1 ] ) # sigma^2 else : self . hypers = self . gp . kernel . get_parameter_vector ( ) self . hypers = np . append ( self . hypers , np . log ( self . noise ) ) logger . debug ( "GP Hyperparameters: " + str ( self . hypers ) ) try : self . gp . compute ( self . X , yerr = np . sqrt ( self . noise ) ) except np . linalg . LinAlgError : self . noise *= 10 self . gp . compute ( self . X , yerr = np . sqrt ( self . noise ) ) self . is_trained = True