def predict(self, Xstar, return_std=False):
"""
Returns mean and covariances for the posterior t-Student process.
Parameters
----------
Xstar: np.ndarray, shape=((nsamples, nfeatures))
Testing instances to predict.
return_std: bool
Whether to return the standard deviation of the posterior process. Otherwise,
it returns the whole covariance matrix of the posterior process.
Returns
-------
np.ndarray
Mean of the posterior process for testing instances.
np.ndarray
Covariance of the posterior process for testing instances.
"""
Xstar = np.atleast_2d(Xstar)
self.K21 = self.covfunc.K(Xstar, self.X)
self.K22 = self.covfunc.K(Xstar, Xstar)
self.K12 = self.covfunc.K(self.X, Xstar)
self.K22_tilde = self.K22 - np.dot(np.dot(self.K21, inv(self.K11)), self.K12)
phi2 = np.dot(np.dot(self.K21, inv(self.K11)), self.y)
cov = (self.nu + self.beta1 - 2) / (self.nu + self.n1 - 2) * self.K22_tilde
if return_std:
return phi2, np.diag(cov)
return phi2, cov
评论列表
文章目录