-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG+1] Fix Error: 'MultiTaskLasso' object has no attribute 'coef_' when warm_start = True #12361
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
Conversation
Please add a non-regression test |
AppVeyor build seems to be failing for I'm not sure if this was triggered by the test I added. Please let me know if there's anything required on my side to rectify this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fix should be documented in what's new. thx @joaak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
@@ -1795,7 +1795,7 @@ def fit(self, X, y): | |||
X, y, X_offset, y_offset, X_scale = _preprocess_data( | |||
X, y, self.fit_intercept, self.normalize, copy=False) | |||
|
|||
if not self.warm_start or self.coef_ is None: | |||
if not self.warm_start or not hasattr(self, "coef_"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be safe, we might want to handle the case where coef_ is None in case someone relied on this broken implementation...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this condition
if not self.warm_start or not hasattr(self, "coef_"): | |
if not self.warm_start or not hasattr(self, "coef_") or self.coef_ is None: |
should be able to handle that?
got to go from my end |
Yes, that should work. Writing a test is a better way to be sure, though
|
what's new is updated and test is there. @jnothman ok to merge? |
Thanks @joaak |
…m_start = True (scikit-learn#12361)" This reverts commit cab496e.
…m_start = True (scikit-learn#12361)" This reverts commit cab496e.
Reference Issues/PRs
Fixes #12360
What does this implement/fix? Explain your changes.
In the original source code, within the class MultiTaskElaticNet,
if not self.warm_start or self.coef_ is None:
(line 1798) throws an error that the object has no attribute 'coef_' when a MultiTaskElaticNet/MultiTaskLasso object is created withwarm_start = True
.Potential Fix:
Replace
if not self.warm_start or self.coef_ is None:
with
if not self.warm_start or not hasattr(self, "coef_"):
(The replacement is what has been done in line 733 within the ElasticNet class in the original source code).