Skip to content

About

Sepsis is one of the deadliest and most costly conditions in hospitals. Our goal was to build a system that alerts nurses and doctors to a deteriorating patient before clinical symptoms appear, providing a critical window for intervention.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

A Real-Time Early Warning System for ICU Sepsis Prediction

Using a Heterogeneous Stacking Ensemble (Super Learner)

Open In Colab Python 3.8+ PyTorch Scikit-Learn PhysioNet Challenge 2019

Authors: Abdullah Al Noman, Md. Zawad Al Mahir, Md. Rakibul Islam, Mahathir Mohammad
Department of Computer Science and Engineering, United International University, Dhaka, Bangladesh
Corresponding Email: iamnoman.swe@gmail.com


1. Project Overview

This repository contains the publication-grade codebase, experimental benchmarks, and clinical models for an advanced ICU Sepsis Early Warning System. Using the full PhysioNet/Computing in Cardiology Challenge 2019 dataset ($1,552,113$ hourly observations across $40,333$ ICU admissions), our framework combines dynamic temporal feature engineering with a Heterogeneous Stacking Super-Learner to predict sepsis onset well in advance of overt clinical diagnosis.

System Architecture Diagram

Key Breakthroughs:

  • AUROC: 0.8060 on an independent holdout test cohort of $8,067$ unseen patients ($308,785$ hourly records).
  • Official PhysioNet 2019 Clinical Utility Score ($U_{norm}$): 0.3435 (matches top international challenge benchmarks).
  • Probability Calibration: Reduced Brier loss from $0.1258$ to 0.0169 using Platt scaling.
  • Clinical Lead Time: Delivers proactive early warning alarms with an empirical median advance lead time of 31.5 hours (mean 51.2 hours) prior to overt clinical diagnosis across 577 unseen sepsis patients.
  • Multi-Paradigm Tournament Stacking: Blends 5 distinct algorithmic families:
    1. Linear Discriminative: $L_2$ Regularized Logistic Regression
    2. Bootstrap Bagging: Random Forest (100 Trees)
    3. Depth-wise Gradient Boosting: Histogram XGBoost
    4. Leaf-wise Gradient Boosting: LightGBM
    5. Connectionist Deep Learning: Custom PyTorch DeepNet with BatchNorm & Dropout

2. Directory Structure

Sepsis_Prediction_Model/
│
├── Sepsis_SuperLearner_Publication_Colab.ipynb # Primary Colab Jupyter notebook
├── README.md                            # Project documentation & guide
├── requirements.txt                     # Project dependencies
│
├── figures/                             # 300 DPI Publication-Grade Figures (Stacking Super-Learner)
│   ├── system_architecture.png          # System architecture diagram (Figure 1)
│   ├── master_stacking_roc_comparison.png # Multi-model ROC curves (Figure 2)
│   ├── precision_recall_curve.png       # Precision-Recall curves (Figure 3)
│   ├── calibration_curve.png            # Platt calibration reliability diagram (Figure 4)
│   ├── decision_curve_analysis.png      # Net clinical benefit curves (DCA) (Figure 5)
│   ├── early_warning_distribution.png   # Lead time histogram & KDE distribution (Figure 6)
│   ├── shap_summary.png                 # Game-theoretic SHAP feature impact (Figure 7)
│   └── legacy/                          # Archived early exploratory / single-model plots
│
├── data/                                # Clean Project Datasets
│   ├── processed_sepsis_data_FULL.csv   # Combined 1.55M preprocessed dataset (Git LFS)
│   └── processed_sepsis_data_FULL.csv.gz# Compressed dataset (direct download & pandas support)
│
├── notebooks/                           # Jupyter & Colab Notebooks
│   ├── Sepsis_SuperLearner_Publication_Colab.ipynb # Primary publication notebook
│   └── Sepsis_Detection_Colab_legacy.ipynb        # Archived early baseline version
│
├── models/                              # Trained Model Checkpoints & Scalers
│   ├── xgb_model.pkl                    # Base XGBoost classifier
│   ├── xgboost_model_advanced.pkl       # Hyper-tuned XGBoost model
│   └── rf_model.pkl                     # Random Forest baseline
│
├── reports/                             # Generated Scientific Evaluation Tables
│   ├── table_stacking_ensemble_benchmark.csv # Multi-paradigm tournament table
│   ├── table_ablation_study.csv              # 4-stage ablation study metrics
│   ├── table_cross_validation_results.csv    # 5-fold patient cross-validation
│   └── table_model_benchmarks.csv            # Baseline comparisons
│
└── scripts/                             # Core Python Experiment Scripts
    ├── train_hybrid_stacking_ensemble.py     # End-to-end Stacking Super Learner pipeline
    ├── run_publication_experiments.py        # Benchmark, ablation, and DCA runner
    ├── evaluate_sepsis_score.py              # Official PhysioNet 2019 scoring utility
    ├── generate_system_architecture_figure.py# System diagram generator
    └── download_physionet.py                 # PhysioNet 2019 dataset downloader

3. Quick Start & Local Execution

Environment Setup

Install the required dependencies:

pip install -r requirements.txt

Running Experiment Scripts

  1. Download PhysioNet Challenge 2019 Data (Optional if using processed data):
    python scripts/download_physionet.py
  2. Train the Stacking Super Learner Pipeline:
    python scripts/train_hybrid_stacking_ensemble.py
  3. Execute Full Benchmarking, Cross-Validation & DCA:
    python scripts/run_publication_experiments.py
  4. Regenerate Publication System Architecture:
    python scripts/generate_system_architecture_figure.py

4. How to Run in Google Colab

You can run the full publication experiment pipeline with GPU acceleration on Google Colab:

Open In Colab

  1. Click the Open In Colab badge above or open Google Colab.
  2. Open notebooks/Sepsis_SuperLearner_Publication_Colab.ipynb.
  3. In Cell 1, mount your Google Drive:
    from google.colab import drive
    drive.mount('/content/drive')
  4. Place data/processed_sepsis_data_FULL.csv (or .csv.gz) in your Google Drive under /content/drive/MyDrive/Sepsis_Detection_Project/.
  5. Select Runtime -> Run all. The notebook will train all 5 models, optimize the stacking meta-learner, and export all figures and tables directly to your Drive.

5. Multi-Paradigm Benchmark Tournament

The tournament evaluates 5 distinct machine learning paradigms against standard clinical bedside scoring (qSOFA) across $8,067$ unseen ICU patients ($308,785$ hourly test observations, $5,515$ sepsis-positive hours):

Model Paradigm AUROC AUPRC Recall Precision F1-Score Brier Loss PhysioNet Utility ($U_{norm}$)
qSOFA Baseline ($\ge 2$) 0.5784 0.0223 0.0696 0.0352 0.0468 0.1216 0.0160
Logistic Regression ($L_2$) 0.7317 0.0706 0.6082 0.0419 0.0784 0.1988 0.2103
Random Forest (100 Trees) 0.7786 0.0791 0.3944 0.0915 0.1485 0.1137 0.2875
PyTorch DeepNet 0.7871 0.0901 0.6983 0.0443 0.0833 0.1874 0.2655
Histogram XGBoost 0.7940 0.0979 0.5634 0.0646 0.1158 0.1231 0.3312
LightGBM 0.7995 0.0936 0.6067 0.0593 0.1080 0.1328 0.3322
Proposed Stacking Super Learner ($\tau=0.60$) 0.8060 0.0985 0.5692 0.0665 0.1192 0.0169* 0.3435

*Brier score after Platt probability calibration (uncalibrated stacking Brier loss: 0.1709).


6. Discrimination & Precision-Recall Performance

The Stacking Super Learner outperforms all individual base algorithms, breaking the $0.80$ AUROC barrier on unseen ICU patients while maximizing precision at clinically relevant operational recall levels:

Multi-Model ROC Comparison Precision-Recall Curves


7. Probability Calibration & Decision Curve Analysis (DCA)

  • Reliability Diagram: Raw tree-based and neural predictions suffer from overconfidence. Platt sigmoid scaling successfully aligns predicted risks with true ICU incidence, slashing Brier error from $0.1258$ to 0.0169.
  • Decision Curve Analysis (Net Clinical Benefit): Evaluates clinical utility across bedside intervention probability thresholds ($p_t \in [0.01, 0.20]$). The Super Learner delivers positive net clinical benefit far superior to treat-all and treat-none baselines across all relevant clinical decision thresholds.

Platt Calibration Curve Decision Curve Analysis


8. Early Warning Lead Time & Explainability (SHAP)

  • Clinical Advance Lead Time: Retrospective simulation across 577 unseen test patients diagnosed with sepsis demonstrates an empirical median lead time of 31.5 hours (mean 51.2 hours) prior to overt clinical shock. Over 50% of patients trigger alerts $>30$ hours early, providing a vital window for antibiotic initiation, blood cultures, and fluid resuscitation.
  • Pathophysiological Explainability: TreeSHAP feature attributions ground model decisions in classical hallmarks of septic shock—elevated maximum heart rate, collapsing minimum mean arterial pressure ($\text{MAP}_{\min}$), and severe Shock Index spikes.

Early Warning Lead Time Distribution SHAP Feature Importance


9. Citation & Contact

If you find this repository, models, or findings useful in your research, please cite:

@inproceedings{noman2026sepsis,
  title={A Real-Time Early Warning System for ICU Sepsis Prediction Using a Heterogeneous Stacking Ensemble},
  author={Noman, Abdullah Al and Mahir, Md. Zawad Al and Islam, Md. Rakibul and Mohammad, Mahathir},
  booktitle={Department of Computer Science and Engineering, United International University},
  year={2026}
}

For questions or collaborative research, please reach out to:
Abdullah Al Noman: iamnoman.swe@gmail.com

About

Sepsis is one of the deadliest and most costly conditions in hospitals. Our goal was to build a system that alerts nurses and doctors to a deteriorating patient before clinical symptoms appear, providing a critical window for intervention.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages