Skip to main content

A Python package for epidemic modeling, simulation, and calibration

Project description

Epydemix, the ABC of Epidemics

GitHub stars PyPI Downloads Read the Docs License: GPL v3 Codecov PyPI version PLOS Computational Biology

Alt text

Documentation | Website | Tutorials

Epydemix is a Python package for epidemic modeling. It provides tools to create, calibrate, and analyze epidemic models, allowing users to simulate the spread of infectious diseases using different compartmental models, contact layers, and calibration techniques. It is designed to be used in conjunction with the epydemix-data package to load population and contact matrix data.

Installation

You can install epydemix from either PyPI or conda-forge. We recommend using a virtual environment (via conda, mamba, or venv) to avoid dependency conflicts.

Install from PyPI

pip install epydemix

Install from Conda (conda-forge)

conda install -c conda-forge epydemix

To create a fresh environment and install Epydemix:

conda create -n epydemix-env -c conda-forge epydemix
conda activate epydemix-env

Quick Start

Once installed, you can start using epydemix in your Python scripts or Jupyter notebooks. Below an example to get started.

Example: Creating and running a simple SIR model

from epydemix import EpiModel
from epydemix.visualization import plot_quantiles

# Define a basic SIR model
model = EpiModel(
    name="SIR Model",
    compartments=["S", "I", "R"],  # Susceptible, Infected, Recovered
)

# Add transitions: infection and recovery
model.add_transition(source="S", target="I", params=(0.3, "I"), kind="mediated")
model.add_transition(source="I", target="R", params=0.1, kind="spontaneous")

# Run simulations
results = model.run_simulations(
    start_date="2024-01-01",
    end_date="2024-04-10",
    Nsim=100,
)

# Extract and plot quantiles of compartment counts
df_quantiles = results.get_quantiles_compartments()
plot_quantiles(df_quantiles, columns=["I_total", "S_total", "R_total"])

Tutorials

We provide a series of tutorials to help you get started with epydemix.

You can run all tutorials directly in Google Colab — just open any notebook in the tutorials folder and click the “Open in Colab” button at the top.


Epydemix Data

epydemix also provides access to a wealth of real-world population and contact matrix data through the epydemix_data module. This dataset allows you to load predefined population structures, including age distribution and contact matrices for over 400 locations globally. You can use this data to create realistic simulations of disease spread in different geographies.

Example of Loading Population Data

from epydemix.population import load_epydemix_population

# Load population data for the United States using the Mistry 2021 contact matrix
population = load_epydemix_population(
    population_name="United_States",
    contacts_source="mistry_2021",
    layers=["home", "work", "school", "community"],
)

# Assign the loaded population to the epidemic model
model.set_population(population)

Epydemix can load data either locally from a folder or directly from online sources, making it easy to simulate a wide range of epidemic models on real population data.

For more information about the available population and contact matrices and to download the data, please visit the dedicated repository.


Citation

The paper describing the development of Epydemix is available here. To reference our work, please use the following citation:

@article{gozzi2025epydemix,
  title={Epydemix: An open-source Python package for epidemic modeling with integrated approximate Bayesian calibration},
  author={Gozzi, Nicol{\'o} and Chinazzi, Matteo and Davis, Jessica T and Gioannini, Corrado and Rossi, Luca and Ajelli, Marco and Perra, Nicola and Vespignani, Alessandro},
  journal={PLOS Computational Biology},
  volume={21},
  number={11},
  pages={e1013735},
  year={2025},
  publisher={Public Library of Science San Francisco, CA USA}
}

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for more details.


Contributors

Contributions are welcome! Please read our Contributing Guide and open issues or pull requests on GitHub. For questions and general discussion, visit our GitHub Discussions.


Changelog

See the CHANGELOG file for details on past releases and updates.


Contact

For questions or issues, please open an issue on GitHub or contact the maintainer at epydemix@isi.it.

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

epydemix-1.1.0.tar.gz (105.9 kB view details)

Uploaded Source

Built Distribution

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

epydemix-1.1.0-py3-none-any.whl (111.2 kB view details)

Uploaded Python 3

File details

Details for the file epydemix-1.1.0.tar.gz.

File metadata

  • Download URL: epydemix-1.1.0.tar.gz
  • Upload date:
  • Size: 105.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for epydemix-1.1.0.tar.gz
Algorithm Hash digest
SHA256 19c8b9d933d335114d185414ab04e04860cd776178e197bf5bc34410747a2b4e
MD5 396f370109069405c3584ea4e9ac8f59
BLAKE2b-256 31ced173001a8e4d61b717b2a93e6b966833870dfc702dafcd18e39c74cfa8a4

See more details on using hashes here.

File details

Details for the file epydemix-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: epydemix-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 111.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for epydemix-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 771562d13c05870d030ab0f78953533e08b24fabfb6cbea6322a689024bb8b52
MD5 d2a8ef228feb99ccdaf2463ebdb47098
BLAKE2b-256 a229617677c0910e2493384de43ec8217b49426370d5ef5718da0edf90f19a80

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