Live Demo: https://njvinay.github.io/Covid-19-Simulation
A comprehensive data-driven simulation model for COVID-19 that studies state transitions and forecasts disease progression across different countries and age groups. This project demonstrates the power of computational modeling in understanding pandemic dynamics and aiding in strategic decision-making.
This simulation models COVID-19 disease progression through five distinct states:
- H (Healthy): Susceptible individuals
- I (Infected): Individuals who have contracted the virus
- S (Serious): Severe cases requiring intensive care
- M (Mild/Immune): Recovered individuals with immunity
- D (Deceased): Fatal cases
The model uses age-specific transition probabilities and holding times to simulate realistic disease progression over time.
- Multi-Country Support: Simulate COVID-19 progression across 150+ countries
- Age-Stratified Modeling: Five age groups (less_5, 5_to_14, 15_to_24, 25_to_64, over_65) with distinct epidemiological parameters
- Interactive Web Interface: Streamlit-based UI for easy configuration and execution
- Flexible Sampling: Adjustable sample ratios for computational efficiency
- Comprehensive Visualization: Automatic generation of filled area plots and line graphs
- Time-Series Output: Detailed CSV exports of individual-level and aggregated data
????????? assignment2.py # Core simulation engine
????????? streamlit_ui.py # Interactive web interface
????????? sim_parameters.py # Transition probabilities and holding times
????????? helper.py # Plotting utilities
????????? test.py # Unit tests
????????? a2-countries.csv # Country demographic data (154 countries)
????????? README.md # This file
????????? *.txt # Documentation files
- Python 3.7+
- pip package manager
pip install numpy pandas matplotlib streamlit- Launch the Streamlit app:
streamlit run streamlit_ui.py-
Configure simulation parameters:
- Sample Ratio: Population scaling factor (default: 1,000,000)
- Start Date: Simulation start date
- End Date: Simulation end date
- Countries: Select one or more countries from the dropdown
-
Click "Run" to execute the simulation
import assignment2
# Run simulation for specific countries
assignment2.run(
countries_csv_file_info='a2-countries.csv',
choosen_countries=['Afghanistan', 'Sweden', 'Japan'],
sample_ratio=1e6,
start_date='2021-04-01',
end_date='2022-04-30'
)python test.pyAge-specific probabilities for state transitions:
- Young age groups (<24): Lower infection rates (10%), minimal mortality (1%)
- Adult groups (25-64): Higher infection rates (30%), moderate mortality (5-20%)
- Elderly (65+): Highest risk with 30% infection rate and up to 40% mortality from serious cases
Duration (in days) individuals remain in each state:
- Infected (I): 4 days
- Serious (S): 14 days
- Mild/Immune (M): 120 days
- Healthy/Deceased: 0 days (no holding time)
The simulation generates three types of output:
-
a2-covid-simulated-timeseries.csv: Individual-level state transitions over time
- Columns: unique_id, country, age_group_name, date, state, staying_days, prev_state
-
a2-covid-summary-timeseries.csv: Aggregated daily counts by country and state
- Columns: date, country, H, I, S, M, D
-
covid_{country}_filled_plot.png: Visualization for each simulated country
Generates a sample population based on demographic data and specified sampling ratio.
Simulates disease progression for each individual using Markov chain state transitions.
Main orchestration function that executes the complete simulation pipeline.
Creates filled area plots showing state distribution over time for each country.
The simulation employs a discrete-time Markov chain approach:
- Population Sampling: Scales country populations using the sample ratio while preserving age distributions
- State Initialization: All individuals start in the "Healthy" (H) state
- Daily State Transitions: For each day and individual:
- Check if holding time for current state has elapsed
- If elapsed, randomly select next state based on age-specific transition probabilities
- If not elapsed, remain in current state
- Data Aggregation: Summarize individual states by country and date
- Visualization: Generate plots showing epidemic curves
The a2-countries.csv file contains demographic information for 154 countries including:
- Total population
- Median age
- Age distribution percentages (5 age groups)
- Sample ratios of 1,000,000 (1M) are recommended for computational efficiency
- Larger date ranges increase processing time linearly
- Memory usage scales with: (population / sample_ratio) ?? number of days ?? number of countries
- Assumes closed populations (no migration)
- Homogeneous mixing within countries
- Fixed transition probabilities over time
- No intervention modeling (vaccines, lockdowns, etc.)
- Vaccination modeling
- Regional/sub-national resolution
- Dynamic transmission rates
- Healthcare capacity constraints
- Multiple virus variants
This project was developed as part of an academic assignment. Contributions, improvements, and extensions are welcome.
This project is available for educational and research purposes.
For questions or collaboration opportunities, please refer to the repository owner.
Note: This is a simplified epidemiological model designed for educational purposes. It should not be used for real-world policy decisions without extensive validation and refinement.
GitHub Pages hosts a static snapshot of the model outputs. The build uses scripts/build_static.py to run a small, fixed simulation and publish the resulting charts and CSVs as a static site.
- Build command:
python scripts/build_static.py - Publish directory:
docs - Customize the snapshot by editing
DEFAULT_COUNTRIES,DEFAULT_START_DATE,DEFAULT_END_DATE, andDEFAULT_SAMPLE_RATIOinscripts/build_static.py.
If you want the interactive UI, deploy streamlit_ui.py to Streamlit Community Cloud, Render, or another Python host instead of GitHub Pages.