UPDATE Getting close. Now I'm running f2py
on the .pyf
file that should generate the _glmnet
module.
I build the package python-glmnet packet with the following command.
python setup.py config_fc --fcompiler=gnu95
--f77flags='-fdefault-real-8'
--f90flags='-fdefault-real-8' build
But when I import the module I get this error:
File "/Users/rose/221/tagger/tagger/glmnet/glmnet.py", line 2, in import _glmnet ImportError: No module named _glmnet
How can I import that module?
The glmnet directory also contains a glmnet.pyf
file that begins with the following:
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module _glmnet ! in
interface ! in :_glmnet
subroutine elnet(ka,parm,no,ni,x,y,w,jd,vp,ne,nx,nlam,flmin,ulam,thr,isd,lmu,a0,ca,ia,nin,rsq,alm,nlp,jerr) ! in :glmnet:glmnet.f
integer optional :: ka=1 ! Use covariance updates over naive by default
real*8 :: parm
integer intent(hide),check(shape(x,0)==no),depend(x) :: no=shape(x,0)
integer intent(hide),check(shape(x,1)==ni),depend(x) :: ni=shape(x,1)
real*8 dimension(no,ni) :: x
real*8 dimension(no),depend(no) :: y
real*8 dimension(no),depend(no) :: w
integer dimension(*) :: jd
real*8 dimension(ni),depend(ni) :: vp
integer optional,depend(x) :: ne=min(shape(x,1), nx)
integer :: nx
integer optional,check((flmin < 1.0 || len(ulam)==nlam)),depend(flmin,ulam) :: nlam=len(ulam)
real*8 :: flmin
real*8 dimension(nlam) :: ulam
real*8 :: thr
integer optional :: isd=1 ! Standardize predictors by default
UPDATE
Where can I find this _glmnet
module? Is it contained in the glmnet.pyf file, as shown below? I tried adding this glment folder to my PYTHONPATH
, but that didn't change anything.
~/221/tagger/tagger/glmnet master ls
__init__.py example_lasso_elastic_net.py glmnet.pyc
__init__.pyc glmnet.f glmnet.pyf
elastic_net.py glmnet.py
~/221/tagger/tagger/glmnet master head -10 glmnet.pyf
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module _glmnet ! in
interface ! in :_glmnet
subroutine elnet(ka,parm,no,ni,x,y,w,jd,vp,ne,nx,nlam,flmin,ulam,thr,isd,lmu,a0,ca,ia,nin,rsq,alm,nlp,jerr) ! in :glmnet:glmnet.f
integer optional :: ka=1 ! Use covariance updates over naive by default
real*8 :: parm
integer intent(hide),check(shape(x,0)==no),depend(x) :: no=shape(x,0)
integer intent(hide),check(shape(x,1)==ni),depend(x) :: ni=shape(x,1)
~/221/tagger/tagger/glmnet master echo $PYTHONPATH
/Users/rose/221/tagger/tagger/glmnet:
~/221/tagger/tagger/glmnet master cd ..
~/221/tagger/tagger master python main.py
Traceback (most recent call last):
File "main.py", line 14, in <module>
from glmnet import glmnet
File "/Users/rose/221/tagger/tagger/glmnet/glmnet.py", line 2, in <module>
import _glmnet
ImportError: No module named _glmnet
As far as I can tell from the source, it's looking for the
_gmlnet
module, which is defined ingmlnet.pyf
.gmlnet.pyf
is not a python module, it's a set of additional instructions for a program calledf2py
, and python will ignore the.pyf
file. You need to compile the.pyf
file along with a fortran file usingf2py
. Use a command like this:Try installing
f2py
and then reinstalling thegmlnet
package.