(self, X_test, **kwargs)
return m, v
r"""
        Returns the predictive mean and variance of the objective function
        at X average over all hyperparameter samples.
        The mean is computed by:
        :math \mu(x) = \frac{1}{M}\sum_{i=1}^{M}\mu_m(x)
        And the variance by:
        :math \sigma^2(x) = (\frac{1}{M}\sum_{i=1}^{M}(\sigma^2_m(x) + \mu_m(x)^2) - \mu^2

        Parameters
        ----------
        X_test: np.ndarray (N, D)
            Input test points

        Returns
        ----------
        np.array(N,)
            predictive mean
        np.array(N,)
            predictive variance
r"""
        Returns the predictive mean and variance of the objective function
        at X average over all hyperparameter samples.
        The mean is computed by:
        :math \mu(x) = \frac{1}{M}\sum_{i=1}^{M}\mu_m(x)
        And the variance by:
        :math \sigma^2(x) = (\frac{1}{M}\sum_{i=1}^{M}(\sigma^2_m(x) + \mu_m(x)^2) - \mu^2
r Returns the predictive mean and variance of the objective function at X average over all hyperparameter samples . The mean is computed by : : math \ mu ( x ) = \ frac { 1 } { M } \ sum_ { i = 1 } ^ { M } \ mu_m ( x ) And the variance by : : math \ sigma^2 ( x ) = ( \ frac { 1 } { M } \ sum_ { i = 1 } ^ { M } ( \ sigma^2_m ( x ) + \ mu_m ( x ) ^2 ) - \ mu^2
def predict(self, X_test, **kwargs):
        r"""
        Returns the predictive mean and variance of the objective function
        at X average over all hyperparameter samples.
        The mean is computed by:
        :math \mu(x) = \frac{1}{M}\sum_{i=1}^{M}\mu_m(x)
        And the variance by:
        :math \sigma^2(x) = (\frac{1}{M}\sum_{i=1}^{M}(\sigma^2_m(x) + \mu_m(x)^2) - \mu^2

        Parameters
        ----------
        X_test: np.ndarray (N, D)
            Input test points

        Returns
        ----------
        np.array(N,)
            predictive mean
        np.array(N,)
            predictive variance

        """
        if not self.is_trained:
            raise Exception('Model has to be trained first!')

        mu = np.zeros([len(self.models), X_test.shape[0]])
        var = np.zeros([len(self.models), X_test.shape[0]])
        for i, model in enumerate(self.models):
            mu[i], var[i] = model.predict(X_test)

        m = mu.mean(axis=0)

        # See the Algorithm Runtime Prediction paper by Hutter et al.
        # for the derivation of the total variance
        v = np.var(mu, axis=0) + np.mean(var, axis=0)

        # Clip negative variances and set them to the smallest
        # positive float value
        if v.shape[0] == 1:
            v = np.clip(v, np.finfo(v.dtype).eps, np.inf)
        else:
            v = np.clip(v, np.finfo(v.dtype).eps, np.inf)
            v[np.where((v < np.finfo(v.dtype).eps) & (v > -np.finfo(v.dtype).eps))] = 0

        return m, v
def predict ( self , X_test , * * kwargs ) : if not self . is_trained : raise Exception ( 'Model has to be trained first!' ) mu = np . zeros ( [ len ( self . models ) , X_test . shape [ 0 ] ] ) var = np . zeros ( [ len ( self . models ) , X_test . shape [ 0 ] ] ) for i , model in enumerate ( self . models ) : mu [ i ] , var [ i ] = model . predict ( X_test ) m = mu . mean ( axis = 0 ) # See the Algorithm Runtime Prediction paper by Hutter et al. # for the derivation of the total variance v = np . var ( mu , axis = 0 ) + np . mean ( var , axis = 0 ) # Clip negative variances and set them to the smallest # positive float value if v . shape [ 0 ] == 1 : v = np . clip ( v , np . finfo ( v . dtype ) . eps , np . inf ) else : v = np . clip ( v , np . finfo ( v . dtype ) . eps , np . inf ) v [ np . where ( ( v < np . finfo ( v . dtype ) . eps ) & ( v > - np . finfo ( v . dtype ) . eps ) ) ] = 0 return m , v