Giter Club home page Giter Club logo

rajeshrinet / pyross Goto Github PK

View Code? Open in Web Editor NEW
165.0 21.0 57.0 147.3 MB

PyRoss: inference, forecasts, and optimised control of epidemiological models in Python

Home Page: https://pyross.readthedocs.io

License: MIT License

Python 4.79% Shell 0.06% Makefile 0.05% Jupyter Notebook 68.18% Cython 26.93%
covid-19 infectious-disease-models epidemiological-predictions epidemic-simulations coronavirus sars-cov-2 compartment-models epidemiological-models pyross

pyross's Introduction

Imagel

PyRoss: inference, forecasts, and optimised control for epidemiological models in Python Binder CI Notebooks PyPI Python Version Downloads stars forks License

About | Documentation | Examples | Installation | Publications |

About

PyRoss is a numerical library that offers an integrated platform for inference, forecasts and non-pharmaceutical interventions in structured epidemiological compartment models.

Compartment models of arbitrary complexity can be user-defined through Python dictionaries. The most common epidemiological models, and several less common ones, come pre-defined with the library. Models can include stages to allow for non-exponentially distributed compartmental residence times. Currently, pre-defined models include ones with multiple disease states (exposed, asymptomatic, symptomatic, etc) and may be further divided by age, and by objective medical states (hospitalized, in ICU, etc). The compartment framework supports models for disease surveillance and quarantine and a variety of other processes of epidemiological relevance.

Generative processes can be formulated stochastically (as Markov population processes) or deterministically (as systems of differential equations). Population processes are sampled exactly by the Doob-Gillespie algorithm or approximately by the tau-leaping algorithm while differential equations are integrated by both fixed and adaptive time-stepping. A hybrid algorithm transits dynamically between these depending on the magnitude of the compartmental fluctuations.

Bayesian inference on pre-defined or user-defined models is performed using model-adapted Gaussian processes derived from functional limit theorems for Markov population process. Generative models are fitted to data through the surveillance model allowing for possibily unobserved compartments. The MAP estimates of parameters and their standard errors can be obtained rapidly by optimising, obviating the need for expensive Markov chain Monte Carlo. This enables the fast evaluation of the model evidence, through which competing models may be objectively compared and their forecasts combined by Bayesian model averaging. Forecasts of disease progression, then, can be fully Bayesian, convolving uncertainties in data, parameters and models. The sensitivity of these forecasts is estimated through the Fisher information matrix.

Non-pharmaceutical interventions are implemented as modifications of the contact structures of the model. Optimised control of these structures, given cost functions, is possible.

PyRossGeo is a companion library that supports spatially resolved compartment models with explicit commuting networks.

The libraries are named after Sir Ronald Ross, doctor, mathematician and poet. In 1898 he made "the great discovery" in his laboratory in Calcutta "that malaria is conveyed by the bite of a mosquito". He won the Nobel Prize in 1902 and laid the foundations of the mathematical modelling of infectious diseases.

The library was developed as a part of The Rapid Assistance in Modelling the Pandemic (RAMP) taskforce at the University of Cambridge. In alphabetical order, the authors are: Ronojoy Adhikari, Austen Bolitho, Erik Brorson, Fernando Caballero, Michael Cates, Jakub Dolezal, Tim Ekeh, Jules Guioth, Robert Jack, Julian Kappler, Lukas Kikuchi, Hideki Kobayashi, Irene Li, Joseph Peterson, Patrick Pietzonka, Benjamin Remez, Paul Rohrbach, Rajesh Singh, and Günther Turk. PyRoss development was also partially supported by a Microsoft Research Award for "Building an open platform for pandemic modelling".

Please read the PyRoss paper and PyRoss Wiki before you use PyRoss for your research. Open an issue, in preference to emailing us with queries. Join our Slack channel for discussion. Please follow the Contributor Covenant in all PyRoss fora. Thank you!

Installation

You can take PyRoss for a spin without installation: Binder. Please be patient while Binder loads.

From a checkout of PyRoss GitHub repository

This is the recommended way as it downloads a whole suite of examples along with the package.

Install PyRoss and an extended list of dependencies using

>> git clone https://github.com/rajeshrinet/pyross.git
>> cd pyross
>> pip install -r requirements.txt
>> python setup.py install

Install PyRoss and an extended list of dependencies, via Anaconda, in an environment named pyross:

>> git clone https://github.com/rajeshrinet/pyross.git
>> cd pyross
>> make env
>> conda activate pyross
>> make

Via pip

Install the latest PyPI version

>> pip install pyross

Testing

Short test of initialisation and running

>> make test

Long test of all example notebooks. Optionally can specify path and recursion to test a certain subset of notebooks

>> make nbtest -e path=examples/deterministic/

Examples

PyRoss has model-agnostic, formulation-agnostic intuitive interface. Once a model is instantiated, stochastic, deterministic and hybrid simulations can be performed through the same interface. The example below shows how to set up a deterministic SIR simulation with three age-groups.

# SIR with three age-groups (M=3)

import numpy as np
import pyross
import matplotlib.pyplot as plt


model_spec = { "classes" : ["S", "I"],

             "S" : {"infection" : [ ["I","S", "-beta"] ]},  ## the I class passes infection to S class
             "I" : { "linear"    : [ ["I", "-gamma"] ],     ## this is recovery process for I class
                    "infection" : [ ["I", "S", "beta"]]}    
             
              ## the recovered class R is internally determined by number conservation
             }


parameters = {'beta'  : 0.1,
              'gamma' : 0.1, 
              }

M=3;  Ni=1000*np.ones(M);  N=np.sum(Ni) 


# Initial conditions as an array
x0 = np.array([
    980, 980, 980,    # S
    20,   20,  20,    # I
])

# Or initial conditions as a dictionary 
x0 = {'S': [n-20 for n in Ni], 'I':  [20, 20, 20]  }


CM = np.array( [[1,   0.5, 0.1],
               [0.5, 1,   0.5],
               [0.1, 0.5, 1  ]], dtype=float)

def contactMatrix(t):
    return CM


# duration of simulation and data file
Tf = 160;  Nf=Tf+1; 

det_model = pyross.deterministic.Model(model_spec, parameters, M, Ni)

# simulate model 
data = det_model.simulate(x0, contactMatrix, Tf, Nf)


# plot the data and obtain the epidemic curve
S = np.sum(det_model.model_class_data('S', data), axis=1)
I = np.sum(det_model.model_class_data('I', data), axis=1)
R = np.sum(det_model.model_class_data('R', data), axis=1)
t = data['t']

fig = plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')
plt.rcParams.update({'font.size': 22})

plt.fill_between(t, 0, S/N, color="#348ABD", alpha=0.3)
plt.plot(t, S, '-', color="#348ABD", label='$S$', lw=4)

plt.fill_between(t, 0, I/N, color='#A60628', alpha=0.3)
plt.plot(t, I, '-', color='#A60628', label='$I$', lw=4)

plt.fill_between(t, 0, R/N, color="dimgrey", alpha=0.3)
plt.plot(t, R, '-', color="dimgrey", label='$R$', lw=4)

plt.legend(fontsize=26); plt.grid() 
plt.autoscale(enable=True, axis='x', tight=True)
plt.ylabel('Compartment value')
plt.xlabel('Days');

Read more in the examples folders.

Publications

  • Bayesian inference across multiple models suggests a strong increase in lethality of COVID-19 in late 2020 in the UK. Patrick Pietzonka, Erik Brorson, William Bankes, Michael E. Cates, Robert L. Jack, R. Adhikari medRxiv, 2021

  • Efficient Bayesian inference of fully stochastic epidemiological models with applications to COVID-19. Yuting I. Li, Günther Turk, Paul B. Rohrbach, Patrick Pietzonka, Julian Kappler, Rajesh Singh, Jakub Dolezal, Timothy Ekeh, Lukas Kikuchi, Joseph D. Peterson, Hideki Kobayashi, Michael E. Cates, R. Adhikari, Robert L. Jack, arXiv:2010.11783, 2020 | ResearchGate

  • Efficient and flexible methods for time since infection models, Joseph D. Peterson, R. Adhikari, arXiv:2010.10955, 2020

  • Inference, prediction and optimization of non-pharmaceutical interventions using compartment models: the PyRoss library. R. Adhikari, Austen Bolitho, Fernando Caballero, Michael E. Cates, Jakub Dolezal, Timothy Ekeh, Jules Guioth, Robert L. Jack, Julian Kappler, Lukas Kikuchi, Hideki Kobayashi, Yuting I. Li, Joseph D. Peterson, Patrick Pietzonka, Benjamin Remez, Paul B. Rohrbach, Rajesh Singh, and Günther Turk, arXiv:2005.09625, 2020 | ResearchGate.

  • Age-structured impact of social distancing on the COVID-19 epidemic in India. Rajesh Singh and R. Adhikari, arXiv:2003.12055, 2020 | ResearchGate.

License

We believe that openness and sharing improves the practice of science and increases the reach of its benefits. This code is released under the MIT license. Our choice is guided by the excellent article on Licensing for the scientist-programmer.

pyross's People

Contributors

erikbrorson avatar fcaballerop avatar hidekb avatar irene-li avatar jakubjdolezal avatar juliankappler avatar lukastk avatar ppietzonka avatar prohrbach avatar qacwnfq avatar rajeshrinet avatar ronojoy avatar takodas avatar tekeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyross's Issues

Questions regarding parameters 'fsa' and 'alpha'

Hello,

I was trying to simulate age-structured SIR model by tweaking the alpha (proportion of asymptomatic individuals) and fsa (fraction/weight of the contact matrix of the symptomatics as compared to asymptomatics). In my model, I set both these to 0.5. This means that the contact matrix of the symptomatics will be half that of asymptomatics which is in line with the fact that symptomatics tend to remain in quarantine or isolation and hence their contacts is less.

Questions:-

  1. Why the beta (probability of infection on contact) decreases with increasing fsa? I thought it should be the other way around. More fsa means, symptomatics contact is more and hence beta should be more. The default fsa of 1 means that symptomatics remain in contact with each other just like the way asymptomatics are. This should increase beta, right? But it seems the other way around. Maybe I am missing something.

  2. Why beta decreases with increasing alpha? More alpha means you have more asymtomatics running around contacting people at will. So, intuitivel beta should increase. But it decreases with increasing alpha. Now I can think of another scenario. More alpha means more asymtomatics. And on an average the one-to-one transmission capability of an asymptomatic person to another person is supposedly lesser than that of a symptomatic person given that there is a contact with a susceptible person. If this is the case, then perhaps a decrease in beta with increase in alpha is understandable. Can you please throw some light on this?

  3. In the 'Infected Cases (IC)' vs 'Time' plot, does the IC takes into account the number of asymptomatic cases also if alpha is set to something less than 1? Or does it only include cases that are symptomatic?

I will have many more questions in the coming few days, please do bear with me :-)

pyross model import error

Hi. This is Rukhsan here. I want to use find the effect of social distancing on the Covid19 transmission. I successfully installed the library. But when I try to import any model, I get import error. Similary I get errors when I try to import contactMatix and control etc. Can you please let me know how should I sort this out. Thanks

Least sum of squares optimization for Is+Ia

Hi,

I was simulating the asymptomatic (Ia) + symptomatic (Is) scenario to fit and find the best beta. In the findBetaIsandIa function, the sum of squares error is computed as below:

findBeta

I see a potential issue here. The cases here consists only the Is, while the Ic consists of both the Is as well as Ia. So this could be biasing the optimization. I believe the cases have to be modified to reflect an estimate of Is+Ia in there. This can be done by using alpha. By default, alpha is zero (no Ia), but in case if alpha is non-zero, then cases have to be multiplied by a factor of 1/(1-alpha) to reflect the total number of cases (Ia + Is). This would make the the estimate of beta to fit better with the total number of cases (Is + Ia). Let me know your thoughts.

Using PyRoss for a vaccination model

Hi,

I would like to use your PyRoss modelling code to implement an SEIRV model to do some inference on vaccination strategies and the reopening of schools.

As far as I’m aware, a vaccination class (where individuals can still become infected) does not seem to be readily implementable. Is this the case at present – i.e. there cannot be more than one “susceptible” class?

I was hoping you could tell me how easy this would be to either implement myself using PyRoss or whether this is something your group have been working on to include in the code but it has not yet been released?

Thanks in advance,
Abby

Difference between progression rate from E to A and recovery rates from E in ex12-SEAIRandSEAIRQ

Hello evrybody, during my models research I have checked out the examples in the pyross module and I wonder what is the the difference between progression rate from E to A and recovery rates from E in ex12-SEAIRandSEAIRQ.
As far as I know gE ( gamma) is the inverse of the length of the incubation but in the script two values are given for the same parameter : 1 and 0.04.
Is this an error or did I have a bad comprehension of this parameter ? Even if it is the case, there's still the problem of why two values for the same variable ?
Thanks in advance !
4
3

Data columns in case files

I noticed the India data has an extra column compared with the China and Italy files. Can you clarify? Maybe a README in the data covid-cases directory?

Thanks.

Derivation of parameters etc.

It would be nice if you could give a method of computing parameters like beta for those who can’t work it out directly from the paper. Using you EX3 adjusted for South Africa, beta = 0.02 is a better fit to the pre-lockdown data but eyeballing is not very rigorous.

Thanks, I am finally getting somewhere with this.

Flaw in lockdown model outputs

I just realised that the lockdown model can’t be right.

Each data point in the input case data is cumulative cases to date.

If you are modelling this, the number of cases should never drop. When you hit a lockdown, it should fall off the exponential trend but never decrease. If you are modelling something different then you need to modify the inputs to fit e.g. new cases in that day.

For example if you want new cases per day you need something like this:

for i in reversed(range(cases.shape[-1])[1:]):
    cases[...,i] = cases[...,i] - cases[...,i-1]

No module named pyross.ContactMatrix

Hello everybody, I'm novice on github. For my trainee, I have to work on SEAIR model. So I tried to use Pyross, since this morning I struggled to install all the module now when I open Python 3.8.2 Editor and try to import pyross it gives me this.
File "C:\Python38-32\lib\pyross_init_.py", line 1, in
import pyross.contactMatrix
ModuleNotFoundError: No module named 'pyross.contactMatrix'

About the setup.py when I use the install command It gives me :
C:\Python38-32\k>python setup.py install
running install
running build
running build_py
running build_ext
running install_lib
byte-compiling C:\Python38-32\Lib\site-packages\pyross\utils.py to utils.cpython-38.pyc
File "C:\Python38-32\Lib\site-packages\pyross\utils.py", line 2
cimport numpy as np
^
SyntaxError: invalid syntax

running install_egg_info
Removing C:\Python38-32\Lib\site-packages\PyRoss-1.0.0-py3.8.egg-info
Writing C:\Python38-32\Lib\site-packages\PyRoss-1.0.0-py3.8.egg-info

Can you please guide me or if a video is available?

SIR and SEIR model for Kerala

Hi,
I tweaked some stuffs, added Kerala data, fitted till data available on April 11th and simulated both SIR and SEIR models considering only the current 35 days lockdown. Both SIR and SEIR models says this lockdown is enough to contain the disease.
KERALA.zip
Although I have significantly tweaked the contactMatrix, recovery rates and other parameters. Would like you to take a look at the notebook. The notebook and the data are attached herewith. I am planning to blog about this, but since you are the developers of the model and the python package, I believe it's better to avoid any misunderstandings/confusions, if applicable :-)

Documentation of fsa and SEkIkIkR in readthedocs

I think there is an error on the description for the parameter fsa in the readthedocs?

fsa: float, np.array (M,)
Fraction by which symptomatic individuals self isolate.

should be corrected to

fsa: float, np.array (M,)
Fraction of symptomatic individuals who do not self isolate.

because a value of fsa=1 should mean that all symptomatic infectives are in contact with the general population.

Also, I think there is a typo in the description of the parameters for SEkIkIkR because it is missing fsa as a parameter?

Thank you!

Negative values in sqdev?

Hi there again,
I'm using the option least_squares_diff in latent_infer (nice one btw). I've noticed that, after doing xm = np.diff(xm,axis=0) in line 3654 of inference.pyx (function _obtain_square_dev_for_lat_traj_diff) the variable xm can end up with negative values which are added to sqdev when they are used in the denominator to normalize it. This is bad because sqdev could decrease towards minus infinity in search of a minimum. Shouldn't xm_red in the denominator of line 3658 be surrounded by np.abs() or something?
Rodrigo

making a new version on Binder

Since I am new to working on Binders, I am sharing a few things others may run into. A binder times out quite quickly and as configured there is no way to save the contents other than copying and pasting out of any open windows.

If others are running into the same issue, here is where I am getting help and will post any followups in that forum to reduce clutter here.

[WinError 2] Le fichier spécifié est introuvable

%%capture

compile PyRoss for this notebook

import os
owd = os.getcwd()
os.chdir('../')
%run setup.py install
os.chdir(owd)

D:\Anaconda3\envs\causal_net\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
995 env,
996 os.fspath(cwd) if cwd is not None else None,
--> 997 startupinfo)
998 finally:
999 # Child is launched. Close the parent's copy of those pipe

FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

Exposure latency

I'm not sure, but it seems that adding exposure latency, and hence having an SE(Ia Ir)R model, would help. I'm asking here because this is one of the few models accounting for age-based social contact.

Change the value of a *variable* during simulation

Hey there,
First off, such a great job. We are using PyRoss to implement epidemiological forecasts when you have very scarce data (as in many places here in Latin America).
My question, it would be amazing to be able to change the value of a variable (i.e. not a parameter) "by hand" at an arbitrary time during simulation, for instance to trigger a wave of a new variant (without resorting to changing parameter values as done with time_dep_params_mapping in /examples/stochastic/ex10-Spp-mutants.ipynb). Do you think it's possible? Are you guys by any chance considering implementing it?
Thanks!
Rodrigo

Changes in parameters

Hello!

I've noticed that you changed the beta parameter in the "india" examples from beta=0.0155 (as in your paper) to beta = 0.0298, is this estimate from new data? If so from when?

Thanks!

Btw, really like the paper.

Cheers!
Nadia

Data file corrections

Files in contact_matrices_152_countries in batch 2 lack the header row.

I fixed South Africa in my fork but all sheets should have a header row

X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16

This is incorrect in all the MUestimates_*_2.xlsx files – someone should fix the entire file in each case to fix this.

I also added cases for South Africa; still checking I didn’t introduced any data errors. Feel free to lift that from my fork if you need it (Wikipedia numbers – I could probably get more official if I have time).

Any chance of adding asymptomatic?

This paper models the effect of asymptomatic transmission of dengue.

I am concerned that this is a big factor being missed as there are reports that asymptomatic could be as much as 50%. If you compare Germany with Italy and Spain, Germany has an order of magnitude fewer deaths / case and its ICUs are not being swamped. It has a much higher rate of testing too. The difference cannot only be accounted for by counting more actual cases. My hypothesis: by doing aggressive track and test, the Germans reduced the next wave of contagion from asymptomatic carriers.

Typo in india.txt

Hi,

There is a typo in pyross/examples/data/covid-cases/india.txt
In the first column.
40 is repeated twice and 42 is missing, it must be 40, 41, 42

ModuleNotFoundError: No module named 'pyross.models'

I followed the installation steps but I am getting this error when I import pyross:

import pyross
Traceback (most recent call last):
File "", line 1, in
File ".../Desktop/pyross/pyross/init.py", line 1, in
import pyross.models
ModuleNotFoundError: No module named 'pyross.models'

Unable to find vcvarsall.bat

I am trying to install PyRoss using Anaconda3 power shell. This is the error message I am getting:

(base) PS C:\Users\Tomy> cd \ramp\code\pyross
(base) PS C:\ramp\code\pyross> python setup.py install
running install
running build
running build_py
running build_ext
building 'pyross.contactMatrix' extension
error: Unable to find vcvarsall.bat
(base) PS C:\ramp\code\pyross>

Please advise
Thanks
Tomy

Simulate until steady state?

If I just use solve_ivp in SciPy, I can run until steady state using callbacks. See this SO post and the following code for an SIR model. Can I do this in Pyross too?

import numpy as np
from scipy.integrate import solve_ivp

# Model definition 
def model(t, u, p):
    b,g = p
    S,I,R = u
    dS = -b*S*I
    dI = b*S*I-g*I
    dR = g*I 
    return [dS,dI,dR]

# Stop integration at steady state
def steady_state(t,u,p,f,tol):
    global flag
    du = f(t,u,p)
    condition = np.max(np.abs(du))<tol
    if flag == 1:
        if condition:
            test = [0]
        else:
            test = [1]
        flag = 0
    else:
        if condition:
            test = np.array([0])
        else:
            test = np.array([1])
    return test

# Define terminal condition and type-change flag
tol = 1e-6
limit = lambda t, u: steady_state(t,u,p,model,tol)
limit.terminal = True                                                                                                                                                                                   
global flag
flag = 1

# Extract inputs from JSON
tspan = [0,40]
u0 = [0.99,0.01,0.0]
p = [0.5,0.25]

# Run model
sol = solve_ivp(lambda t, u: model(t, u, p),
                tspan,
                u0,
                events = limit)

lack of contact matrices

for the data of contact_matrices_152_countries there is only 90 sheet so 90 country.
how can we fill the others

Pyross Installation

Hi Rajeshrinet,
I have tried to install pyros over the last two days with no luck. Indeed it is a painful journey. I did look at pyros issue posts.

Would you please help. Many thanks in advance. Also I sincerely apologize for this long post…

I have Python 3.6.5, Cython 0.28.2, Conda 4.8.2

Here is a summary of what I did:

  1. git clone https://github.com/rajeshrinet/pyross.git
  2. cd pyross
  3. for (>>> make env): conda env create -f environment.yml
  4. conda activate pyros
  5. pyross package installation (3 ways all negative result)
    5.1 conda install pyross: Error message (PackageNotFoundError)
    --------------------------- cmd screen
    Collecting package metadata (repodata.json): done
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.
    PackagesNotFoundError: The following packages are not available from current channels:

5.2 pip install pyross: 2 error messages: (1) Building wheels for pyros (PEP 517) … error, (2) Building 'pyross.contactMatrix' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
Failed to build pyros
--------------------------- cmd screen
(pyross) C:\Users\wafeeq.ajoor\pyross>pip install pyross
Collecting pyross
Using cached pyross-1.1.9.tar.gz (2.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: ipython in c:\users\wafeeq.ajoor\appdata\local\continuum\anaconda3\envs\pyross\lib\site-packages (from pyross) (7.16.1)
Requirement already satisfied: cma in c:\users\wafeeq.ajoor\appdata\local\continuum\anaconda3\envs\pyross\lib\site-packages (from pyross) (3.0.3)
Collecting jupyter
Using cached jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Requirement already satisfied: cython in c:\users\wafeeq.ajoor\appdata\local\continuum\anaconda3\envs\pyross\lib\site-packages (from pyross) (0.29.20)
:
:
:
Requirement already satisfied: zipp>=0.5 in c:\users\wafeeq.ajoor\appdata\local\continuum\anaconda3\envs\pyross\lib\site-packages (from importlib-metadata; python_version < "3.8"->jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert->pyross) (3.1.0)
Building wheels for collected packages: pyross
Building wheel for pyross (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\python.exe' 'C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\lib\site-packages\pip_vendor\pep517_in_process.py' build_wheel 'C:\Users\WAFEEQ1.AJO\AppData\Local\Temp\tmpfi5u52l7'
cwd: C:\Users\WAFEEQ
1.AJO\AppData\Local\Temp\pip-install-pt6fzrk1\pyross
Complete output (12 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pyross
copying pyross\utils_python.py -> build\lib.win-amd64-3.7\pyross
copying pyross_init_.py -> build\lib.win-amd64-3.7\pyross
copying pyross\deterministic.pxd -> build\lib.win-amd64-3.7\pyross
running build_ext
building 'pyross.contactMatrix' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

ERROR: Failed building wheel for pyross
Failed to build pyross
ERROR: Could not build wheels for pyross which use PEP 517 and cannot be installed directly
--------------------------- cmd screen end

5.3 python setup.py install: error messages: Building 'pyross.contactMatrix' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
--------------------------- cmd screen
(pyross) C:\Users\wafeeq.ajoor\pyross>python setup.py install
running install
running bdist_egg
running egg_info
writing pyross.egg-info\PKG-INFO
writing dependency_links to pyross.egg-info\dependency_links.txt
writing requirements to pyross.egg-info\requires.txt
writing top-level names to pyross.egg-info\top_level.txt
reading manifest file 'pyross.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyross.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'pyross.contactMatrix' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
--------------------------- cmd screen end

  1. I focused on #5.3 (python setup.py install), trying to resolve the issue with no luck.
    6.1 I downloaded and installed Visual C++ Build Test from the following link (Use this link to download and install Visual C++ 2015 Build Tools. It will automatically download visualcppbuildtools_full.exe and install Visual C++ 14.0 without actually installing Visual Studio): https://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat/60396650#60396650

6.2 But still getting above “Microsoft Visual C++ 14.0 is required” error message.
I thought “Path” is the issue. Here is snapshot of my system “Path”:
--------------------------- cmd screen
(pyross) C:\Users\wafeeq.ajoor\pyross>echo %PATH%
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\Library\mingw-w64\bin;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\Library\usr\bin;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\Library\bin;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\Scripts;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\envs\pyross\bin;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\condabin;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0;
C:\Program Files\Git\cmd;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0;
C:\Program Files\Git\cmd;
C:\Program Files\Microsoft VS Code\bin;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3;
C:\Users\wafeeq.ajoor\AppData\Local\Microsoft\WindowsApps;
.;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3\Scripts;
C:\Users\wafeeq.ajoor\AppData\Local\Continuum\anaconda3"
--------------------------- cmd screen end

How can I be sure that “pyross setup.py” have access to Microsoft Visual C++ 14.0 Buildtools? What seem the problem, if otherwise?

Regards,
Wafeeq

Supporting time-varying model parameters

Hi,

Any plans or possibility to support time varying model parameters that depend on other external data? Is this best achieved by modifying the contact matrix during the simulation?

Thanks!

Issue in Pyross

Hello,
I am Shalini. First of all i would like to congratulate you all for this wonderful paper. I found this paper very very useful for my work and started the same in more deep.
So, while I was exploring the implementation part of pyross , I am facing some critical issues in loading modules.
Firstly i installed the latest version of the Pyross the way you have suggested in the github and tried implementing one of the module in example folder but unfortunately it says the module is not such attribute.
It would be of great help if you can help me to solve the issue. Attaching hereby the screenshot of the error and looking forward to hear from you.
Error in pyross

Thanks & Regards,
Shalini

Unnecessarily convoluted code

In examples/inference/ex08-optimal_design.ipynb in the fifth code cell the following lines appear:

make a fltr to get Is for each age class

fltr1=np.kron([[0, 0, 0, 1]], np.identity(M))
obs1=np.einsum('ij,kj->ki', fltr1, x)

This is a very interesting way of writing
obs1 = x[:,-2:]

Verify:

import numpy as np
M = 2
x = np.random.randn(200, 4*M)

fltr1=np.kron([[0, 0, 0, 1]], np.identity(M))
np.all(np.einsum('ij,kj->ki', fltr1, x) == x[:,-2:])

Cython Compile Error ' Converting to Python object not allowed without gil' during installation

Hi,

I am facing issues whilst trying to install this library. I have Anaconda3, Python 3.7 and Cython 0.29.13.

pyross\deterministic.pyx:431:37: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            aa = bb*S[i]
            X[i]     = -aa
            X[i+M]   = aa - gI*I[i]

            for j in range(kk-1):
                X[i+(j+2)*M]   = gI*I[i+j*M] - gIa*I[i+(j+1)*M]
                                                 ^
------------------------------------------------------------

pyross\deterministic.pyx:431:50: Converting to Python object not allowed without gil
Traceback (most recent call last):
  File "setup.py", line 59, in <module>
    compiler_directives={"language_level": sys.version_info[0]},
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1096, in cythonize
    cythonize_one(*args)
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1219, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyross\deterministic.pyx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.