AttributeError: module 'pymc3' has no attribute 'Simulator'


I am trying to find parameters for the Lotka-Volterra equations using halfnormal prior for each of the parameter.Here’s the code-

with pm.Model() as model:
    a = pm.HalfNormal('a', 1, transform=None)
    b = pm.HalfNormal('b', 0.5, transform=None)
    c = pm.HalfNormal('c', 1.5, transform=None)
    d = pm.HalfNormal('d', 1, transform=None)
    simulator = pm.Simulator('simulator', simulate, observed=observed)
    trace = pm.sample(step=pm.SMC_ABC(n_steps=50, min_epsilon=70, iqr_scale=3), 

AttributeError Traceback (most recent call last)
55 c = pm.HalfNormal(‘c’, 1.5, transform=None)
56 d = pm.HalfNormal(‘d’, 1, transform=None)
—> 57 simulator =pm.Simulator(‘simulator’, simulate, observed=observed)
58 trace = pm.sample(step=pm.SMC_ABC(n_steps=50, min_epsilon=70, iqr_scale=3),
59 draws=50)

AttributeError: module ‘pymc3’ has no attribute ‘Simulator’

Additional details -

PyMC3 Version:3.6
Theano Version:1.0.4
Python Version:3.6
Operating system:16.04, UBUNTU
How did you install PyMC3: pip

Scope of implementing ABC,SMC-ABC in PYMC4 as GSOC 2019 Project

I dont think Simulator is still underdevelopment and not yet in pymc3, @aloctavodia, @agustinaarroyuelo any update on progress?


I was trying to reproduce the results to find parameters for the Lotka-Volterra equations using halfnormal prior for each of the parameter(example_i_wanted_to_reproduce from the project Module for approximate bayesian computation so that i can understand the problems in the current implementation as it’s mentioned that -

On the other hand, this implementation is quite unstable, meaning that some runs can show reasonably good results and others can present problems with covariance matrix computation or low acceptance rates. Which results in poor parameter estimation. In future work, we would like to include tunning of the number of acceptance/rejection steps that each chain goes through. This might deal efectively with the low acceptance rate issues. Besides, this SMC-ABC implementation cannot sample from transformed PyMC3 variables, as it encounters boundary issues.

I would be very happy to contribute ,I have also explored some of the recent progress in ABC such as -using non linear regression models of the parameters on the summary statistics and then adaptively improving estimation using importance sampling(paper_link
,as mentioned in the paper it lowers the computational burden as well which is one of the current problem.


You are right, is not yet in PyMC3, but Agustina and I have plans to continue developing it and adding it to PyMC3 this year.


Due to unavailability of the Simulator in pymc3 ,I am not able to experiment out the model ,but I would be very happy to contribute to it or to some other features if you want to add in the pymc3 module for improving the acceptance ratio /computational efficiency.


@aloctavodia might have an experimental branch that you can test/contribute to


Hi @Adarsh-kumar your help is certainly appreciated. There are some changes in SMC that are now part of PyMC3 but not reflected yet in SMC-ABC, although @agustina may have a newer version I am not aware of. I will talk to Agustina next Monday (she is on vacations now) and we then could coordinate to work on this problem, is this OK with you?


Hi @ Adarsh-kumar. The Lotka-Volterra example should run on the code currently on this branch. It is not merged to pymc3’s master branch yet. I suggest you use this branch for testing.


thanks @agustina, it seems to me your branch has not incorporated the last changes in SMC, right?


That’s right!


@aloctavodia and @agustinaarroyuelo thanks for the response , I will test model on the branch mentioned by @agustinaarroyuelo .
I am ready to contribute from Monday , till then i will test the models on some example datasets /known distributions and get my hands on it.


hi @agustinaarroyuelo ,but I am getting the same error message while running the Lotka-Volterra example on the branch you mentioned.
AttributeError: module ‘pymc3’ has no attribute ‘Simulator’


@aloctavodia @agustinaarroyuelo may you recheck the branch on which I can test the The Lotka-Volterra example and will be able to contribute to the project in the coming time.


The Simulator distribution is here. You can try importing it as
from pymc3.distributions.simulator import Simulator. If that doesn’t work, then the most likely thing is that your python interpreter is looking up a different installation of pymc3 and not the fork that implements Simulator.


Hi, I was just about to write what @lucianopaz said. You can check here that the simulator code is present on the branch I linked you to.

Something you can do is install pymc3 using pip install -e (directory of the pymc3 repository).


@lucianopaz thanks , now I am able to run the Lotka-Volterrra example. I ran the model some times and the results are quite unstable ,like- the first vs third example -

) ,@junpenglao @aloctavodia @agustinaarroyuelo ,It would be great to discuss with you and contribute to the part which can solve these issues.I have also explored some recent papers for better summary statistics calculation which can help us.paper_link


@junpenglao please suggest me the part/feature that I should contribute to.Now i am able to run the experimental pymc3 branch on my system and will be able to do some experiments with that.


I think some notebook as example to start would be great! I would say the best way is to wait for Simulator to check in into PyMC3 - what is your plan on this end @agustinaarroyuelo @aloctavodia?


@junpenglao I am able to run the example notebooks like Lotka-Voltrra as well some other simple examples ,as you told to wait for simulator to check in to PYMC3 ,I am free to contribute/help @agustinaarroyuelo and @aloctavodia to get it done asap so that we can work on some other features .
@agustinaarroyuelo and @aloctavodia , it would be great if you share some updates about your plans .


BTW, I gather that you are using scipy function to generate ODE? You might find this interesting as well: Dynamical model in pymc3