bbalasub1 / glmnet_python

GNU General Public License v3.0
199 stars 93 forks source link

Error when using dfmax option under certain conditions #9

Open miguelcorrea opened 7 years ago

miguelcorrea commented 7 years ago

The value of the parameter dfmax is supposed to be passed as a 1x1 scipy.ndarray. Now, if we look at glmnet.py, starting from line 311:

ne = options['dfmax']
if len(ne) == 0:
    ne = nvars + 1
# check nx
nx = options['pmax']
if len(nx) == 0:
    nx = min(ne*2 + 20, nvars)

In the case that ne*2+20 is smaller than nvars, this makes nx an array too. This leads to problems later. For example, line 111 of lognet.py: ca = scipy.zeros([nx, nc, nlam], dtype = scipy.float64) Which in this case gives us the error: TypeError: only integer scalar arrays can be converted to a scalar index