def fit(self, x_, y, sample_weight=None):
X, y = check_X_y(x_, y, accept_sparse=[], y_numeric=True, multi_output=False)
x, y, X_offset, y_offset, X_scale = self._preprocess_data(
x_, y, fit_intercept=self.fit_intercept, normalize=self.normalize,
copy=self.copy_X, sample_weight=None)
if sample_weight is not None:
x, y = _rescale_data(x, y, sample_weight)
self.iters = 0
self.ind_ = np.ones(x.shape[1], dtype=bool) # initial guess
if self.threshold > 0:
self._reduce(x, y)
else:
self.coef_ = self._regress(x[:, self.ind_], y, self.alpha)
if self.unbias and self.alpha >= 0:
self._unbias(x, y)
self._set_intercept(X_offset, y_offset, X_scale)
return self
评论列表
文章目录