Skip to main content
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.

Metadata

Release files for pydemic 2020.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydemic 2020.2.2
File Size Uploaded
pydemic-2020.2.2.tar.gz 874.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydemic 2020.2.2
File Interpreter ABI Platform
pydemic-2020.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 913.2 kB

Release files / pydemic-2020.2.2.tar.gz

Download URL pydemic-2020.2.2.tar.gz
Size 874.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6c0f9477daa653a8967aed46b6530c1f499ae8b2ce2dcebf684e6eb8c20781b0
BLAKE2b-256 checksum
How to use checksums
cad76c297f8d93e6c912801cc6e291ad85b539ffdf72e44ece414bc185f23144
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pydemic-2020.2.2-py3-none-any.whl

Download URL pydemic-2020.2.2-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e073d17a9ad36a6e4b1989305a73ac8e3c16032ca8fdfb6f641c2e646dc7726
BLAKE2b-256 checksum
How to use checksums
f38977d69f1a34d3a6316ceacd7b091d9133a0af22647f6e2bbca107df7607f4
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

2020.2.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page