Skip to main content

A python driver for epidemic modeling and inference

Project description

Github Build Status Documentation Status https://badge.fury.io/py/pydemic.svg

The pydemic package comprises a set of tools for modeling the population dynamics of an epidemic and calibrating models to data. pydemic provides implementations of various types of compartmental models, including not only SIR/SEIR models but also the more general Kermack and McKendrick age-of-infection models, which allow transitions between disease states to be described by arbitrary time-delay distributions. More generally, pydemic provides a framework for users to specify custom epidemic models by extending the base classes for reaction-based and non-Markovian simulations.

To evaluate a model’s applicability to an actual epidemic, its predictions (e.g., for the rate of new cases or deaths) can be compared to real world data. Parameter inference—the task of calibrating a model’s input parameters via likelihood estimation—is supported by pydemic’s interfaces to the Markov chain Monte Carlo package emcee and SciPy’s global optimization routines.

pydemic provides simple parsers for COVID-19 case data sourced from the COVID Tracking Project and the New York Times. Pull requests that contribute new, robust parsers are welcome!

As an example, we consider our SEIR++ model, which treats the dynamics of infection and subsequent hospitalization. The model includes a large set of parameters that specify the distribution of various time delays (e.g., for the spread of infection, symptom onset, and hospitalization), the severity of infection (i.e., the likelihood of progressing from one stage of the disease to the next), and the time-dependent degree to which interventions mitigate the spread of the disease. We calibrate these parameters by comparing the model’s predictions to COVID-19–related hospitalizations and deaths in Illinois. We describe the model and calibration procedure in detail in a recent preprint on the arXiv.

pydemic is in beta. While effort will be made to preserve backwards compatibility with staged deprecation, we cannot guarantee that features will be preserved or that interfaces will not change. However, we will attempt to ensure that backwards-incompatible changes are demarcated by incrementing the major version.

pydemic is fully documented and is licensed under the liberal MIT license. See the docs for citation info.

Getting started

pydemic is available on PyPI and can be installed with pip:

pip install pydemic

Several examples exhibit how to use pydemic:

  • The SEIR++ tutorial notebook demonstrates how to set up a simulation object, specify parameters, run the simulation, and visualize the results.

  • An example of calibration illustrates how to set up likelihood estimation, run Markov chain Monte Carlo, and plot the posterior probability distribution of model parameters, using the SEIR++ model and public Illinois data from the COVID Tracking Project as an example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydemic-2020.2.2.tar.gz (874.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydemic-2020.2.2-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file pydemic-2020.2.2.tar.gz.

File metadata

  • Download URL: pydemic-2020.2.2.tar.gz
  • Upload date:
  • Size: 874.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pydemic-2020.2.2.tar.gz
Algorithm Hash digest
SHA256 6c0f9477daa653a8967aed46b6530c1f499ae8b2ce2dcebf684e6eb8c20781b0
MD5 61c659b2731ba04113b74ef401e9d85e
BLAKE2b-256 cad76c297f8d93e6c912801cc6e291ad85b539ffdf72e44ece414bc185f23144

See more details on using hashes here.

File details

Details for the file pydemic-2020.2.2-py3-none-any.whl.

File metadata

  • Download URL: pydemic-2020.2.2-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pydemic-2020.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e073d17a9ad36a6e4b1989305a73ac8e3c16032ca8fdfb6f641c2e646dc7726
MD5 300c4eaad853b762261b73cbd444f7bb
BLAKE2b-256 f38977d69f1a34d3a6316ceacd7b091d9133a0af22647f6e2bbca107df7607f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page