Skip to content
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

lognet crashes when there are less than three values of lambda #16

Open
miguelcorrea opened this issue Jun 28, 2017 · 1 comment
Open

Comments

@miguelcorrea
Copy link
Contributor

I have noticed that sometimes, when glmnet has problems reaching convergence, lognet will crash with the error

File "/usr/lib/python3.6/site-packages/glmnet_py/lognet.py", line 257, in lognet t2 = scipy.log(alm[2]) IndexError: index 2 is out of bounds for axis 0 with size 2

This occurs only when there are less than three values of lambda (this does not require forcing glmnet to do so!). If we look at lognet.py, from line 255, we see that it is trying to retrieve a non-existing value of lambda, and therefore the crash.
if ulam[0] == 0.0: t1 = scipy.log(alm[1]) t2 = scipy.log(alm[2]) alm[0] = scipy.exp(2*t1 - t2)
I have tested the behaviour of the R version of glmnet with the same data, and it simply leaves the first value of the lambda sequence (here alm[0]) as it is, so I suppose that would be acceptable behaviour here.

@pancodia
Copy link

pancodia commented Dec 29, 2017

I encountered the same issue. My case is more extreme that I only have one value in ˋalmˋ

IndexError: index 1 is out of bounds for axis 0 with size 1

So I have two questions:

  1. How does the algorithm choose the values for ˋlambdauˋ ?
  2. Besides the solution mentioned by @miguelcorrea , can I just explicit provide a list of ˋlambdauˋ as a walk around of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants