Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set_params for linear models #4096

Merged
merged 4 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python/cuml/linear_model/elastic_net.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ class ElasticNet(Base,

return self

def set_params(self, **params):
super().set_params(**params)
self._check_alpha(self.alpha)
self._check_l1_ratio(self.l1_ratio)
shuffle = self.selection == 'random'
self.solver_model = CD(fit_intercept=self.fit_intercept,
normalize=self.normalize, alpha=self.alpha,
l1_ratio=self.l1_ratio, shuffle=shuffle,
max_iter=self.max_iter, handle=self.handle,
output_type=self.output_type)
lowener marked this conversation as resolved.
Show resolved Hide resolved
return self

def get_param_names(self):
return super().get_param_names() + [
"alpha",
Expand Down
11 changes: 11 additions & 0 deletions python/cuml/linear_model/lasso.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ class Lasso(Base,
msg = "alpha value has to be positive"
raise ValueError(msg.format(alpha))

def set_params(self, **params):
super().set_params(**params)
self._check_alpha(self.alpha)
shuffle = self.selection == 'random'
self.solver_model = CD(fit_intercept=self.fit_intercept,
normalize=self.normalize, alpha=self.alpha,
l1_ratio=1.0, shuffle=shuffle,
max_iter=self.max_iter, handle=self.handle,
output_type=self.output_type)
return self

@generate_docstring()
def fit(self, X, y, convert_dtype=True) -> "Lasso":
"""
Expand Down
5 changes: 5 additions & 0 deletions python/cuml/linear_model/mbsgd_classifier.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ class MBSGDClassifier(Base,

return preds

def set_params(self, **params):
super().set_params(**params)
self.solver_model.set_params(**params)
return self

def get_param_names(self):
return super().get_param_names() + [
"loss",
Expand Down
5 changes: 5 additions & 0 deletions python/cuml/linear_model/mbsgd_regressor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class MBSGDRegressor(Base,
convert_dtype=convert_dtype)
return preds

def set_params(self, **params):
super().set_params(**params)
self.solver_model.set_params(**params)
return self

def get_param_names(self):
return super().get_param_names() + [
"loss",
Expand Down