def fit(self, X, T):
Phi = self.nonlinear_transformation(X)
# MLE for w
self.w = linalg.solve(
Phi.T.dot(Phi) + np.eye(self.n_basis) * self.lamb, Phi.T.dot(T))
# MLE for beta
n_output = 1 if T.ndim < 2 else T.shape[1]
self.beta = n_output / np.mean(linalg.norm(T - Phi.dot(self.w))**2)
return self
评论列表
文章目录