[MRG+1] Ensure coef_ is an ndarray when fitting LassoLars #8160
+15
−5
Conversation
Great, it looks like you've got most of the way to a regression test at #1615. Please add it? |
Tests added. |
LGTM, thanks! |
(I've confirmed the test fails in master) |
sklearn/linear_model/least_angle.py
Outdated
@@ -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_) |
agramfort
Jan 7, 2017
Member
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
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
perimosocordiae
Jan 10, 2017
Author
Contributor
True. Would you like me to add that optimization to this PR?
True. Would you like me to add that optimization to this PR?
tguillemot
Jan 16, 2017
Contributor
If you can do it, it will be great :)
If you can do it, it will be great :)
+1 if tests are ok. |
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 |
sergeyf
added a commit
to sergeyf/scikit-learn
that referenced
this pull request
Feb 28, 2017
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
Closed
Sundrique
added a commit
to Sundrique/scikit-learn
that referenced
this pull request
Jun 14, 2017
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
NelleV
added a commit
to NelleV/scikit-learn
that referenced
this pull request
Aug 11, 2017
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
paulha
added a commit
to paulha/scikit-learn
that referenced
this pull request
Aug 19, 2017
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
maskani-moh
added a commit
to maskani-moh/scikit-learn
that referenced
this pull request
Nov 15, 2017
) * Fix scikit-learngh-1615: ensure self.coef_ is an ndarray
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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.