Reproducibility code and SQL queries for an interpretable machine-learning model of in-hospital mortality in ICU patients with aspiration pneumonia (MIMIC-IV and eICU-CRD)
Le résumé fourni par la source
This deposit contains the complete SQL extraction queries, the Python analysis pipeline, and the deployable model artefacts that reproduce the results of a study developing and externally validating an interpretable machine-learning model for in-hospital mortality in intensive care unit patients with aspiration pneumonia. The model is developed in the MIMIC-IV v3.1 database and externally validated in the eICU Collaborative Research Database v2.0, both accessed through PhysioNet by credentialed users. The cohorts comprise adults with aspiration pneumonia (ICD-10-CM J69.0 or ICD-9-CM 507.0; or the corresponding eICU diagnosis strings), first ICU stay only, an ICU length of stay of at least 24 hours, with deaths within 24 hours of ICU admission excluded; the prediction time origin is ICU admission and all predictors are drawn from the first 24 hours. The development cohort comprises 3,756 stays (857 deaths, 22.8%) and the external-validation cohort 2,673 stays (552 deaths, 20.7%). Contents: sql/ : two BigQuery queries that build the cohorts and feature matrices. 01_mimic_cohort_and_features.sql extracts the development cohort and 42 first-24-hour predictors; 02_eicu_cohort_and_features.sql extracts the external cohort with the harmonized predictors, baseline treatments, and the native APACHE IVa predicted mortality.src/ : the Python pipeline. config.py defines the full (42-variable) and harmonized (18-variable) feature sets, fixed model hyperparameters, and the random seed; utils.py provides discrimination, calibration, and bootstrap routines; models.py defines the four algorithms (gradient boosting as the primary model, random forest, logistic regression, histogram gradient boosting). Numbered scripts run, in order: data preparation; internal five-fold cross-validation; temporal validation; external validation and calibration assessment (slope, intercept, expected calibration error); logistic recalibration evaluated out-of-sample; benchmarking against APACHE IVa, in which both instruments are recalibrated by the identical procedure on the same patients, with a paired bootstrap for the difference in AUROC; subgroup analysis; an imputation sensitivity analysis (median versus multiple imputation by chained equations); Shapley-value feature importance for either feature set; and export of the deployable model.deployable_model.joblib : the fitted 18-variable model proposed for use at a new site (TRIPOD+AI item 22). The artefact contains the gradient-boosting pipeline (median imputer and classifier), the feature list in the order the estimator expects, the eighteen development-cohort medians used to impute a missing predictor at the point of prediction, and the eICU-CRD logistic recalibration coefficients (intercept -0.599, slope 0.726). No database access is required to use it.predict_example.py : a worked example that scores one hypothetical patient with the deposited artefact, on both the original and the recalibrated probability scale, without any database access.README.md : data-access instructions, environment setup, and the exact run order.requirements.txt : the Python 3.12.9 environment. Two points about the feature sets. The full 42-feature set is the configuration intended for single-database deployment. The harmonized 18-variable set contains only those predictors that map consistently to eICU-CRD and is the configuration used for external validation and for the deployable model; peripheral oxygen saturation is deliberately excluded from it, because it is absent from the eICU-CRD APACHE physiology variables and would have to be imputed to a constant across the entire external cohort, contributing no external information. The recalibration coefficients bundled with the deployable artefact were estimated in eICU-CRD and are supplied for reference. A new site should re-estimate them on its own outcome data before using the absolute risk scale; that is the central recommendation of the paper. Because logistic recalibration is a monotonic transformation, the rank ordering of patients, and therefore discrimination, is unchanged by it. The databases themselves are not redistributed; they are obtained from PhysioNet under its credentialing and data use agreement. Running the queries and then the scripts in the documented order regenerates the cohorts, all reported performance and calibration metrics, the recalibration equation, the APACHE IVa comparison, the subgroup results, the imputation sensitivity result, and the feature-importance ranking. Random seeds are fixed throughout (RANDOM_SEED = 42 in config.py), so a re-run in the documented environment is deterministic; small last-digit differences may arise across library versions or platforms, and do not affect any ranking or any reported conclusion.
Ce résumé expose les affirmations des auteurs. BNTIC ne l’interprète pas comme une validation indépendante des résultats.