# mahith28/icu-mortality-real-time architecture

> Architecture diagram of the GitHub repository mahith28/icu-mortality-real-time, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mahith28/icu-mortality-real-time
- Repository: https://github.com/mahith28/icu-mortality-real-time

## Overview

This repository contains an ICU mortality prediction research pipeline: MIMIC table preparation, temporal and feature construction, separate XGBoost and LSTM modeling, and calibrated ensemble evaluation. The excerpts show subject-level train/validation/test splitting, model-specific threshold selection, prediction alignment, and final ensemble evaluation. Some preprocessing and model stages are represented by their source paths and filenames, but their internals were not sampled; with no README, links between those stages are left out where the excerpts do not establish them.

Main entry points: [`Preprocessing/05_Data_preparation.py`](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/05_Data_preparation.py) (Subject-level splits), [`lstm_clean/04_lstm_training.py`](https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/04_lstm_training.py) (Train LSTM), [`ensemble/01_prediction_geration.py`](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/01_prediction_geration.py) (Generate aligned predictions), [`Preprocessing/02_extract_vital_signals.py`](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/02_extract_vital_signals.py) (Extract vital signals)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_mimic["Load MIMIC tables"]
  node_vitals["Extract vital signals"]
  node_join["Join clinical tables<br/>[03_join_tables.py]"]
  node_windows["Five-minute windows<br/>[04_5min_window.py]"]
  node_split["Subject-level splits"]
end

subgraph group_xgb["XGBoost model"]
  node_features["Feature generation"]
  node_xgbtrain["Train XGBoost<br/>[03_xgboost.py]"]
  node_xgbthreshold["Tune XGBoost threshold"]
  node_xgbtest["Evaluate XGBoost"]
  node_decode["Decode feature vectors<br/>[feature_decode.py]"]
end

subgraph group_lstm["LSTM model"]
  node_sequences["Build sequences"]
  node_lstmtrain["Train LSTM"]
  node_lstmthreshold["Tune LSTM threshold"]
  node_shap["LSTM explanations<br/>[07_SHAP.py]"]
end

subgraph group_ensemble["Ensemble evaluation"]
  node_predictions["Generate aligned predictions"]
  node_calibration["Calibrate probabilities<br/>[03_calibration.py]"]
  node_tuning["Tune ensemble weights"]
  node_locked["Select operating threshold"]
  node_final["Evaluate ensemble"]
end

node_mimic -.-> node_vitals
node_vitals -.-> node_join
node_join -.-> node_windows
node_windows -->|"reads windows"| node_split
node_split -.-> node_features
node_features -.-> node_xgbtrain
node_xgbtrain -->|"loads model"| node_xgbthreshold
node_xgbthreshold -->|"loads threshold"| node_xgbtest
node_xgbtest -->|"calls decoder"| node_decode
node_split -.-> node_sequences
node_sequences -.-> node_lstmtrain
node_lstmtrain -.-> node_lstmthreshold
node_lstmtrain -.-> node_shap
node_predictions -.-> node_calibration
node_calibration -.-> node_tuning
node_tuning -.-> node_locked
node_locked -->|"loads locked settings"| node_final
node_predictions -.-> node_final

click node_mimic "https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/01_load_mimic_tables.py"
click node_vitals "https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/02_extract_vital_signals.py"
click node_join "https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/03_join_tables.py"
click node_windows "https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/04_5min_window.py"
click node_split "https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/05_Data_preparation.py"
click node_features "https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/00_clean_feature_generation.py"
click node_xgbtrain "https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/03_xgboost.py"
click node_xgbthreshold "https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/04_Threshold_optimization.py"
click node_xgbtest "https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/05_Test_evaluation.py"
click node_decode "https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/feature_decode.py"
click node_sequences "https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/01_sequence_data_adaptive.py"
click node_lstmtrain "https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/04_lstm_training.py"
click node_lstmthreshold "https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/05_threshold_optimization.py"
click node_shap "https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/07_SHAP.py"
click node_predictions "https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/01_prediction_geration.py"
click node_calibration "https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/03_calibration.py"
click node_tuning "https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/04_ensemble_tuning.py"
click node_locked "https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/06_ensemble_threshold.py"
click node_final "https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/08_ensemble_test_evaluation.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mimic,node_vitals,node_join,node_windows,node_split toneBlue
class node_features,node_xgbtrain,node_xgbthreshold,node_xgbtest,node_decode toneAmber
class node_sequences,node_lstmtrain,node_lstmthreshold,node_shap toneMint
class node_predictions,node_calibration,node_tuning,node_locked,node_final toneRose
```

## Components

### Data preparation

- [Load MIMIC tables](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/01_load_mimic_tables.py): `Preprocessing/01_load_mimic_tables.py`
- [Extract vital signals](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/02_extract_vital_signals.py): `Preprocessing/02_extract_vital_signals.py`
- [Join clinical tables](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/03_join_tables.py): `Preprocessing/03_join_tables.py`
- [Five-minute windows](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/04_5min_window.py): `Preprocessing/04_5min_window.py`
- [Subject-level splits](https://github.com/mahith28/icu-mortality-real-time/blob/main/Preprocessing/05_Data_preparation.py): `Preprocessing/05_Data_preparation.py`

### XGBoost model

- [Feature generation](https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/00_clean_feature_generation.py): `xgb_clean/00_clean_feature_generation.py`
- [Train XGBoost](https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/03_xgboost.py): `xgb_clean/03_xgboost.py`
- [Tune XGBoost threshold](https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/04_Threshold_optimization.py): `xgb_clean/04_Threshold_optimization.py`
- [Evaluate XGBoost](https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/05_Test_evaluation.py): `xgb_clean/05_Test_evaluation.py`
- [Decode feature vectors](https://github.com/mahith28/icu-mortality-real-time/blob/main/xgb_clean/feature_decode.py): `xgb_clean/feature_decode.py`

### LSTM model

- [Build sequences](https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/01_sequence_data_adaptive.py): `lstm_clean/01_sequence_data_adaptive.py`
- [Train LSTM](https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/04_lstm_training.py): `lstm_clean/04_lstm_training.py`
- [Tune LSTM threshold](https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/05_threshold_optimization.py): `lstm_clean/05_threshold_optimization.py`
- [LSTM explanations](https://github.com/mahith28/icu-mortality-real-time/blob/main/lstm_clean/07_SHAP.py): `lstm_clean/07_SHAP.py`

### Ensemble evaluation

- [Generate aligned predictions](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/01_prediction_geration.py): `ensemble/01_prediction_geration.py`
- [Calibrate probabilities](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/03_calibration.py): `ensemble/03_calibration.py`
- [Tune ensemble weights](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/04_ensemble_tuning.py): `ensemble/04_ensemble_tuning.py`
- [Select operating threshold](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/06_ensemble_threshold.py): `ensemble/06_ensemble_threshold.py`
- [Evaluate ensemble](https://github.com/mahith28/icu-mortality-real-time/blob/main/ensemble/08_ensemble_test_evaluation.py): `ensemble/08_ensemble_test_evaluation.py`

## Connections

- Load MIMIC tables → Extract vital signals
- Extract vital signals → Join clinical tables
- Join clinical tables → Five-minute windows
- Five-minute windows → Subject-level splits: reads windows (evidence: `Preprocessing/05_Data_preparation.py`)
- Subject-level splits → Feature generation
- Feature generation → Train XGBoost
- Train XGBoost → Tune XGBoost threshold: loads model (evidence: `xgb_clean/04_Threshold_optimization.py`)
- Tune XGBoost threshold → Evaluate XGBoost: loads threshold (evidence: `xgb_clean/05_Test_evaluation.py`)
- Evaluate XGBoost → Decode feature vectors: calls decoder (evidence: `xgb_clean/05_Test_evaluation.py`)
- Subject-level splits → Build sequences
- Build sequences → Train LSTM
- Train LSTM → Tune LSTM threshold
- Train LSTM → LSTM explanations
- Generate aligned predictions → Calibrate probabilities
- Calibrate probabilities → Tune ensemble weights
- Tune ensemble weights → Select operating threshold
- Select operating threshold → Evaluate ensemble: loads locked settings (evidence: `ensemble/08_ensemble_test_evaluation.py`)
- Generate aligned predictions → Evaluate ensemble
