Objective To investigate the application value of unsupervised machine learning-based clinical phenotypic classification in predicting the risk of early cholecystitis after endoscopic retrograde cholangiopancreatography (ERCP), and to construct an individualized risk prediction model using supervised machine learning approaches.
Methods The prospective cohort study was conducted. The clinical data of 1 019 patients undergoing ERCP in 4 medical centers, including The First Hospital of Lanzhou University et al, from February 2020 to October 2023 were selected. All 1 019 patients were divided into a training set (715 cases) and an internal validation set (304 cases) at a ratio of 7∶3 using the random number table method. The training set was used for the construc-tion of predictive model, and the internal validation set was used for model verification. An indepen-dent external validation set comprising 110 patients undergoing ERCP for choledocholithiasis who were admitted to The First Hospital of Lanzhou University from December 2023 to December 2024 was used for external validation of the prediction model. The unsupervised phenotypic clustering was used for the classification of 3 different clinical phenotypes of 1 019 patients. Observation indicators: (1) grouping of enrolled patients and postoperative complications; (2) unsupervised clustering analysis; (3) screening core variables distinguishing clinical phenotypes; (4) construction of a clinical decision tree; (5) construction of an individualized risk prediction model for early cholecystitis after ERCP. Normality of data was assessed using the Shapiro-Wilk test. Comparison of measurement data with normal distribution among multiple groups was conducted using the ANOVA. Comparison of measurement data with skewed distribution between groups was conducted using the Mann-Whitney U test or Kruskal‑Wallis H test. Comparison of count data between groups was conducted using the Pearson chi‑square test or Fisher exact probability. Univariate stepwise Logistic regression and random forest algorithms were employed for predictor screening. Machine learning-based predictive models were established with visualized output. Receiver operating characteristic (ROC) curves were plotted, and the area under the curve (AUC), sensitivity, specificity, and negative predictive value (NPV) were calculated. The performance of predictive models was assessed using the Delong test, Hosmer-Lemeshow test, and decision curve.
Results (1) Grouping of enrolled patients and postoperative complications: a total of 1 019 eligible patients who underwent ERCP for choledocholithiasis were selected. There were 581 males and 438 females, aged (60±16) years. Of the 1 019 patients, 75 cases developed cholecystitis after ERCP, including 66 cases developing early cholecystitis and 9 cases developing delayed‑onset cholecystitis. (2) Unsupervised clustering analysis: based on the unsupervised clustering analysis, 1 019 patients were classified as phenotype 1 (381 cases), phenotype 2 (489 cases), and phenotype 3 (149 cases). The incidences of early cholecystitis after ERCP were 8.40%(32/381) in cases of phenotype 1, 4.50%(22/489) in cases of phenotype 2, and 8.05%(12/149) in cases of phenotype 3, showing a significant difference among them (χ²=6.093, P<0.05). The incidences of acute obstructive suppurative cholangitis were 4.46%(17/381) in cases of phenotype 1, 1.02% (5/489) in cases of phenotype 2, and 3.36%(5/149) in cases of phenotype 3, showing a significant difference among them (χ²=10.158, P<0.05). (3) Screening core variables distinguishing clinical phenotypes: a total of 14 core predictive variables for further differentiation of clinical phenotypes were ultimately identified. (4) Construction of a clinical decision tree: based on the clinical phenotype and regression tree algorithm, a clinical decision pathway was generated using the 14 core variables as input nodes. (5) Construction of an individualized risk predictive model for early cholecystitis after ERCP: results of univariate analysis were incorporated into a random forest model, and a risk predictive model was constructed based on the top six variables. Performance evaluation of the predictive model demonstrated that the AUC of predictive model were 0.982 (95% confidence interval as 0.974-0.993) in the training set and 0.902 (95% confidence interval as 0.799-1.000) in the internal validation set, respectively. The optimal prediction proba-bility thresholds based on the Youden index derived from platt scaling were 0.162 and 0.103, respectively, with corresponding sensitivity of 0.921 and 0.895, specificity of 0.963 and 0.877, and NPV of 0.991 and 0.990. DeLong test showed that there was no significant difference in AUC between the training set and the internal validation set (Z=1.554, P>0.05). The Hosmer‑Lemeshow test showed a acceptable goodness‑of‑fit in the internal validation set (χ²=5.963, P>0.05). Decision curve analysis showed a substantial clinical net benefit across a threshold probability range of 2%-70%. When the clinical decision threshold exceeded 40%, the negative predictive value of the model approached 100%. In the 110 patients of the external validation set, the prediction model achieved an AUC of 0.886 (95% confidence interval as 0.782-0.991), with sensitivity of 0.714, specificity of 0.806, and NPV of 0.981.
Conclusions Patients with choledocholithiasis undergoing ERCP are divided into 3 distinct clinical phenotypes based on unsupervised machine learning, among which cases of phenotype 1 and phenotype 3 represent high-incidence sub population for early cholecystitis. The individualized prediction model incorporating phenotypic labels demonstrates satisfactory discri-minative capacity and high negative predictive value.