A Python package for epidemic modeling, simulation, and calibration
Project description
Epydemix, the ABC of Epidemics
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
To install the latest version of epydemix from PyPI, use the following command in a terminal or command prompt—ideally within a virtual environment to avoid dependency conflicts:
pip install epydemix
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
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 preprint describing the development of Epydemix is available here. To reference our work, please use the following citation:
@article{gozzi2025epydemix,
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},
title = {Epydemix: An open-source Python package for epidemic modeling with integrated approximate Bayesian calibration},
elocation-id = {2025.05.07.25327151},
year = {2025},
doi = {10.1101/2025.05.07.25327151},
publisher = {Cold Spring Harbor Laboratory Press},
URL = {https://www.medrxiv.org/content/early/2025/05/08/2025.05.07.25327151},
eprint = {https://www.medrxiv.org/content/early/2025/05/08/2025.05.07.25327151.full.pdf},
journal = {medRxiv}
}
License
This project is licensed under the GPL-3.0 License. See the LICENSE file for more details.
Contributors
Contributions are welcome! Please open issues or pull requests on GitHub.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file epydemix-1.0.2.tar.gz.
File metadata
- Download URL: epydemix-1.0.2.tar.gz
- Upload date:
- Size: 97.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90633fa5b3329fef9db7d62361108cc5771c9b5d035b7a9253f50275b5b70684
|
|
| MD5 |
2b5803906d9c874d365be5d748e3f3e3
|
|
| BLAKE2b-256 |
959c597ece0120b4a41585b49f9c0c7888da97276b484182b2e6301e74da9900
|
File details
Details for the file epydemix-1.0.2-py3-none-any.whl.
File metadata
- Download URL: epydemix-1.0.2-py3-none-any.whl
- Upload date:
- Size: 102.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09a67c7478723ce27d903b0ac4acee5a6834bda5ef6166e6e2848e2aaa66aee9
|
|
| MD5 |
e87fa8fcb8d50ea007548e70c5baa183
|
|
| BLAKE2b-256 |
ca1973c7ba741aec09b1b4608035144f4c61a1ccd417708a5266ea12d430964e
|