This study was performed in line with the principles of the Declaration of Helsinki. Approval was granted by the Ethics Committee of Binhai County People's Hospital (Approval No. 2024-BHKYLL-055).
Methodology
Patients
We retrospectively enrolled 1,999 adults diagnosed with acute cholangitis at two centers between January 2020 and August 2024: Binhai County People's Hospital and Huai'an Second People's Hospital. Of these patients, 1,561 were managed in general wards, and 438 were admitted to the ICU. The study protocol was approved by the Ethics Committee of Binhai County People's Hospital (Approval No. 2024-BHKYLL-055). Written informed consent was obtained from each participant or a legally authorized representative.
Patients were eligible if they (1) had a physician-confirmed diagnosis of acute cholangitis, (2) were aged 18 years or older, and (3) had complete medical records and follow-up data for the relevant outcome.
Patients were excluded if they (1) had a concurrent malignancy expected to substantially affect survival, (2) were unable to provide informed consent, or (3) were lost to follow-up.
Clinical data collection and follow-up
Clinical characteristics and laboratory data were retrospectively extracted from the medical records of Binhai County People's Hospital and Huai'an Second People's Hospital. Demographic and medical-history variables included sex, age, cardiovascular disease, diabetes, hepatitis, cirrhosis, hyperlipidemia, and stroke. The first available laboratory measurements after admission to the general ward or ICU included white blood cell count (WBC), platelet count (PLT), hemoglobin (Hb), albumin, sodium, potassium, chloride, lactate (Lac), total bilirubin (TBil), alanine aminotransferase (ALT), aspartate aminotransferase (AST), creatinine (CR), and blood urea nitrogen (BUN). Recorded interventions included biliary stent placement, endoscopic retrograde cholangiopancreatography (ERCP), and percutaneous drainage. Disease-severity measures included the SOFA score, APS III, and the requirement for mechanical ventilation. Blood specimens were processed using standardized automated laboratory procedures. Patients discharged alive were followed through outpatient visits or telephone contact when follow-up was required. Sepsis status was assessed throughout hospitalization according to Sepsis-3 criteria; the sepsis group therefore included patients with sepsis at admission and those who developed sepsis later. Because the exact onset time of sepsis was unavailable and hospital length of stay was retained in the final general-ward sepsis model, a uniform prospective admission-time prediction landmark could not be established for that model. It should therefore be interpreted as a retrospective in-hospital risk-stratification model.
Outcome
The study evaluated three related but distinct prediction tasks. The primary outcome was sepsis status during hospitalization among general-ward patients with acute cholangitis, as determined using Sepsis-3 criteria. The secondary outcomes were all-cause in-hospital mortality in the general-ward cohort, defined as death before discharge, and all-cause 28-day mortality in the ICU cohort, defined as death within 28 days after ICU admission.
Statistical analysis
The distribution of each continuous variable was assessed using the Shapiro-Wilk test. Normally distributed variables were presented as the mean ± standard deviation and were compared using the independent-samples Student's t-test; Welch's t-test was used when the homogeneity-of-variance assumption was not met. Non-normally distributed variables were presented as the median and interquartile range (IQR) and were compared using the Wilcoxon rank-sum test. Categorical variables were presented as counts and percentages and compared using the chi-square or Fisher's exact test, as appropriate. All tests were two-sided, and P < 0.05 was considered statistically significant.
Patients were stratified according to the presence or absence of sepsis. In the general-ward cohort, multivariable logistic regression was used to identify factors associated with sepsis; results are reported as odds ratios (ORs) with 95% confidence intervals (CIs). Kaplan-Meier curves and log-rank tests were used to compare in-hospital survival in the general-ward cohort and 28-day survival in the ICU cohort between patients with and without sepsis. Cox proportional hazards models were fitted separately for the two cohorts, and results are reported as hazard ratios (HRs) with 95% CIs.
Four progressively adjusted Cox models were constructed. Model 1 was unadjusted. Model 2 was adjusted for age and sex. Model 3 was additionally adjusted for hypertension, diabetes, heart failure, stroke, and kidney injury. In the general-ward cohort, Model 4 was further adjusted for WBC, Hb, PLT, albumin, CR, BUN, AST, ALT, sodium, potassium, chloride, and Lac. In the ICU cohort, Model 4 additionally included APS III and SOFA because these severity scores were available only for ICU patients.
For each prediction task, a fixed random seed of 500 was used to divide the corresponding complete-case dataset into training and internal-validation cohorts at a 7:3 ratio. All feature-selection procedures were conducted exclusively in the training cohort; the internal-validation cohort was not used for predictor selection. Within the training cohort, LASSO regression with 10-fold cross-validation and the Boruta algorithm were used to identify candidate predictors. For LASSO, predictors with nonzero coefficients at lambda.min were retained. Boruta was run independently for up to 5,000 iterations. The resulting candidate predictors were used consistently to develop four models for each task: LR, RF, SVM, and XGBoost. Binary clinical variables were encoded as 0 or 1. No manual normalization or transformation was applied before fitting LR, RF, or XGBoost. Scaling for LASSO and SVM followed the default settings of their respective software implementations, and preprocessing parameters derived from the training cohort were applied unchanged to the internal validation cohort. No oversampling, undersampling, synthetic minority oversampling technique, or manually specified class weighting was used. The best-performing model was defined as the model with the highest overall internal-validation performance among the four prespecified implementations, rather than a fully optimized version of each algorithm. The fitted training-cohort models were then evaluated in the internal-validation cohort. The complete workflow is shown in Supplementary Figure 1, and implementation details are provided in Supplementary Table 1.
Model performance was evaluated using the area under the receiver operating characteristic curve (AUC), sensitivity, specificity, recall, F1 score, and accuracy. AUC summarizes discrimination across all possible classification thresholds, with 0.5 indicating no discrimination and 1.0 indicating perfect discrimination. At the selected threshold, true positives (TP) and true negatives (TN) were correctly classified positive and negative cases, whereas false positives (FP) and false negatives (FN) were incorrectly classified cases. Sensitivity, equivalent to recall in binary classification, was calculated as TP/(TP + FN); specificity as TN/(TN + FP); precision as TP/(TP + FP); F1 score as 2 × precision × recall/(precision + recall); and accuracy as (TP + TN)/(TP + TN + FP + FN). The positive classes were sepsis (coded as 1) for the general-ward sepsis prediction model, in-hospital death (coded as 1) for the general-ward in-hospital mortality model, and death within 28 days (coded as 1) for the ICU 28-day mortality model. The corresponding negative classes were absence of sepsis, discharge alive, and survival at 28 days (all coded as 0), respectively.
Four supervised machine-learning algorithms were selected to represent complementary strategies for structured clinical data. LR served as an interpretable reference model for additive linear associations. RF represented a bagging-based ensemble capable of modeling nonlinear relationships and interactions while reducing variance. SVM represented a margin-based classifier capable of accommodating nonlinear decision boundaries in moderately sized datasets. XGBoost represented a regularized boosting algorithm capable of capturing higher-order interactions and nonlinear patterns. All algorithms used the same candidate predictor set and were evaluated in the same training and internal-validation cohorts for each prediction task.
SHAP analysis was performed for the best-performing model for each outcome to quantify global feature importance and explain individual predictions. Nomogram development followed outcome-specific procedures. For the general-ward sepsis outcome, candidate predictors were entered into a multivariable logistic regression model, and variables that remained statistically significant at P < 0.05 were incorporated into the final nomogram. For the two mortality outcomes, predictor inclusion was based on the global SHAP feature-importance results of the corresponding best-performing models, without additional P-value-based elimination.
During retrospective database assembly, records missing clinical, laboratory, or outcome data required for the relevant analysis were excluded before entry into the final analytical dataset. A detailed pre-entry screening log was not retained; therefore, the number of records excluded due to missing data and the original variable-level patterns of missingness could not be reconstructed. The finalized general-ward cohort (n = 1,561) and ICU cohort (n = 438) contained no missing values for the variables used in the corresponding analyses (0% missing), and no statistical imputation was performed. All 1,561 general-ward patients were included in the sepsis and in-hospital mortality analyses, and all 438 ICU patients were included in the 28-day mortality analysis. Variable-level completeness in the finalized datasets is reported in Supplementary Table 2.
Machine-learning analyses were conducted using the machine-learning analysis platform. Conventional statistical analyses were performed using an open-source statistical computing environment and Statistical software. All statistical tests were two-sided, and P < 0.05 was considered statistically significant.