civisanalytics / python-glmnet

A python port of the glmnet package for fitting generalized linear models via penalized maximum likelihood.
Other
262 stars 59 forks source link

class variable CV not available from instance LogitNet?Python version issue??!! #39

Closed seanv507 closed 6 years ago

seanv507 commented 6 years ago
from glmnet import LogitNet
m3 = LogitNet()
xd = trn

%time m3 = m3.fit(X=xd, y=yd_trn)

the fit command gives me an error

Traceback (most recent call last):

  File "<timed exec>", line 1, in <module>

  File "XXX/anaconda3/lib/python3.6/site-packages/glmnet/logistic.py", line 206, in fit
    self.cv = self.CV(n_splits=self.n_splits, shuffle=True,

AttributeError: 'LogitNet' object has no attribute 'CV'

I have 'fixed' it by changing code to LogitNet.CV .... I am not clear on why this should be required.

I am using Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)

stephen-hoover commented 6 years ago

Thanks for the report! Could you provide a minimum working (broken) example? I'm unable to reproduce. The following code works as expected for me:

Python 3.6.3 | packaged by conda-forge | (default, Dec  9 2017, 16:20:51)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from sklearn.datasets import make_classification

In [2]: from glmnet import LogitNet

In [3]: X, y = make_classification(random_state=42)

In [4]: m = LogitNet()

In [5]: %time m = m.fit(X, y)
CPU times: user 85.1 ms, sys: 3.15 ms, total: 88.3 ms
Wall time: 118 ms

In [6]: import glmnet, sklearn

In [7]: print(glmnet.__version__, sklearn.__version__)
2.0.0 0.19.0
kcrum commented 6 years ago

Which version of glmnet do you have installed? Try

import glmnet
print(glmnet.__version__)

I created a conda environment with python 3.6.3 and then pip installed glmnet (version 2.0.0), but I was unable to reproduce your error.

seanv507 commented 6 years ago

Hi I'm sorry I can't reproduce it myself. ( my kernel died) and using stephens test now works as expected

stephen-hoover commented 6 years ago

Thank you for the bug report. Please re-open this ticket if the problem re-occurs!