-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Ensure coef_ is an ndarray when fitting LassoLars #8160
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
Great, it looks like you've got most of the way to a regression test at #1615. Please add it? |
Tests added. |
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.
LGTM, thanks!
(I've confirmed the test fails in master) |
@@ -689,6 +689,8 @@ def fit(self, X, y, Xy=None): | |||
a[0] for a in (self.alphas_, self.active_, self.coef_path_, | |||
self.coef_)] | |||
self.n_iter_ = self.n_iter_[0] | |||
else: | |||
self.coef_ = np.array(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.
it would be more efficient to preallocate self.coef_ to an empty array rather than first having a list than copying the data to an array
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.
True. Would you like me to add that optimization to this PR?
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.
If you can do it, it will be great :)
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.
+1 if tests are ok.
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.
a changelog entry would be great, otherwise let's merge.
LGTM see why CIs complain but diff looks clean |
@agramfort Error on circleci are not related. We have the same problem on several PR (ex : #8135). |
@perimosocordiae Ci problems seems solved now, can you rebase ? |
Nah. Merging. |
@jnothman Thanks :) |
@perimosocordiae Thanks for your work |
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
This PR fixes #1615, an issue related to fitting a
LassoLars
model with the specific combination offit_path=True
,fit_intercept=False
, and >1 targets.The bug was masked in the
fit_intercept=True
case because of this line,in which the coefficient list is promoted to an ndarray by division with another ndarray.