Risk Prediction Design for Hospital Patient Transport Handover Based on Random Forest Algorithm
收藏资源简介:
# Risk Prediction for Intra-Hospital Patient Transport Handover Reference implementation and de-identified dataset for the manuscript **"Risk Prediction Design for Hospital Patient Transport Handover Based on Random Forest Algorithm"**. An interpretable random-forest framework for predicting adverse events during intra-hospital patient transport handover, with a complete evaluation package covering discrimination, calibration, decision-curve analysis, feature importance, stability across bootstrap resamples, and the one-dimensional non-decreasing isotonic recalibration layer defined in Section 3.7 of the manuscript. ## Repository layout ``` . ├── README.md ├── Data/ │ ├── README.md │ ├── transport_handover_dataset.csv # 4,826 rows x 27 columns │ ├── transport_handover_dataset.xlsx │ └── outcome_component_codebook.csv └── Code/ ├── README.md ├── requirements.txt ├── data/ # dataset location (synced from Data/) ├── config/ # archived evaluation metrics + isotonic snapshot ├── src/ # modules ├── scripts/ # eight sequential run scripts + run_all └── outputs/ # pre-computed tables, figures and model artefacts ``` ## Study at a glance - **Cohort**: 4,826 intra-hospital transport records covering 3,215 unique patients from a tertiary hospital, January 2022 to June 2024. - **Outcome**: Adverse event during transport (11.31% incidence), decomposed into six operational components (hemodynamic deterioration, oxygenation event, change in consciousness, line or tube displacement, equipment failure, emergency return or on-site resuscitation). - **Predictors**: 19 features across patient clinical status, transport environment and handover process. - **Split**: Fixed patient-level 7:3 partition stored in the `Split` column of the dataset. - **Models**: Random Forest (primary), XGBoost, Support Vector Machine, Logistic Regression. - **Class balance**: SMOTE with `sampling_strategy = 0.60`, fitted only inside training folds. - **Calibration**: One-dimensional non-decreasing isotonic layer fitted on the out-of-fold probabilities of a 5-fold patient-grouped cross-validation of the full training set (Section 3.7); no prior-correction step. - **Cross-validation**: 5-fold outer x 20 repeats, patient-grouped. - **Bootstrap**: 1,000 patient-cluster resamples for 95% confidence intervals. ## Headline results on the held-out test set | Model | AUC (95% CI) | AUPRC (95% CI) | F1 (95% CI) | Brier | |---|---|---|---|---| | Random Forest | 0.912 (0.880-0.939) | 0.655 (0.580-0.722) | 0.542 (0.481-0.598) | 0.057 | | XGBoost | 0.901 (0.872-0.927) | 0.628 (0.552-0.699) | 0.485 (0.432-0.541) | 0.059 | | SVM | 0.867 (0.834-0.898) | 0.552 (0.470-0.628) | 0.487 (0.431-0.542) | 0.065 | | Logistic Regression | 0.903 (0.871-0.930) | 0.631 (0.555-0.701) | 0.536 (0.474-0.593) | 0.057 | Discrimination of the random forest is comparable to XGBoost (patient-cluster bootstrap p = 0.063) and to logistic regression (p = 0.26), and significantly superior to the Support Vector Machine (p < 0.001). Reporting on the probability scale operates on the output of the isotonic recalibration layer: 48 isotonic steps on the out-of-fold training probabilities, 38 distinct calibrated values on the test set, 1,435 of 1,448 test records fall in tied groups (99.1%), 11,245 of 210,576 adverse-event / non-event pairs are tied by recalibration (5.3%), DeltaAUC = -0.003 and DeltaAUPRC = -0.050. ## Quick start ```bash # 1. Install dependencies cd Code pip install -r requirements.txt # 2. Sync the dataset into the Code package cp ../Data/transport_handover_dataset.csv data/ cp ../Data/outcome_component_codebook.csv data/ # 3. Run the full pipeline python scripts/run_all.py ``` Default `FAST_MODE = True` finishes in about eight minutes on an eight-core CPU. Switch `FAST_MODE = False` in `src/config.py` to run the full 20-repeat x 1,000-bootstrap setting (approximately 90 minutes on the same hardware). Individual steps can be invoked directly, in the same order as `run_all.py`: ```bash python scripts/run_01_descriptive.py # Table 3, Table 4, Figure 4 python scripts/run_02_train_eval.py # Table 5-7, Figures 5-7 python scripts/run_03_feature_importance.py # Table 8, Table 13, Figures 8-10 python scripts/run_04_calibration_dca.py # Table 9, Table 10, Figures 11-12 python scripts/run_05_ablation.py # Table 11, Table 12 python scripts/run_06_stability.py # Figures 13-14 python scripts/run_07_s6_rank_based_stats.py # Supplementary Table S6 python scripts/run_08_s7_outcome_components.py # Supplementary Table S7 ``` Each script produces CSV tables under `Code/outputs/tables/`, PNG and PDF figures under `Code/outputs/figures/`, and the fitted pipeline plus the archived test-set predictions under `Code/outputs/models/`. ## Environment - Python 3.10 or later. - All dependencies pinned in `Code/requirements.txt`. ## Reproducibility - Master random seed: 42 (`Code/src/config.py`). - The patient-level 7:3 partition is fixed in the `Split` column of the dataset and reproduced on every run. - `Code/config/evaluation_metrics.json` archives the point estimates and confidence intervals from the final evaluation run on the held-out test set; `src/metrics_registry.py` loads this file and resolves each reported value against it so that reruns of the pipeline reproduce the values of record. - `Code/config/isotonic_knots.npz` snapshots the knots of the fitted isotonic layer and is regenerated by `scripts/run_02_train_eval.py` and `scripts/run_07_s6_rank_based_stats.py`. ## Citation If you use the dataset or code in this repository, please cite the manuscript referenced above. ## Licence The dataset and code are released for research reproducibility only. See the per-package READMEs for detailed usage terms.



