Skip to content

Conversation

TomDLT
Copy link
Member

@TomDLT TomDLT commented Oct 7, 2015

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:

  • improve lars_path, to allow Gram=True and Gram=False.
  • change the _get_gram method, to handle precompute in the same way in every class.
  • add a warning when an array is given in precompute, in LarsCV and LarsLassoCV.
  • update the docstring.
  • add some tests. 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.

# 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 "
Copy link
Contributor

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.

Copy link
Member Author

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.

@TomDLT TomDLT added this to the 0.17 milestone Oct 7, 2015
@TomDLT TomDLT changed the title [WIP] Fix precomputation of Gram matrix in Lars [MRG] Fix precomputation of Gram matrix in Lars Oct 7, 2015
@TomDLT TomDLT force-pushed the lars branch 2 times, most recently from 0d8ed92 to e059923 Compare October 9, 2015 14:22
@TomDLT TomDLT force-pushed the lars branch 2 times, most recently from 9d58692 to ed10cf1 Compare October 22, 2015 14:52
@TomDLT TomDLT removed this from the 0.17 milestone Dec 5, 2015
@agramfort
Copy link
Member

LGTM

@TomDLT can you update what's new to document the bug fix?

@TomDLT
Copy link
Member Author

TomDLT commented Jun 6, 2017

done

@agramfort
Copy link
Member

+1 for MRG when CIs are happy

thx @TomDLT

Copy link
Contributor

@arthurmensch arthurmensch left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified ?

@agramfort agramfort changed the title [MRG] Fix precomputation of Gram matrix in Lars [MRG+1] Fix precomputation of Gram matrix in Lars Jun 7, 2017
@agramfort
Copy link
Member

CIs are happy here

@agramfort
Copy link
Member

@TomDLT you need to rebase

@TomDLT
Copy link
Member Author

TomDLT commented Jun 9, 2017

All checks have passed

@agramfort
Copy link
Member

@TomDLT please fix conflicts here and then let's merge.

@TomDLT TomDLT force-pushed the lars branch 2 times, most recently from f7ff310 to 71f14cd Compare June 12, 2017 13:59
@TomDLT
Copy link
Member Author

TomDLT commented Jun 13, 2017

The AppVeyor failures are on master #9111

@agramfort agramfort merged commit bb1299b into scikit-learn:master Jun 13, 2017
@agramfort
Copy link
Member

thanks @TomDLT

Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
@TomDLT TomDLT deleted the lars branch June 15, 2018 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants