-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
[MRG+1] Fix precomputation of Gram matrix in Lars #5359
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
# As we use cross-validation, the Gram matrix is not precomputed here | ||
Gram = self.precompute | ||
if hasattr(Gram, '__array__'): | ||
warnings.warn("Parameter 'precompute' cannot be an array in " |
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.
I would say raise an error instead of a warning but it depends on how much we want to nurse the user.
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.
I was thinking about avoiding an error when a user changes Lars(precompute=G).fit(X, y)
into LarsCV(precompute=G).fit(X, y)
. But it is kind of nursing.
0d8ed92
to
e059923
Compare
9d58692
to
ed10cf1
Compare
LGTM @TomDLT can you update what's new to document the bug fix? |
done |
+1 for MRG when CIs are happy thx @TomDLT |
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.
To me it would make more sense to explicitely feed the gram matrix in the .fit
but I reckon this has little usage anyway. LGTM
return Gram | ||
def _get_gram(self, precompute, X, y): | ||
if (not hasattr(precompute, '__array__')) and ( | ||
(precompute is True) or |
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.
Can be simplified ?
CIs are happy here |
@TomDLT you need to rebase |
|
@TomDLT please fix conflicts here and then let's merge. |
f7ff310
to
71f14cd
Compare
The AppVeyor failures are on master #9111 |
thanks @TomDLT |
This is a fix for the bug reported in #1856.
The parameter
precompute
(in RandomizedLasso, Lars, LarsLasso, LarsCV and LarsLassoCV) were not consistent and some values proposed in the docstrings (False, array) could raise errors.This PR includes the following steps:
lars_path
, to allowGram=True
andGram=False
._get_gram
method, to handleprecompute
in the same way in every class.precompute
, in LarsCV and LarsLassoCV.test_randomized_l1.py
is also updated to be shorter (from 1.582s to 0.817s).test_least_angle.py
goes from 1.305s to 1.465s.