Establishment of a postoperative delirium risk prediction model for elderly hip fracture patients based on machine learning algorithms Authors: Yayun Xing, Yuetong Wang, Yuejiao Huang, Fanguo Lin, Yuye Zhang Published: 2025 ABSTRACT AbstractBackgroundAlthough no definitive treatment exists, 30–40% of postoperative delirium cases are preventable through early risk identification and intervention. Therefore our aim was to develop and evaluate a postoperative delirium risk prediction model for elderly hip fracture patients using machine learning algorithms.MethodsA retrospective analysis was conducted on the clinical data of elderly hip fracture patients who underwent surgical treatment at our hospital from June 2022 to December 2024. Postoperative delirium occurrence was set as the outcome variable. Six machine learning algorithms, including logistic regression, random forest, decision tree, CatBoost, balanced bagging classifier and XGBoost, were used to build the risk prediction models for postoperative delirium. The model-building process included data preprocessing, feature selection, and hyperparameter tuning through grid search, with 10-fold cross-validation for internal validation. The model performance was evaluated using AUC, accuracy, precision, sensitivity, specificity, and F1 score, and the optimal model was selected.ResultsA total of 801 hip fracture patients were included in the model construction, among which 211 patients developed delirium, with an incidence rate of 26.3%. Among the six models, the CatBoost model demonstrated the best overall performance, with AUC values of 0.976 for the test set and 0.871 for the validation set. It also maintained high sensitivity (0.846) and specificity (0.686). Based on the CatBoost model, the risk factors for postoperative delirium in elderly hip fracture patients were identified as preoperative, intraoperative, and postoperative oxygen saturation, preoperative blood glucose levels, preoperative fasting time, preoperative albumin levels, nutritional status, VAS, and preoperative serum creatinine levels.ConclusionThe postoperative delirium risk prediction model for elderly hip fracture patients, developed using machine learning, demonstrates good performance and can provide precise, individualized predictions.Keywords: Postoperative delirium, Risk prediction model, Elderly hip fracture, Machine learning algorithms Introduction Hip fractures occur around the hip joint (such as the femoral neck, intertrochanteric, and subtrochanteric regions), and are commonly seen in elderly individuals, often resulting from low-energy trauma [1]. With global aging and a significant increase in life expectancy, hip fractures have become one of the major health concerns. It is estimated that by 2050, there will be approximately 6.3 million elderly patients with hip fractures worldwide [2]. The one-month mortality rate after a hip fracture is 8%−10%, and the one-year mortality rate can reach 20%−40%, making it characterized by high incidence, high disability rate, and high mortality rate [3]. Surgery is the main treatment for elderly hip fracture patients. Early functional exercises post-surgery can effectively prevent fatal complications, such as pneumonia and deep vein thrombosis in the lower extremities. Additionally, surgical treatment can significantly improve the patient’s quality of life and reduce the burden on society and families. Delirium is an acute, fluctuating mental status change characterized by reduced consciousness and attention disturbances, caused by multiple factors [4, 5]. It typically occurs within five days after surgery. Delirium is closely related to the prognosis of hip fracture patients, as it not only affects long-term cognitive recovery but also increases the risk of other severe complications, ultimately contributing to higher disability and mortality rates [6, 7]. Currently, there is no clear and effective treatment for postoperative delirium. However, studies show that [8] 30%−40% of postoperative delirium cases are preventable, and effective prevention requires timely identification of high-risk patients and the implementation of targeted interventions. With the development of research, new algorithms and technologies have emerged, one of which is machine learning. Machine learning can extract key factors from vast amounts of data, identify underlying patterns, and predict future trends [9]. In recent years, machine learning has been widely used in disease diagnosis, treatment, prognosis, and other aspects, driving the development of medical informatization and modernization [10, 11]. For example, Deep et al. applied machine learning algorithms in cancer prognosis management, and the results showed that the algorithm could effectively predict cancer recurrence and prognosis [10]. Teagan et al. introduced machine learning algorithms to predict the risk of diabetic foot, and the algorithm accurately calculated the risk, allowing for timely intervention and significantly reducing the incidence of diabetic foot [11]. Therefore, this study aims to identify the risk factors for postoperative delirium in elderly hip fracture patients using machine learning algorithms and to construct a risk prediction model for postoperative delirium, providing an effective assessment tool for clinical decision-making. Methods Patient population This is a retrospective study that does not involve patient privacy. This retrospective study is registered on ClinicalTrials.gov (NCT07121309) and has been approved by the Institutional Ethics Committee (JD-HG-2025-022). The study collected data from 801 elderly patients with hip fractures who underwent surgical treatment at our hospital from June 2022 to September 2024 through electronic medical record queries. The data was used to establish a model. Additionally, 100 elderly hip fracture patients from October 2024 to December 2024 were selected for external validation of the model. Inclusion criteria: Age ≥ 60 years; diagnosed with hip fracture by X-ray; patients who underwent surgical treatment. Exclusion criteria: Patients with other severe diseases (“Severe disease” is now defined in the manuscript as ASA ≥ IV or any end-stage condition/major organ failure—including terminal malignancy, NYHA IV heart failure, Child–Pugh C hepatic failure, multiple-organ dysfunction, or acute stroke with persistent deficits.); patients with mental disorders; patients participating in other studies. An a priori power analysis was conducted in G*Power 3.1.9.7 using logistic regression (Wald test; two-tailed), assuming an event rate of π1 = 0.35 (based on published postoperative delirium rates of 25–45%), a minimum clinically important effect of OR = 1.50 for a key binary predictor, 10 pre-specified predictors, α = 0.05, and power (1 − β) = 0.80. Under these assumptions, the required minimum total sample size was N = 893; our study enrolled 901 patients (training = 801; test = 100), thereby meeting this criterion. Data collection Based on previous literature and clinical experience, patient personal and clinical data were collected through the hospital information management system (HIS). All experimental data have been desensitized, and the specifics are as follows: Patient demographic data The general data of patients included as study variables in this research encompass age, gender, educational level, living conditions, and so on. Clinical variables Clinical data: course of illness, BMI index, surgery duration, anesthesia method, intraoperative blood loss, preoperative frailty, preoperative blood glucose level, preoperative albumin, nutritional status, preoperative anemia, cognitive function, preoperative fasting time, Visual Analogue Scale (VAS), history of sedative use, whether a drainage tube was placed, preoperative serum creatinine level, presence of sleep disorders, preoperative pulse oximetry, intraoperative pulse oximetry, and postoperative pulse oximetry. Frailty was assessed using the Tilburg Frailty Index (TFI), a 15-item questionnaire that covers three domains: physical (8 items), psychological (4 items), and social (3 items). Items are scored dichotomously (0 = no, 1 = yes), with a total score ranging from 0 to 15. A score of ≥ 5 indicates frailty. Pre-operative sleep quality was measured using the Pittsburgh Sleep Quality Index (PSQI), which includes seven components: subjective sleep quality, sleep latency, sleep duration, habitual sleep efficiency, sleep disturbances, use of sleep medication, and daytime dysfunction. Each component is rated on a scale from 0 to 3, with a total score ranging from 0 to 21. A score > 7 indicates clinically significant sleep disturbances.Pre-operative SpO2 was recorded three times per day (08:00, 14:00, and 20:00) on each day from admission until surgery, and the mean of these readings was used; Intra-operative SpO2 was captured continuously via pulse oximetry from anaesthetic induction through skin closure, with values automatically stored every 30 min by the anaesthesia information system, then averaged for analysis; and Post-operative SpO2 was likewise recorded every 30 min on the ward’s telemetry system from arrival in the recovery room until 72 h after surgery, after which a time-weighted mean was calculated. The criteria for postoperative delirium assessment Outcome assessment: Delirium was screened with the 3-Minute Confusion Assessment Method (3D-CAM) [12] and its severity graded with the Memorial Delirium Assessment Scale (MDAS) [13]. A 3D-CAM diagnosis required acute onset or a fluctuating course and inattention, plus either disorganised thinking or an altered level of consciousness. Assessments were performed twice daily from postoperative day 1 until discharge (08:00–10:00 and 18:00–20:00); the earliest positive assessment defined delirium onset. Patients were then categorised as delirium or non-delirium. Three bachelor-level nurses with >10 years’ experience, blinded to patient status, conducted all assessments. Before study initiation, assessors received standardised training, and structured testing confirmed competency with both scales to ensure consistent ratings. Furthermore, to minimize potential bias, each study participant was assigned a unique identification code. Personally identifiable information, such as patients’ names, was not used during the assessment process, ensuring that the personnel evaluating delirium status remained blinded to any clinical details that could influence their judgment.Meanwhile, the three researchers independently completed the MDAS scoring and conducted evaluations without knowing each other’s scoring results to minimize subjective bias to the greatest extent. The final score is processed by taking the average value to further improve the reliability of the evaluation results. Methodology Data preprocessing and feature engineering This study began by conducting data integrity checks on both the training and test sets, there are no duplicate values or missing values. Appropriate processing strategies were implemented based on the characteristics of the data. For categorical variables, one-hot encoding was used to effectively map categorical features into vector representations. For continuous variables, standardization parameters were calculated based on the distribution of the training set and then applied to the test set to maintain consistency in data transformation. All candidate variables were subjected to multivariate logistic regression analysis to preliminarily screen out factors with statistical significance for the outcome variable. On this basis, to further exclude potential multicollinearity issues among variables, the variance inflation factor (VIF) analysis method was adopted. By gradually removing variables with VIF values higher than the set threshold of 10, a feature subset with low multicollinearity was retained, thus achieving variable dimensionality reduction and model optimization. Handling class imbalance An analysis of the target variable in the test set revealed a significant class imbalance, with Group 2 and Group 1 representing 73.7% and 26.3% of the samples, respectively. To address the potential bias caused by the skewed class distribution during training, an inverse frequency weighting strategy was employed. Class weights were computed as the reciprocal of sample frequencies and incorporated into the model’s loss function to dynamically adjust for class imbalances. Model construction and optimization A classification framework was developed, encompassing six machine learning models: Logistic Regression, Decision Tree, Random Forest, XGBoost, CatBoost, and Balanced Bagging Classifier. For each model, hyperparameter were systematically optimized using grid search with 10-fold cross-validation, with the F1-score serving as the objective function to balance precision and recall, which was essential for addressing the class imbalance observed in the dataset. Specifically, the dataset was divided into 10 non-overlapping subsets. Each hyperparameter combination in the grid search was evaluated through 10 iterations of training and assessment. In each iteration, one subset was used as the validation set, while the remaining 9 subsets were employed for training. This process allowed for a systematic exploration of parameter spaces to identify the optimal configurations. During training, the best hyperparameter settings for each model were recorded, and iterative performance validation was carried out on the validation set to ensure that the selected parameter combinations did not lead to overfitting. Finally, predictions are made on an independent test set for each of the optimal models. Model evaluation framework Model performance was assessed using a multidimensional evaluation system, considering both discriminative efficacy and clinical applicability. For discriminative assessment, receiver operating characteristic (ROC) curves were plotted to evaluate classification performance, with the area under the curve (AUC) being the primary metric. Additional performance metrics, including accuracy, F1-score, positive predictive value (PPV), negative predictive value (NPV), sensitivity, and specificity, were also recorded. For clinical decision-making, decision curve analysis (DCA) was applied to assess the clinical net benefit across different risk thresholds, providing quantitative guidance for selecting the optimal threshold. The best-performing model from the validation set was chosen for evaluation on the independent test set, where generalization metrics (e.g., AUC, sensitivity, specificity) were computed to validate the model’s robustness and clinical utility. Statistical validation and generalizability testing To ensure statistical rigor, all hypothesis tests were conducted using a two-tailed approach with a significance level of α = 0.05. Model stability was evaluated using bootstrap resampling (1,000 iterations) to calculate 95% confidence intervals for the performance metrics. Final model evaluation was performed on the independent test set, with a systematic analysis of generalization capacity and overfitting risk through a comparison of performance between the training and test sets. Model interpretation and feature importance analysis Following performance evaluation and generalizability testing, the SHapley Additive exPlanations (SHAP) framework, based on game theory, was used to interpret the optimal model. The best-performing classifier, selected based on comprehensive validation and test results, underwent feature contribution analysis via Shapley value computation at the sample level. For nonlinear models, the Kernel SHAP algorithm was employed for approximate interpretation, while tree-based models utilized the more computationally efficient Tree SHAP algorithm. Global feature importance rankings, feature dependency plots, and individual prediction force diagrams were generated to systematically reveal the directional impact and magnitude of key predictors. Additionally, these visualizations helped elucidate the biological or clinical relevance of nonlinear feature interactions. This interpretability framework enhances the transparency of model decision-making and provides actionable insights for biomarker discovery and clinical decision support. Statistical methods Statistical analysis and modeling were performed using IBM SPSS 26.0, Python 3.8, the open-source Anaconda 23.1.0 release, and the Spyder 5.4.1 development environment. Quantitative data that followed a normal distribution were presented as mean ± standard deviation, and comparisons between groups were made using a T-test. For data that did not conform to a normal distribution, the median (quartiles) was used, and comparisons between groups were conducted with non-parametric tests. The number and percentage of cases with deterministic data were reported, and χ² tests or Fisher’s exact probability method was applied for inter-group comparisons. P < 0.05 was considered statistically significant. Results Comparison of general data between the two groups of patients A total of 901 patients were included in this study, of which 801 patients were used for model construction (training set) and 100 patients for external validation (testing set). The average age of the patients in the training set was 75.9 ± 8.345 years, with 318 males and 483 females. Among them, 211 patients developed delirium (delirium group) and 590 did not (non-delirium group), resulting in a delirium incidence rate of 26.3%. A comparison of the general data between the training and testing sets is shown in Table 1. Table 1Clinical characteristics of elderly patients with hip fracturesVaribleDelirium group (n = 211)Non-delirium group (n = 590)χ2/t P Gender0.611a0.634 Male79 (37.4%)239 (40.5%) Female132 (62.6%)351 (59.5%)Age76.95 ± 8.11275.52 ± 8.4021.897b0.052Educational attainment0.901a0.437 College degree or above17 (8.1%)59 (10.0%) Junior and senior high school64 (30.3%)185 (31.4%) Primary school and below130 (61.6%)346 (58.6%)BMI6.356a0.042 < 18.572 (34.1%)155 (26.3%) 18.5 ~ 2483 (39.3%)232 (39.3%) ≥ 2456 (26.5%)203 (34.4%)Living condition2.655a0.265 Live alone70 (33.2%)178 (30.2%) Live with children71 (33.6%)236 (40.0%) Live with one’s spouse70 (33.2%)176 (29.8%)Course of disease0.744a0.588 ≤ 6month144 (54.0%)339 (57.5%) > 6month97 (46.0%)251 (42.5%)Operation time2.384a0.123 < 2 h106 (50.2%)260 (44.1%) ≥ 2 h105 (49.8%)330 (55.9%)Intraoperative blood loss (ml)38.925a< 0.001 ≤ 20058 (27.5%)304 (51.5%) 200 ~ 40056 (26.5%)126 (21.4%) ≥ 40097 (46.0%)160 (27.1%)Mode of anesthesia4.542a0.103 General anesthesia142 (67.3%)379 (64.2%) Numbness in the waist46 (21.8%)166 (28.1%) Other23 (10.9%)45 (7.6%)Preoperative asthenia5.621a0.018 Yes113 (53.6%)260 (44.1%) no98 (46.4%)330 (55.9%) Preoperative blood glucose2.757 ± 3.7518.059 ± 3.7410.269b0.533 Preoperative albumin36.278 ± 6.14537.508 ± 7.1286.623b0.026Nutritional status6.032a0.015 Malnutrition66 (31.3%)167 (28.3%) High risk of malnutrition93 (44.1%)224 (38.0%) Good nutritional status52 (24.6%)199 (33.7%)Preoperative anemia4.210a0.04 Yes113 (53.6%)260 (44.1%) no98 (46.4%)330 (55.9%)Cognitive dysfunction5.271a0.022 Yes108 (51.2%)248 (42.0%) no103 (48.8%)342 (58.0%)Preoperative fasting time12.164 ± 1.9658.909 ± 4.6774.921b0.034VAS12.945a0.002 0 ~ 171 (33.6%)278 (47.1%) 2 ~ 364 (30.3%)161 (27.3%) ≥ 476 (36.0%)151 (25.6%)History of sedative use2.488a0.115 Yes95 (45.0%)229 (38.8%) no116 (55.0%)361 (61.2%)Drainage tube placement7.03a0.008 Yes124 (58.8%)284 (48.1%) no87 (41.2%)306 (51.9%)Preoperative creatinine79.506 ± 56.94970.051 ± 59.1874.719b0.035Sleep disorder Yes80 (37.9%)199 (33.7%)1.200a0.273 no131 (62.1%)391 (66.3%)Intraoperative pulse oxygen96.93 ± 1.85997.83 ± 1.6819.225b< 0.001Preoperative pulse oxygen96.08 ± 2.01697.45 ± 1.66911.940b< 0.001Postoperative pulse oxygen96.11 ± 1.80197.71 ± 4.02510.152b< 0.001Note: a:χ2; b:t Clinical characteristics of elderly patients with hip fractures Note: a:χ2; b:t Risk factors for postoperative delirium in elderly hip fracture patients in the training set Multivariable logistic regression analysis showed that preoperative pulse oximetry, intraoperative pulse oximetry, postoperative pulse oximetry, drainage tube placement, pain scores, and intraoperative blood loss were all significant risk factors for postoperative delirium in elderly hip fracture patients (P < 0.05), as detailed in Table 2. After performing multivariate logistic regression analysis and subsequent variance inflation factor (VIF) analysis to address multicollinearity, the following variables were retained in the final model with VIF values below the threshold of 10, indicating low multicollinearity. Table 2Test set the risk factors for postoperative delirium in elderly patients with hip fractureItemRegression coefficientSEWald X2 P OR95%CIConstant−82.1228.45294.407< 0.001Preoperative pulse oxygen0.3490.05639.395< 0.0011.418(1.272, 1.581)Intraoperative pulse oxygen0.3530.05738.341< 0.0011.423(1.273, 1.591)Postoperative pulse oxygen0.1760.05510.0860.0011.192(1.070, 1.329)Drainage tube placement−0.4740.2035.4450.0200.622(0.418, 0.927)VAS0.6020.2446.1000.0091.825(1.132, 2.943)Intraoperative blood loss1.3300.23532.153< 0.0013.781(2.387, 5.987)Nutritional status−0.6230.2059.1890.0020.537(0.359, 0.802)Preoperative fasting time0.3800.1784.5600.0021.463(1.032, 2.074)Preoperative albumin0.4500.1617.7800.0051.569(1.143, 2.153)Preoperative creatinine0.4230.1626.8020.0141.526(1.111, 2.096)VAS Visual analog score Test set the risk factors for postoperative delirium in elderly patients with hip fracture VAS Visual analog score Model construction and evaluation Through multivariable analysis, preoperative pulse oximetry, intraoperative pulse oximetry, postoperative pulse oximetry, VAS, drainage tube placement, intraoperative blood loss, preoperative fasting time, preoperative albumin levels, and preoperative serum creatinine levels were entered into machine learning models, resulting in the construction of six prediction models. The results indicate that Balanced Bagging demonstrated strong overall performance on both the validation and test sets, particularly in terms of accuracy and Brier score. Meanwhile, CatBoost achieved high scores in sensitivity, positive predictive value, F1-score, and specificity on the test set.From the ROC curve analysis, XGBoost had the highest AUC (0.91), indicating it possesses the strongest discriminative ability among all models. CatBoost followed closely with an AUC of 0.871. DCA curve analysis revealed that both XGBoost and CatBoost provided high clinical net benefit, making them clinically useful. However, XGBoost had the lowest specificity (0.371), suggesting poor performance in identifying negative-class samples. Comprehensive analysis suggests that CatBoost exhibits the best overall performance in building clinical risk prediction models.The predictive performance of the six models on the training set is detailed in Fig. 1, while their performance on the validation set is shown in Fig. 2. The AUC values of ROC curves and DCA curves for all six models are presented in Fig. 3. Evaluation of training set indicators on different machine learning models Evaluation of testing set indicators on different machine learning models ROC analysis of model decision thresholds and DCA for optimal decision threshold selection Model interpretability In this study, SHAP analysis was applied to identify and rank the most important factors contributing to delirium in elderly patients with hip fractures. The results showed that Intraoperative blood loss, preoperative fasting time, preoperative blood glucose, and preoperative creatinine were highly influential. As shown in figure (Fig. 4), the significant differences in SHAP value distributions between different classes further validated the feature patterns the model relied on to differentiate positive and negative classes. In the positive class, higher postoperative pulse oximetry showed a significant negative contribution, and its SHAP value indicated that higher levels of this variable reduced the probability of the sample being classified as positive. In contrast, preoperative blood glucose and fasting time had a positive impact on this category, meaning that higher preoperative blood glucose levels and longer preoperative fasting times increased the likelihood of the sample being classified as positive. The SHAP summary chart indicated that the impact of these variables remained stable across the entire dataset, and the SHAP contribution graph further confirmed their contribution to the prediction of individual samples. In the negative class, postoperative pulse oximetry remained the key variable influencing model prediction. However, in contrast to the positive class, its role was reversed, and higher postoperative pulse oximetry increased the likelihood of the sample being classified as negative. In addition, preoperative albumin and nutritional status also contributed significantly to predictions for the negative class. The SHAP dependence plot further revealed the trend of these variables’ effects across different value ranges, suggesting that patients with higher preoperative albumin levels and better nutritional status were more likely to be predicted as negative. A: SHAP summary plot, SHAP waterfall plot, SHAP heatmap, SHAP decision plot (positive class). B: SHAP summary plot, SHAP waterfall plot, SHAP heatmap, SHAP decision plot (negative class) Discussion Machine learning model performance Postoperative delirium is one of the common complications in elderly hip fracture patients, with an incidence rate ranging from 15% to 50% [14]. It not only prolongs hospitalization but also increases the risk of other complications, becoming one of the major factors affecting postoperative functional recovery and quality of life. With the further development of medical information technology, machine learning-based methods have expanded clinical disease research, promoted precision medicine, and individualized treatments, and facilitated the development of more accurate and practical clinical prediction models [15–17]. Therefore, this study established a machine learning-based delirium risk prediction model for elderly hip fracture patients, and added interpretability analysis to provide reasonable evidence for individualized predictions, helping clinicians better understand risk factors. Additionally, this study compared the performance of six machine learning models to select the optimal model. The results showed that machine learning algorithms exhibited strong generalization capabilities, while classic algorithms demonstrated significant differences across various evaluation metrics. The logistic regression model showed good stability, with the AUC of the test set (0.803) improving by 1.01% compared to the training set (0.702), indicating that the model performed well in calibrating unseen data. Among the machine learning models, CatBoost exhibited the best overall performance, achieving an AUC of 0.871 in the test set (0.976 in the training set) while maintaining high sensitivity (0.846) and specificity (0.686). In all models, its positive predictive value (0.833) and F1 score (0.840) were relatively high. Although the Balanced Bagging method achieved an AUC of 0.931 in the training set, its performance slightly declined during testing (0.860). The XGBoost model displayed a typical “high sensitivity - low specificity” pattern (0.969 vs. 0.371), suggesting that it may have overfitted the positive class features and struggled with imbalanced data. The Random Forest showed relatively stable performance between the training set (AUC 0.931) and the test set (0.869), but its specificity (0.657) was significantly lower than its sensitivity (0.846), indicating room for improvement in distinguishing negative samples. The decision tree model showed the most significant performance drop, with nearly no change in AUC between the test set (0.738) and the training set (0.927), but its F1 score decreased by 1.3% points, indicating limited ability to capture complex data patterns. Notably, all models showed an increase in Brier scores during testing, indicating good calibration of probability predictions. From a clinical applicability perspective, CatBoost is the most advantageous model, maintaining high diagnostic performance (AUC 0.871) and achieving about 90% positive predictive value. However, it should be noted that in practical applications, the performance of each model may vary depending on the selected sample group, feature selection, and parameter optimization. Therefore, in actual implementation, it is recommended to choose the most suitable risk prediction algorithm based on specific needs and data characteristics to ensure that the selected method not only meets the performance requirements of the particular problem but also achieves the desired interpretability standards. Key risk factors for postoperative delirium in elderly hip fracture patients The analysis of risk factors in this study showed that preoperative, intraoperative, and postoperative pulse oximetry, preoperative blood glucose levels, preoperative fasting time, preoperative albumin levels, nutritional status, VAS, and preoperative serum creatinine levels were the major risk factors for postoperative delirium in elderly hip fracture patients. The SHAP analysis results in this study indicated that perioperative pulse oximetry was the most critical variable influencing model prediction, especially postoperative and preoperative pulse oximetry, which aligns with the findings of Zhe et al. [18]. This is primarily because perioperative oxygen levels in patients’ blood are positively correlated with brain cell function. Insufficient oxygen supply can cause brain cell hypoxia and edema, norepinephrine-acetylcholine imbalance, and other issues, which can then induce postoperative delirium [19]. Francois et al. [20] pointed out that prolonged hyperglycemia can lead to cerebrovascular damage and impairment of the brain microenvironment, triggering postoperative delirium, which is consistent with the SHAP analysis results of this study. This study found that higher preoperative blood glucose levels increased the risk of postoperative delirium in elderly hip fracture patients. Persistent hyperglycemia can lead to cerebrovascular atherosclerosis, damage neuronal cells, and promote cognitive dysfunction, thus triggering delirium [21]. SHAP visualization analysis showed that preoperative fasting time, preoperative albumin levels, nutritional status, VAS, and preoperative serum creatinine levels were associated with postoperative delirium occurrence in elderly hip fracture patients. The occurrence of postoperative delirium in elderly hip fracture patients may be influenced by preoperative fasting time, with significant differences in the risk of delirium between patients with different fasting times [22]. An et al. [23] also showed that preoperative fasting and drinking time was positively correlated with postoperative delirium occurrence, but other studies [24] indicated that preoperative fasting and drinking time had no effect on postoperative delirium. Therefore, whether shortening preoperative fasting and drinking time can prevent postoperative delirium in elderly hip fracture patients requires further validation. Preoperative albumin levels and nutritional status are also important factors for postoperative delirium, which is consistent with the research of Tatsuro et al. [25]. Albumin is one of the commonly used indicators for assessing nutritional status, and malnutrition can lead to excessive protein breakdown, affecting neurotransmitter synthesis. Furthermore, long-term malnutrition can weaken the immune system, create a low-grade inflammatory state, impair brain function, and promote postoperative delirium [26]. Previous studies [27] have shown that VAS scores are also related to postoperative delirium in elderly hip fracture patients. High VAS scores can trigger stress responses in the body, leading to increased levels of cortisol, catecholamines, and other stress hormones, promoting the release of inflammatory factors, and affecting sleep quality, which indirectly damages brain function and leads to delirium. Studies have also shown that compared with patients with normal preoperative serum creatinine levels, those with high serum creatinine levels have a higher incidence of postoperative delirium [18]. This may be related to impaired kidney function, resulting in toxin accumulation, electrolyte imbalances, and affecting the cardiovascular and cerebrovascular systems, increasing the likelihood of delirium. Recommendations for preventing postoperative delirium in elderly hip fracture patients 4.3.1 Previous studies have only investigated the impact of postoperative pulse oximetry on delirium occurrence [28, 29], neglecting the effect of preoperative and intraoperative pulse oximetry on postoperative delirium. The SHAP results of this study show that both preoperative and intraoperative pulse oximetry are equally important in preventing postoperative delirium in elderly hip fracture patients. Therefore, attention should be given to the entire perioperative pulse oximetry in elderly hip fracture patients, with timely oxygen administration to maintain high pulse oximetry levels. 4.3.2 Preoperatively, blood glucose levels should be used to develop a comprehensive glycemic control plan, addressing multiple aspects to maintain blood glucose levels within a safe range and reduce the risk of postoperative delirium. 4.3.3 For elderly hip fracture patients, surgery should be scheduled as early as possible to minimize preoperative fasting and drinking time. Additionally, preoperatively, based on the patient’s nutritional status and albumin levels, appropriate nutritional supplementation should be provided to correct malnutrition. 4.3.4 The perioperative VAS scores of patients should be monitored, and pain management should be strengthened with a combination of various methods, keeping the VAS score between 2 and 3. 4.3.5 Elderly hip fracture patients often have complex conditions, and multiple factors affect postoperative delirium occurrence. Relying on a single indicator may not accurately predict the outcome. Exploring the complex interactions between variables using correlation coefficients or machine learning algorithms may provide higher accuracy and offer more comprehensive and precise information to assist healthcare providers in making more scientific treatment and care decisions. This study has several limitations. First, it is a single-centre retrospective analysis with a relatively homogeneous patient source, which may introduce selection bias. Second, although we ultimately enrolled 901 patients, the independent external-validation cohort comprised only 100 cases, limiting the precision with which transportability can be judged. Third, the model relies solely on objective clinical variables and does not capture potentially influential psychological factors such as depression or social isolation.To address these issues, we are forming a multicentre consortium with several tertiary trauma hospitals to establish a large, standardised database of elderly hip-fracture cases. This initiative will provide a substantially larger external-validation set, permit prospective data collection, and allow inclusion of additional psychosocial and peri-operative variables. Based on the expanded dataset, we will refine the machine-learning model, derive a weighted risk-score chart, and validate its bedside utility for early identification of high-risk patients and personalised preventive intervention. Conclusion This study compared the performance of six risk prediction models for predicting postoperative delirium in elderly hip fracture patients through a combination of internal and external validation. The models performed well and can provide a basis for subsequent clinical decision-making. Additionally, the visualization of model results allows for dynamic and precise assessment of individual patients, facilitating targeted interventions to improve healthcare quality. Acknowledgments Contributors All authors contributed significantly to the planning, conduct and reporting of the work described in the paper. Yayun Xing, Yuetong Wang, and Yuejiao Huang are co-first authors. Clinical trial number NCT07121309 (ClinicalTrials.gov). Explanation This study fully complies with the reporting standards of the predictive model. Abbreviations Hospital information management system Visual analogue scale Memory and delirium assessment scale Receiver operating characteristic Area under the curve Positive predictive value Negative predictive value Decision curve analysis SHapley Additive exPlanations Authors’ contributions X, W, and H contributed significantly to the planning, conduct and reporting of the work described in the paper. X, W, and H are co-first authors. L and Z critically reviewed the manuscript for important intellectual content. L and Z are joint corresponding author. All authors approved the final version of the manuscript. Funding This work was supported by the Science and Education Strong Health Project of Suzhou in China (No. MSXM2024011). Data availability Our data have not been deposited in a repository, but are available upon reasonable request to the corresponding author. Declarations Ethics approval and consent to participate Our study is a retrospective research that does not involve patient privacy. Therefore, an application for exemption from informed consent was submitted and authorized by the hospital ethics committee before the commencement of the study. Our research complies with the Helsinki Declaration and has been approved by the Ethics Committee of Second Affiliated Hospital of Soochow University (JD-HG-2025-022). Consent for publication Not Applicable. Competing interests The authors declare no competing interests. Footnotes Publisher’s Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Yayun Xing, Yuejiao Huang and Yuetong Wang contributed equally to this work. References Associated Data Data Availability Statement Our data have not been deposited in a repository, but are available upon reasonable request to the corresponding author.