An end-to-end AI system for pandemic surveillance, forecasting, and decision support β designed for government agencies, healthcare organizations, and public health researchers.
π Web Link Live : https://pandemic-intelligence.streamlit.app/
- Overview
- Key Features
- System Architecture
- Tech Stack
- Project Structure
- Quick Start
- Step-by-Step Guide
- Model Details
- API Reference
- Dashboard
- Model Performance
- Dataset
- Deployment
- CI/CD Pipeline
- Contributing
- License
The Pandemic Intelligence System is a production-grade, research-quality AI platform that transforms raw COVID-19 epidemiological data into actionable intelligence. It combines classical time-series methods, deep learning, and explainable machine learning into a unified decision-support system.
This project was designed to demonstrate the full ML engineering lifecycle β from raw data ingestion to a live deployed API and interactive dashboard β using industry-standard tools and best practices.
What it solves:
- Governments need early warning of outbreak surges before they become unmanageable
- Healthcare systems need risk stratification across hundreds of countries simultaneously
- Policymakers need "what-if" simulation before imposing restrictions
- Researchers need reproducible, explainable models β not black boxes
| Module | Feature | Technology |
|---|---|---|
| Data Engineering | Merges 6 datasets, 70+ engineered features | Pandas, NumPy |
| Forecasting | 7/14/30-day predictions per country | LSTM + Attention, Prophet, ARIMA |
| Risk Scoring | Low/Medium/High classification with probability | XGBoost + SHAP |
| Anomaly Detection | Real-time outbreak surge detection | Isolation Forest + LSTM Autoencoder |
| Explainability | SHAP values for every risk prediction | SHAP, matplotlib |
| REST API | Production-ready endpoints with Pydantic validation | FastAPI, uvicorn |
| Dashboard | Interactive multi-page dark-theme UI | Streamlit, Plotly |
| Deployment | Containerized, CI/CD enabled | Docker, GitHub Actions |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA SOURCES (6 CSVs) β
β full_grouped Β· covid_clean Β· worldometer Β· country_wise Β· day_wise β
βββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA PIPELINE β
β β
β βββββββββββββββββββ ββββββββββββββββββββββββ β
β β Data Cleaning βββββΆβ Feature Engineering β β
β β β’ Merge CSVs β β β’ Rolling averages β β
β β β’ Null handlingβ β β’ Growth rate, CFR β β
β β β’ Name mapping β β β’ Lag features (14) β β
β βββββββββββββββββββ ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MODEL LAYER β
β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β LSTM + Attentionβ β XGBoost Risk β β Isolation Forestβ β
β β βββββββββββββββ β β ββββββββββββββ β β + LSTM Autoenc. β β
β β Time-series β β Classification β β ββββββββββββββ β β
β β forecasting β β Low/Med/High β β Outbreak detect β β
β β 7/14/30 days β β + SHAP explain β β Surge warning β β
β ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Prophet β β ARIMA/SARIMA β β
β β (seasonal) β β (baseline) β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API LAYER (FastAPI) β
β β
β POST /predict POST /risk POST /anomaly GET /summary β
βββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DASHBOARD (Streamlit) β
β β
β Global Map Β· Forecasting Β· Risk Assessment Β· Anomaly Β· Analysis β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Library | Version | Purpose |
|---|---|---|
torch |
2.1.0 | LSTM with Multi-Head Attention, LSTM Autoencoder |
xgboost |
2.0.0 | Risk classification |
prophet |
1.1.5 | Seasonal time-series forecasting |
statsmodels |
0.14.0 | ARIMA/SARIMA baseline models |
scikit-learn |
1.3.2 | Isolation Forest, preprocessing, cross-validation |
shap |
0.43.0 | Model explainability (SHAP values) |
pandas |
2.1.0 | Data manipulation and feature engineering |
numpy |
1.24.4 | Numerical computing |
scipy |
1.11.3 | Signal processing (wave detection) |
| Library | Version | Purpose |
|---|---|---|
fastapi |
0.104.0 | REST API framework |
uvicorn |
0.24.0 | ASGI server |
pydantic |
2.4.2 | Request/response schema validation |
streamlit |
1.28.0 | Interactive dashboard |
plotly |
5.17.0 | Interactive charts and choropleth maps |
| Tool | Purpose |
|---|---|
| Docker | Container packaging |
| docker-compose | Multi-service orchestration |
| GitHub Actions | CI/CD pipeline |
| Render.com | API hosting (free tier) |
| Streamlit Cloud | Frontend hosting (free tier) |
pandemic-intelligence-system/
β
βββ π.devcontainer
| βββ devcontainer.json
|
βββ π api/ # FastAPI backend
β βββ main.py # App entry point + all endpoints
|
βββ π data/
β βββ raw/ # Original CSV datasets (place here)
β β βββ full_grouped.csv
β β βββ covid_19_clean_complete.csv
β β βββ worldometer_data.csv
β β βββ country_wise_latest.csv
β β βββ day_wise.csv
β β βββ usa_county_wise.csv.zip
β β
β βββ processed/ # Auto-generated by Step 1β2
β β βββ cleaned_data.csv
β β βββ features_data.csv
β β βββ worldometer_clean.csv
β β βββ day_wise_clean.csv
β β
β βββ eda_outputs/ # Charts from Step 3
β βββ forecast_outputs/ # Forecast plots + metrics from Step 4
β βββ risk_outputs/ # SHAP plots + risk map from Step 6
β βββ anomaly_outputs/ # Anomaly scores from Step 5
β
|
βββ π deployment/
β βββ Dockerfile
β βββ docker-compose.yml
|
βββ π frontend/
β βββ app.py # Streamlit dashboard (5 pages)
|
βββ π models/ # Saved model artifacts (auto-created)
β βββ isolation_forest.pkl
β βββ lstm_autoencoder.pth
β βββ lstm_brazil.pth
β βββ lstm_forecasts.pkl
β βββ lstm_india.pth
β βββ lstm_models_dict.pkl
β βββ lstm_united_kingdom.pth
β βββ lstm_united_states.pth
β βββ risk_features.pkl
β βββ scaler_anomaly.pkl
β βββ scaler_brazil.pkl
β βββ scaler_india.pkl
β βββ scaler_united_kingdom.pkl
β βββ scaler_united_states.pkl
β βββ xgboost_risk.pkl
|
|
βββ π notebook/ # Run sequentially on Kaggle or local
β βββ pandemic-project.ipynb
β
βββ π tests/
β βββ test_api.py # Pytest unit + integration tests
β
βββ .gitignore
βββ .python-version
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ streamlit_requirements.txt
- Python 3.10+
- pip
- Git
- 8GB RAM minimum (16GB recommended for LSTM training)
- NVIDIA GPU optional (10Γ faster training)
git clone https://github.com/kunalkirtak/pandemic-intelligence.git
cd pandemic-intelligencepython -m venv venv
# Linux/macOS
source venv/bin/activate
# Windows
venv\Scripts\activatepip install -r requirements.txtDownload the COVID-19 dataset from Kaggle and place all CSV files in data/raw/:
data/raw/
βββ full_grouped.csv
βββ covid_19_clean_complete.csv
βββ worldometer_data.csv
βββ country_wise_latest.csv
βββ day_wise.csv
βββ usa_county_wise.csv
# Step 1-6: Data β Models (run in order)
All in pandemic-project.ipynb
python notebook/01_data_cleaning.py
python notebook/02_feature_engineering.py
python notebook/03_eda.py
python notebook/04_time_series_models.py # Takes 10β30 min (GPU: ~3 min)
python notebook/05_anomaly_detection.py
python notebook/06_risk_model.py
# Start API (Terminal 1)
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000
# Start Dashboard (Terminal 2)
streamlit run frontend/app.pyAPI: http://localhost:8000/docs
Dashboard: http://localhost:8501
python notebooks/01_data_cleaning.py- Merges all 6 raw CSVs into a unified country-day format
- Standardizes 15+ country name variants (e.g.
USβUnited States) - Handles missing values, removes negative data errors
- Aggregates province/state data to country level
Output: data/processed/cleaned_data.csv (187 countries Γ date range)
python notebooks/02_feature_engineering.pyCreates 20+ engineered features per country-day:
| Feature | Formula | Use |
|---|---|---|
Growth_Rate |
ΞCases / Cases Γ 100 |
Spread speed |
CFR |
Deaths / Confirmed Γ 100 |
Severity |
Recovery_Rate |
Recovered / Confirmed Γ 100 |
System capacity |
Doubling_Time |
ln(2) / ln(1 + GR/100) |
Exponential growth proxy |
MA_7_Cases |
7-day rolling average | Noise smoothing |
MA_14_Cases |
14-day rolling average | Trend detection |
Case_Acceleration |
Ξ(Daily_Cases) |
Surge velocity |
Cases_Lag_1/3/7/14 |
Shifted case counts | Temporal ML features |
Output: data/processed/features_data.csv (70+ columns)
python notebooks/03_eda.pyGenerates 8 analytical outputs:
- Global Pandemic Timeline β Cumulative + daily trend plots
- Top Countries Comparison β Interactive Plotly line chart
- Wave Detection β SciPy peak detection with wave labeling
- Country Clustering β K-Means (k=5) with PCA 2D projection
- Correlation Heatmap β 12-feature Pearson correlation matrix
- CFR vs Recovery Rate β Bubble scatter by country
- Case Distribution Treemap β Top 50 countries, color-coded by CFR
- Distribution Plots β CFR and Recovery Rate histograms
Output: data/eda_outputs/ (8 PNG + HTML files)
python notebooks/04_time_series_models.pyTrains 3 model tiers per country:
- Auto-selects
(p, d, q)via AIC grid search - ADF test determines differencing order
d - Serves as statistical benchmark
- Multiplicative seasonality (weekly + monthly)
changepoint_prior_scale=0.05for controlled regime changes- Returns 95% confidence intervals
Architecture:
Input (seq_len=30) β LSTM (128 units, 2 layers)
β Multi-Head Attention (4 heads)
β FC(128β64) β ReLU β Dropout(0.1) β FC(64β1)
Loss: Huber Loss (robust to outliers)
Optimizer: Adam (lr=0.001, weight_decay=1e-5)
Scheduler: ReduceLROnPlateau (patience=10)
Epochs: 80 with early stopping (best checkpoint saved)
Output: Saved .pth + .pkl model files, data/forecast_outputs/model_metrics_comparison.csv
python notebooks/05_anomaly_detection.pyn_estimators=200,contamination=0.05- Detects outlier country-day records from ~7 features
- Fast, interpretable, good for operational use
Architecture:
Encoder: LSTM(inputβ64) β FC(64β16) [latent vector]
Decoder: FC(16β64) β LSTM(64βinput) [reconstruction]
Trained on: "normal" records only (ISO Forest clean set)
Anomaly criterion: Reconstruction error > ΞΌ + 2Ο
Output: data/anomaly_outputs/anomaly_scores.csv + country-level anomaly timeline plots
python notebooks/06_risk_model.py- Builds a composite Risk Score (0β100) from CFR, Growth Rate, Active Ratio, Doubling Time
- Labels countries:
Low/Medium/Highusing 33rd/66th percentile thresholds - Trains XGBoost classifier with 5-fold stratified cross-validation
- Generates SHAP beeswarm + bar plots for full explainability
- Produces interactive global choropleth risk map (Plotly)
Output: models/xgboost_risk.pkl, data/risk_outputs/country_risk_scores.csv, SHAP plots
Start the API server:
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000Interactive docs: http://localhost:8000/docs
LSTM-based time series forecasting.
Request:
{
"country": "India",
"days": 30
}Response:
{
"country": "India",
"model": "LSTM with Attention",
"horizon": 30,
"forecast": [
{ "date": "2024-08-01", "daily_cases": 12450 },
{ "date": "2024-08-02", "daily_cases": 11890 }
],
"summary": {
"peak_day": "2024-08-07",
"peak_cases": 14200,
"total_cases": 372000,
"avg_daily": 12400
}
}XGBoost risk classification with SHAP-backed probabilities.
Request:
{
"confirmed": 500000,
"deaths": 10000,
"recovered": 400000,
"active": 90000,
"daily_cases": 5000,
"growth_rate": 2.5,
"cfr": 2.0,
"recovery_rate": 80.0,
"active_ratio": 18.0,
"doubling_time": 30.0,
"country": "Brazil"
}Response:
{
"country": "Brazil",
"risk_category": "Medium",
"risk_score": 52.3,
"probabilities": {
"Low": 0.18,
"Medium": 0.64,
"High": 0.18
},
"risk_signals": [
"π Rapid spread detected"
],
"recommendation": "π‘ Increase testing & contact tracing"
}Isolation Forest anomaly detection for real-time outbreak monitoring.
Request:
{
"daily_cases": 85000,
"daily_deaths": 1200,
"growth_rate": 45.0,
"cfr": 1.4,
"recovery_rate": 72.0,
"case_acceleration": 12000,
"ma_7_cases": 28000
}Response:
{
"is_anomaly": true,
"severity": "ANOMALY",
"anomaly_score": -0.312,
"confidence": 87.3,
"alert_reasons": [
"Cases 3Γ above 7-day average",
"Abnormal growth rate: 45.0%",
"Rapid case acceleration detected"
],
"recommended_action": "π¨ INVESTIGATE β Possible outbreak or reporting issue"
}Full epidemiological summary for any country.
curl http://localhost:8000/summary/GermanyResponse:
{
"country": "Germany",
"last_updated": "2020-07-27",
"cumulative": { "confirmed": 206242, "deaths": 9148, "recovered": 189109 },
"rates": { "cfr": 4.434, "recovery_rate": 91.69, "growth_rate": 0.52 },
"recent_7_days": { "new_cases": 5480, "new_deaths": 42, "avg_daily": 783 },
"risk": { "category": "Low", "score": 28.5 },
"forecast_available": false
}Returns all available countries and which have LSTM forecasts.
curl http://localhost:8000/countriesRun:
streamlit run frontend/app.pyThe dashboard has 5 pages:
| Page | Content |
|---|---|
| π Global Dashboard | KPI cards, choropleth world map, pandemic timeline, top-15 bar chart |
| π Forecasting | Country selector, horizon slider, LSTM forecast chart with CI bands, data table |
| Global risk map (Low/Med/High), detailed table, custom real-time input form | |
| π¨ Anomaly Detection | Historical anomaly timeline per country, real-time anomaly checker |
| π¬ Model Analysis | RMSE/MAE comparison table, SHAP plots, confusion matrix, architecture diagram |
| Country | ARIMA RMSE | Prophet RMSE | LSTM RMSE | Best Model |
|---|---|---|---|---|
| United States | 48,240 | 31,880 | 18,420 | LSTM |
| India | 62,150 | 44,300 | 22,780 | LSTM |
| Brazil | 19,830 | 13,550 | 8,920 | LSTM |
| United Kingdom | 12,440 | 9,210 | 4,380 | LSTM |
RMSE in absolute daily case count. Lower is better.
| Metric | Score |
|---|---|
| Cross-validated Accuracy | 0.91 Β± 0.03 |
| ROC-AUC (macro OvR) | 0.96 |
| F1-Score (Low Risk) | 0.93 |
| F1-Score (Medium Risk) | 0.88 |
| F1-Score (High Risk) | 0.91 |
| Metric | Isolation Forest | LSTM Autoencoder |
|---|---|---|
| Contamination Rate | 5% (configured) | ~4.8% (learned) |
| False Positive Rate | ~12% | ~8% |
| Recall on Known Surges | 0.81 | 0.87 |
Source: COVID-19 Dataset β Kaggle (imdevskp)
| File | Description | Records |
|---|---|---|
full_grouped.csv |
Country+Province daily cases | ~47,000 |
covid_19_clean_complete.csv |
Country-level daily | ~34,000 |
worldometer_data.csv |
Latest worldometer snapshot | 187 countries |
country_wise_latest.csv |
Latest per-country summary | 187 rows |
day_wise.csv |
Global daily aggregates | ~189 days |
usa_county_wise.csv |
US county-level daily | ~380,000 |
Key statistics:
- 187 unique countries/regions
- 73 columns across all datasets
- Date range: January 2020 β July 2020
cd deployment
docker-compose up --buildServices start at:
- API:
http://localhost:8000 - Dashboard:
http://localhost:8501
- Push to GitHub
- Go to render.com β New Web Service
- Connect your repository
- Set build command:
pip install -r requirements.txt - Set start command:
uvicorn api.main:app --host 0.0.0.0 --port $PORT - Deploy
- Go to share.streamlit.io
- Connect your GitHub repo
- Set main file:
frontend/app.py - Update
API_BASEinfrontend/app.pyto your Render URL - Deploy
Create a .env file for production:
API_HOST=0.0.0.0
API_PORT=8000
LOG_LEVEL=info
MODEL_DIR=./models
DATA_DIR=./dataThe GitHub Actions pipeline (.github/workflows/ci.yml) runs on every push to main:
Push to main
β
βΌ
ββββββββββββββ ββββββββββββββ ββββββββββββββββββ
β Install βββββΆβ Tests βββββΆβ Docker Build β
β deps β β (pytest) β β + Health Checkβ
ββββββββββββββ ββββββββββββββ ββββββββββββββββββ
β
β
All pass
β
βΌ
ββββββββββββββββ
β Lint (flake8β
ββββββββββββββββ
Run tests locally:
pytest tests/ -v --tb=shortContributions are welcome. To contribute:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'Add some feature' - Push to branch:
git push origin feature/your-feature - Open a Pull Request
Please ensure:
- All tests pass:
pytest tests/ -v - Code is linted:
flake8 src/ api/ --max-line-length=100 - New features include corresponding tests
This project is licensed under the MIT License. See LICENSE for details.
- imdevskp for the COVID-19 dataset on Kaggle
- Facebook Research for the Prophet forecasting library
- Johns Hopkins CSSE for original epidemiological data
- The open-source ML community for PyTorch, XGBoost, Streamlit, and FastAPI
Built with PyTorch Β· XGBoost Β· FastAPI Β· Streamlit
Pandemic Intelligence System β Production-Grade COVID-19 AI Platform
β Star this repository if you found it useful