Skip to main content

A Pytorch library for machine learning in epidemic modeling

Project description

EpiLearn

Epidemic Modeling with Pytorch

Documentation Status License MIT Downloads Web Interface

Documentation | Paper | Web Interface

EpiLearn is a Pytorch-based machine learning tool-kit for epidemic data modeling and analysis. We provide numerour features including:

  • Implementation of Epidemic Models
  • Simulation of Epidemic Spreading
  • Visualization of Epidemic Data
  • Unified Pipeline for Epidemic Tasks

For more models, please refer to our Awesome-Epidemic-Modeling-Papers

Installation

From Source

git clone https://github.com/Emory-Melody/EpiLearn.git
cd EpiLearn

conda create -n epilearn python=3.9
conda activate epilearn

python setup.py install

From Pypi

pip install epilearn

EpiLearn also requires pytorch>=1.20, torch_geometric and torch_scatter. For cpu version, we simply use pip install torch, pip install torch_geometric and pip install torch_scatter. For GPU version, please refer to Pytorch, PyG and torch_scatter.

Tutorial

We provide a complete tutorial of EpiLearn in our documentation, including pipelines, simulations and other utilities. For more examples, please refer to the example folder. For the overal framework of EpiLearn, please check our paper.

Here we also offer a quickstart of how to use the EpiLearn for forecast and detection task.

Forecast Pipeline

from epilearn.models.SpatialTemporal.STGCN import STGCN
from epilearn.data import UniversalDataset
from epilearn.utils import transforms
from epilearn.tasks.forecast import Forecast
# initialize settings
lookback = 12 # inputs size
horizon = 3 # predicts size
# load toy dataset
dataset = UniversalDataset()
dataset.load_toy_dataset()
# Adding Transformations
transformation = transforms.Compose({
                "features": [transforms.normalize_feat()],
                "graph": [transforms.normalize_adj()]})
dataset.transforms = transformation
# Initialize Task
task = Forecast(prototype=STGCN,
                dataset=None, 
                lookback=lookback, 
                horizon=horizon, 
                device='cpu')
# Training
result = task.train_model(dataset=dataset, 
                          loss='mse', 
                          epochs=50, 
                          batch_size=5, 
                          permute_dataset=True)
# Evaluation
evaluation = task.evaluate_model()

Detection Pipeline

from epilearn.models.Spatial.GCN import GCN
from epilearn.data import UniversalDataset
from epilearn.utils import transforms
from epilearn.tasks.detection import Detection
# initialize settings
lookback = 1 # inputs size
horizon = 2 # predicts size; also seen as number of classes
# load toy dataset
dataset = UniversalDataset()
dataset.load_toy_dataset()
# Adding Transformations
transformation = transforms.Compose({
                " features": [],
                " graph": []})
dataset.transforms = transformation
# Initialize Task
task = Detection(prototype=GCN, 
                 dataset=None, 
                 lookback=lookback, 
                 horizon=horizon, 
                 device='cpu')
# Training
result = task.train_model(dataset=dataset, 
                          loss='ce', 
                          epochs=50, 
                          batch_size=5)
# Evaluation
evaluation = task.evaluate_model()

Web Interface

Our web application is deployed online using streamlit. But it also can be initiated using:

python -m streamlit run interface/app.py to activate the interface

Citing

If you find this work useful, please cite: EpiLearn: A Python Library for Machine Learning in Epidemic Modeling

@article{liu2024epilearn,
title={EpiLearn: A Python Library for Machine Learning in Epidemic Modeling},
author={Liu, Zewen and Li, Yunxiao and Wei, Mingyang and Wan, Guancheng and Lau, Max SY and Jin, Wei},
journal={arXiv e-prints},
pages={arXiv--2406},
year={2024}
}

Acknowledgement

Some algorithms are adopted from the papers' implmentation and the original links can be easily found on top of each file. We also appreciate the datasets from various sources, which will be highlighted in the dataset file.

Thanks to their great work and contributions!

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

epilearn-0.0.8.tar.gz (91.0 kB view details)

Uploaded Source

File details

Details for the file epilearn-0.0.8.tar.gz.

File metadata

  • Download URL: epilearn-0.0.8.tar.gz
  • Upload date:
  • Size: 91.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for epilearn-0.0.8.tar.gz
Algorithm Hash digest
SHA256 ed861203c772d86d47a3e2a59b1e38edfbbe51eaf5fbed04b5da6abc80da8a66
MD5 61d2228d53738b76f2edd3f2a64008ba
BLAKE2b-256 808f274d4685ea02b5ae90176122874ae1997421114146dec5b1d28993bce4e2

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