def _fit(self, X, y):
# Calling the class-specific train method
n, d = X.shape
if n < d:
tmp = np.dot(X, X.T)
if self.mu != 0.0:
tmp += self.mu * n * np.eye(n)
tmp = la.pinv(tmp)
coef_ = np.dot(np.dot(X.T, tmp), y)
else:
tmp = np.dot(X.T, X)
if self.mu != 0.0:
tmp += self.mu * n * np.eye(d)
tmp = la.pinv(tmp)
coef_ = np.dot(tmp, np.dot(X.T, y))
self.coef_ = coef_
评论列表
文章目录