def fit(self, x_, y, sample_weight=None):
n_samples, n_features = x_.shape
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:
# Sample weight can be implemented via a simple rescaling.
x, y = _rescale_data(x, y, sample_weight)
coefs, intercept = fit_with_noise(x, y, self.sigma, self.alpha, self.n)
self.intercept_ = intercept
self.coef_ = coefs
self._set_intercept(X_offset, y_offset, X_scale)
return self
评论列表
文章目录