def fit(self, X, y):
"""Fit the parameters of the probabilistic process based on the
available training data.
"""
# Store the training data (both the inputs and the targets).
self.X, self.y = X, y
# Compute the covariance matrix of the observed inputs.
K = self.kernel.cov(self.X)
# For a numerically stable algorithm, we use Cholesky decomposition.
self.L = spla.cholesky(K, lower=True)
self.alpha = spla.cho_solve((self.L, True), self.y).ravel()
L_inv = spla.solve_triangular(self.L.T, np.eye(self.L.shape[0]))
self.K_inv = L_inv.dot(L_inv.T)
self.beta = self.y.dot(self.alpha)
评论列表
文章目录