Skip to main content

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

Add pip install epydemix[numba] for a JIT-compiled speedup on the stochastic simulation hot path (optional — epydemix runs fine without it, just slower).

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.

  • Tutorial 1: An Introduction to Model Definition and Simulation
  • Tutorial 2: Using Population Data from Epydemix Data
  • Tutorial 3: Modeling Non-pharmaceutical Interventions
  • Tutorial 4: Model Calibration with ABC (Part 1)
  • Tutorial 5: Model Calibration with ABC (Part 2)
  • Tutorial 6: Advanced Modeling Features
  • Tutorial 7: COVID-19 Case Study
  • Tutorial 8: Modeling Multiple Strains
  • Tutorial 9: Modeling Vaccinations
  • Tutorial 10: Speeding up Simulations and Calibration with Multiprocessing
  • Tutorial 11: Using Epistorm-Mix Contact Matrices (sex and race/ethnicity)
  • Tutorial 12: Predefined Epidemic Models — Backbones and Modular Extensions
  • Tutorial 13: The Command-Line Interface — Scenarios, Calibration, and Projections from YAML Configs

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.


Agent Framework

Epydemix also ships a CLI for driving simulations programmatically — designed for use by LLM agents and automation pipelines, but equally usable from the shell. It covers discovery, config validation, running, calibration, and inspecting results end-to-end.

pip install "epydemix[agent]"

epydemix models                                       # discover available models
epydemix run config.yaml --output results.epx         # run a YAML-configured simulation
epydemix inspect results.epx peak -v Infected_total   # query results as compact JSON

See AGENT_FRAMEWORK.md for an overview and quick start, AGENT.md for the full CLI and config reference, and AGENT_EXAMPLES.md for worked examples.


Web API

The Epydemix Web API is a REST API for running epydemix simulations over HTTP: run a simulation from a JSON request, list populations and their contact matrices, and browse model presets. Each request can also be exported as an equivalent, runnable Python script. See its documentation and API reference.


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.

Metadata

Release files for epydemix 1.5.0

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

Source distribution (sdist)

Source distribution for epydemix 1.5.0
File Size Uploaded Provenance Actions
epydemix-1.5.0.tar.gz 196.5 kB Without provenance Details for epydemix-1.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 406.9 kB

Release files / epydemix-1.5.0.tar.gz

Download URL epydemix-1.5.0.tar.gz
Size 196.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dec3cb7aa525c4f1bf279c066000bfd96f17b108b78143e3b40df7b2b75ed83a
BLAKE2b-256 checksum
How to use checksums
3861ae3063e7e902588313087265930320ce8693fcda00432edd5fef578fb3ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / epydemix-1.5.0-py3-none-any.whl

Download URL epydemix-1.5.0-py3-none-any.whl
Size 210.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba16e59065a0715834559e5367a80828cc881790a185ec6b54606a129e6b9a46
BLAKE2b-256 checksum
How to use checksums
db2ed797b427cb6e7031575eee781645100cc679461bf2ebca75a32dae3deb17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for epydemix 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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