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

Can't reproduce the example using cvglmnet #69

Open
egayer opened this issue Jun 21, 2024 · 0 comments
Open

Can't reproduce the example using cvglmnet #69

egayer opened this issue Jun 21, 2024 · 0 comments

Comments

@egayer
Copy link

egayer commented Jun 21, 2024

Hi all,

I am having trouble using a code I wrote few years ago. In order to see if my code was the problem, although it was working fine back then, I tried to run an example from the notebook "glmnet_examples.ipynb" (https://github.com/bbalasub1/glmnet_python/blob/master/test/glmnet_examples.ipynb)

here is the example:

x = np.loadtxt(baseDataDir + 'QuickStartExampleX.dat', dtype = np.float64)
y = np.loadtxt(baseDataDir + 'QuickStartExampleY.dat', dtype = np.float64)

cvfit = cvglmnet(x = x.copy(), y = y.copy(), ptype = 'mse', nfolds = 20)

But it gives me the same error as with my old code :

raceback (most recent call last):
  Cell In[73], line 2
    cvfit = cvglmnet(x = x.copy(), y = y.copy(), family = 'binomial', ptype = 'class')

  File ~/anaconda3/envs/py3_forgeGlmnet/lib/python3.10/site-packages/glmnet_python/cvglmnet.py:244 in cvglmnet
    glmfit = glmnet(x = x, y = y, family = family, **options)

  File ~/anaconda3/envs/py3_forgeGlmnet/lib/python3.10/site-packages/glmnet_python/glmnet.py:454 in glmnet
    fit = lognet(x, is_sparse, irs, pcs, y, weights, offset, parm,

  File ~/anaconda3/envs/py3_forgeGlmnet/lib/python3.10/site-packages/glmnet_python/lognet.py:41 in lognet
    y = y[:, [1, 0]]

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

This is weird because y (the response) is a 1D array containing 1 and 0, while x is supposed to the 2D array of observations. It was working fine before. I don't remember the version of glmnet_py at that time though. I currently use glmnet from conda-forge, (glmnet_py 1.0.2 py310h89d7329_5 conda-forge) on Mac OS 10.15.7, python 3.10.14.

Did this happen to anyone else ?

thanks you for your help

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

1 participant