Skip to content

venkata3204sai/Covid-19-simulation-using-Python

Repository files navigation

Covid-19 Simulation (Python)

License: MIT Python Version Streamlit Markov Simulation Last Commit Repo Size

Simulates the spread of COVID-19 using a per-country sampled population and a simple Markov-chain per-person model.
This assignment-style project creates a per-person daily time-series, a per-country daily summary, and a visualization of infection waves. It also includes a small Streamlit app to run and visualize the results.

Snapshot

  • Status: working (no automated CI or packaging yet).
  • Language: Python
  • Key files: assignment2.py, app.py (Streamlit UI), helper.py, sim_parameters.py, a2-countries.csv, test.py.
  • Outputs:
    • a2-covid-simulated-timeseries.csv
    • a2-covid-summary-timeseries.csv
    • a2-covid-simulation.png.

What it does

  • Builds sampled populations for selected countries (sample ratio, e.g. 1e6).
  • Runs a per-person, daily Markov chain using age-group specific transition probabilities (from sim_parameters.py) between states:
    • H (healthy)
    • I (infected, no symptoms)
    • S (symptomatic)
    • M (immune)
    • D (deceased).
  • Saves:
    • a2-covid-simulated-timeseries.csv — long table of person/day/state.
    • a2-covid-summary-timeseries.csv — aggregated counts per country/day for states D, H, I, M, S.
    • a2-covid-simulation.png — chart created by helper.py::create_plot().

Quick setup (local)

  1. Create venv and install:
python -m venv .venv
source .venv/bin/activate    # or .venv\Scripts\activate on Windows
pip install --upgrade pip
pip install -r requirements.txt  # or: pip install pandas matplotlib streamlit
  1. Run the simulation (default inputs are read from test.py):
# Run assignment script directly (example arguments)
python assignment2.py
# or if the file exposes run() and test.py calls it, run the test driver:
python test.py
  1. Run the Streamlit app (interactive):
streamlit run app.py
# then open http://localhost:8501

File Overview

  • assignment2.py — main simulator (implements run(countries_csv_name, countries, start_date, end_date, sample_ratio)).
  • sim_parameters.py — transition probabilities and holding times per age group.
  • helper.py — plotting helper (provides create_plot() used to produce PNG).
  • app.py — Streamlit UI that calls assignment2.run(...).
  • test.py — example driver and test harness.
  • a2-countries.csv — country demographics input.
  • ass2.ipynb — notebook used for experimentation.

Outputs (generated by running):

  • a2-covid-simulated-timeseries.csv
  • a2-covid-summary-timeseries.csv
  • a2-covid-simulation.png

Example usage

Run the sim for ["Afghanistan", "Sweden", "Japan"] from 2021-04-01 to 2022-04-30 with sample ratio 1e6. Output CSV + PNG will be written to the project root.

Example Plot Image

COVID-19 Simulation Output

About

Markov-chain simulation of COVID-19 spread across sampled country populations, with per-person daily state transitions (healthy → infected → symptomatic → immune/deceased) and an interactive Streamlit dashboard

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages