mggg / ecological-inference

Ecological inference, in Python
MIT License
28 stars 11 forks source link

Update PyEI to run on PyMC4 #96

Closed karink520 closed 1 year ago

karink520 commented 2 years ago
tahentx commented 2 years ago

@karink520 will completing the tasks in this workflow address the theano error I'm getting below? If not, I can open a separate issue.

AttributeError                            Traceback (most recent call last)
/var/folders/5g/7r8ydrzj3xs1v0k3w1gbk38m0000gn/T/ipykernel_62796/1726703495.py in <module>
      4 import numpy as np
      5 import fuzzymatcher
----> 6 from pyei.two_by_two import TwoByTwoEI

~/miniconda3/envs/ldf/lib/python3.7/site-packages/pyei/__init__.py in <module>
      1 """A package for rpv and ecological inference"""
      2 __version__ = "0.1.0"
----> 3 from .two_by_two import *
      4 from .goodmans_er import *
      5 from .plot_utils import *

~/miniconda3/envs/ldf/lib/python3.7/site-packages/pyei/two_by_two.py in <module>
      8 
      9 import warnings
---> 10 import pymc3 as pm
     11 import numpy as np
     12 import theano.tensor as tt

~/miniconda3/envs/ldf/lib/python3.7/site-packages/pymc3/__init__.py in <module>
     48 
     49 
---> 50 __set_compiler_flags()
     51 
     52 from pymc3 import gp, ode, sampling

~/miniconda3/envs/ldf/lib/python3.7/site-packages/pymc3/__init__.py in __set_compiler_flags()
     44 def __set_compiler_flags():
     45     # Workarounds for Theano compiler problems on various platforms
---> 46     current = theano.config.gcc__cxxflags
     47     theano.config.gcc__cxxflags = f"{current} -Wno-c++11-narrowing"
     48 

AttributeError: 'TheanoConfigParser' object has no attribute 'gcc__cxxflags'
karink520 commented 2 years ago

Hi @tahentx, thanks for asking. Not exactly. It sounds like this is a theano installation issue, so I don't think it's pyei-specific issue, unfortunately. (I say unfortunately, because if it was, I could potentially be more helpful finding a fix!). Things I'd try would be to either:

1) uninstall theano and then install theano-pymc (as suggested here). Pyei used to be pinned to an earlier version of pymc3, which ran on the older theano, so using that older version of pyei might have left you with the older theano.

or

2) install the pymc4_upgrade branch of pyei with pip install https://github.com/mggg/ecological-inference@pymc4_upgrade, which runs on aesara, which is a fork of theano. The pymc4 version of pyei is also faster. The only reason not to install it would be if you need the Wakefield EI approach -- that approach will give you an error at the moment until you try to use it, until this issue is fully resolved.