Introduction
Primary liver cancer (PLC) is one of the most common malignancies worldwide, ranking sixth in incidence and third in cancer-related mortality (1). In China, PLC represents a particularly significant public health burden, accounting for nearly half of all global cases (2). Despite substantial advances in systemic therapies, surgical resection remains the preferred potentially curative treatment for patients with resectable PLC (3).
Hepatectomy, however, remains associated with considerable postoperative morbidity, among which postoperative pulmonary complications (PPCs) represent one of the most frequent and clinically relevant adverse outcomes (4).
According to standardized perioperative outcome definitions, PPCs represent a heterogeneous group of clinically meaningful respiratory complications occurring after surgery, including respiratory infection, pneumonia, aspiration pneumonitis, bronchospasm, pleural effusion requiring intervention, atelectasis requiring treatment, respiratory failure, and acute respiratory distress syndrome (ARDS) (5). Reported PPC incidence after hepatectomy varies according to patient characteristics, extent of liver resection, perioperative management, and diagnostic criteria, with previous studies reporting rates ranging from approximately 5% to 50% in contemporary surgical cohorts (6,7). PPCs are associated with prolonged hospitalization, increased healthcare utilization, delayed functional recovery, and worse postoperative outcomes (8).
Therefore, early identification of patients at increased risk of PPCs may facilitate individualized postoperative surveillance and targeted supportive management.
Previous studies have identified multiple patient-related and procedure-related factors associated with PPC development after hepatectomy. Advanced age, smoking history, chronic respiratory disease, poor nutritional status, impaired liver function, higher American Society of Anesthesiologists (ASA) classification, extensive liver resection, open surgical approaches, prolonged operative duration, increased blood loss, blood transfusion, and prolonged portal triad clamping have been reported as important contributors to postoperative respiratory morbidity (4,9,10). These factors may influence PPC susceptibility through reduced pulmonary reserve, impaired respiratory mechanics, inflammatory activation, fluid shifts, and surgical stress.
However, the complex interactions among these clinical characteristics make individualized risk estimation challenging using conventional clinical assessment alone.
Several clinical risk assessment tools have been developed to estimate PPC risk in general surgical populations. The Assess Respiratory Risk in Surgical Patients in Catalonia (ARISCAT) score incorporates age, oxygen saturation, respiratory infection history, anemia, surgical incision site, operative duration, and emergency surgery status, whereas the Local Assessment of Ventilatory Management During General Anaesthesia for Surgery (LAS VEGAS) score incorporates perioperative characteristics associated with respiratory outcomes (11,12). Although these tools are valuable for broad surgical risk stratification, their applicability to patients undergoing hepatectomy for PLC remains incompletely established.
Specifically, they were not developed in liver surgery populations and do not incorporate several hepatectomy-specific variables, including portal triad clamping duration, extent of liver resection, intraoperative transfusion, and liver-specific nutritional or functional indicators (13-15). Therefore, models specifically developed and validated for patients undergoing hepatectomy may provide additional value for individualized postoperative PPC risk stratification.
In recent years, machine-learning approaches have emerged as promising methods for clinical prediction modeling because they can capture nonlinear relationships and complex interactions among multiple clinical predictors (16). Unlike conventional regression-based approaches that rely on predefined assumptions regarding predictor-outcome relationships, machine-learning algorithms can integrate heterogeneous clinical information derived from electronic medical records (EMRs), including demographic characteristics, laboratory parameters, comorbidities, surgical factors, and intraoperative variables (17). Previous studies have demonstrated the potential of machine-learning methods for predicting PPCs in diverse surgical populations (18,19).
However, few studies have specifically focused on PPC risk stratification after hepatectomy in patients with PLC, using externally evaluated and interpretable models.
In this study, we aimed to develop and externally evaluate an explainable machine-learning model for postoperative PPC risk stratification after hepatectomy in patients with PLC using routinely collected perioperative clinical variables. Multiple machine-learning algorithms were systematically compared, and the final model was selected based on a multidimensional evaluation framework incorporating discrimination, calibration, classification performance, and clinical utility. Furthermore, an interpretable web-based calculator was developed to facilitate individualized postoperative risk assessment and support enhanced respiratory surveillance among patients identified as potentially high risk.
We present this article in accordance with the TRIPOD reporting checklist (available at https://jgo.amegroups.com/article/view/10.21037/jgo-2026-0702/rc).
Methods
Data source and study design
This retrospective prediction-model development and validation study included 906 patients with PLC who underwent elective hepatectomy at The First Affiliated Hospital of China Medical University (Shenyang, China) between March 2021 and September 2025. These patients constituted the development cohort. An independent external validation cohort comprising 388 patients who underwent elective hepatectomy at Shengjing Hospital of China Medical University (Shenyang, China) between February 2024 and October 2025 was established to evaluate model transportability.
Hepatectomy procedures were performed according to contemporaneous clinical guidelines and institutional surgical protocols. Demographic, clinical, laboratory, tumor-related, surgical, and perioperative data were retrospectively extracted from EMR systems of both institutions.
The inclusion criteria were as follows: (I) age ≥18 years; (II) pathologically confirmed PLC treated with elective hepatectomy; and (III) complete assessment of PPCs within the prespecified follow-up period. The exclusion criteria were as follows: (I) preoperative pulmonary infection, including active pneumonia, or severe/uncontrolled chronic respiratory disease that could independently influence postoperative respiratory outcomes; (II) emergency surgery or non-resection procedures, including exploratory laparotomy, liver biopsy, or biliary drainage alone; (III) severe preoperative organ failure, other life-threatening conditions, or concomitant malignancies; and (IV) more than 20% missingness across candidate predictor variables.
The study was conducted in accordance with the Declaration of Helsinki and its subsequent amendments. The study protocol was reviewed and approved by the Ethics Committees of The First Affiliated Hospital of China Medical University (approval No. EC-[2025]-2294-2) and Shengjing Hospital of China Medical University (approval No.
EC-2025PS1632K). Because of the retrospective observational design and use of de-identified data, the requirement for written informed consent was waived by both Ethics Committees. All patient data were anonymized before analysis and securely stored with access restricted to authorized study personnel.
Sample size calculation
The minimum sample size for model development was estimated according to the Riley framework for binary clinical prediction models, which considers the anticipated outcome incidence, model complexity, and expected predictive performance (20). Assuming an expected PPC incidence of approximately 15%, an anticipated model discrimination of C-statistic of 0.75, and eight predictor parameters in the final prediction model, the required sample size was estimated using the pmsampsize package in R software. The calculation indicated that a minimum of 660 participants, including approximately 99 PPC events, would be required to achieve adequate precision and limit optimism in model performance estimates.
The present study included 906 patients in the development cohort, among whom 131 (14.5%) experienced PPCs, exceeding both the required overall sample size and the expected number of outcome events.
Data collection
Initially, 51 candidate predictors were prespecified based on previous literature, clinical relevance, and routine availability in perioperative EMRs (4,9,10). These variables represented clinically relevant domains including demographic characteristics, baseline comorbidities, laboratory parameters, tumor-related characteristics, and perioperative surgical factors. Candidate predictors were defined before model development and were not selected solely according to univariable associations, statistical significance, or model performance.
Demographic characteristics included age, sex, body mass index (BMI, kg/m2), smoking history, and alcohol consumption. Baseline medical characteristics included hypertension, diabetes mellitus, dyslipidemia, chronic respiratory disease, coronary heart disease, cerebrovascular disease, previous abdominal surgery, hepatitis B or C virus infection, liver cirrhosis, Child-Pugh classification, and previous anticancer therapy. Tumor-related variables included histological subtype, maximum tumor diameter, tumor multiplicity, and vascular invasion.
Perioperative surgical variables included ASA classification, surgical approach, extent of hepatectomy, resection involving segments VII/VIII, concomitant extrahepatic procedures, operative duration, portal triad clamping duration, estimated blood loss, intraoperative blood transfusion, crystalloid and colloid administration, intraoperative urine output, and core body temperature.
Preoperative laboratory variables included hemoglobin (Hgb), albumin (ALB), total bilirubin (TBIL), aspartate aminotransferase (AST), alanine aminotransferase (ALT), blood urea nitrogen (BUN), uric acid (UA), serum creatinine (SCr), prothrombin time (PT), white blood cell count (WBC), platelet count (PLT), lymphocyte count (LYM), and neutrophil count (NEU). For patients with repeated measurements, the laboratory value obtained closest to surgery within 48 hours before the procedure was selected. All laboratory tests were performed as part of routine clinical care in institutional clinical laboratories using standardized procedures.
Derived inflammatory and nutritional indices were calculated as follows: platelet-to-lymphocyte ratio (PLR), neutrophil-to-lymphocyte ratio (NLR), and prognostic nutritional index (PNI=ALB + 5 × LYM).
Intraoperative variables were extracted from standardized anesthesia records and surgical documentation. Operative duration was defined as the interval from skin incision to completion of wound closure. Estimated blood loss was obtained from anesthesia records and operative reports.
Intraoperative blood transfusion was defined as the administration of packed red blood cells or other allogeneic blood products during surgery. Portal triad clamping duration was defined as the cumulative duration of hepatic inflow occlusion documented by the surgical team. Crystalloid and colloid administration represented the total intraoperative volumes recorded in the anesthesia information system.
Core body temperature was obtained from continuous intraoperative monitoring records. Ventilation-related variables, including tidal volume, airway pressure, and ventilatory mode, were not included because these variables were not consistently available across both participating institutions, which could compromise model reproducibility and external applicability.
Because several final predictors, including portal triad clamping duration and intraoperative blood transfusion, become available only after completion of surgery, the developed model was not designed for preoperative counseling or intraoperative decision modification. Instead, the model was intended for immediate postoperative PPC risk stratification after hepatectomy, when all required predictor information becomes available.
Primary outcome: PPCs
The primary outcome was the occurrence of PPCs within 30 days after hepatectomy. PPCs were defined according to the European Perioperative Clinical Outcome (EPCO) criteria and prespecified clinical diagnostic criteria (5). A composite PPC endpoint was used to capture clinically relevant postoperative respiratory morbidity requiring clinical recognition, monitoring, or intervention.
Although individual PPC components may differ in pathophysiology, severity, and therapeutic requirements, they represent clinically related manifestations of postoperative respiratory dysfunction and share several perioperative contributors, including reduced pulmonary reserve, impaired lung expansion, inflammatory responses, fluid imbalance, and surgical stress. Therefore, the composite endpoint was selected to reflect the overall burden of clinically meaningful respiratory complications after hepatectomy rather than to represent a single biological mechanism.
Patients were classified as PPC-positive if they developed at least one of the following conditions within 30 days after surgery: respiratory infection, pneumonia, aspiration pneumonitis, bronchospasm, pleural effusion, atelectasis, pneumothorax, respiratory failure, or ARDS. Diagnoses were established using predefined criteria incorporating clinical manifestations, laboratory findings, and imaging examinations, including chest radiography or computed tomography (CT) (Table S1). To improve clinical specificity and reduce misclassification of transient postoperative physiological changes, minor radiographic abnormalities were considered clinically relevant PPCs when accompanied by respiratory symptoms (such as dyspnea or hypoxemia) or requiring specific clinical management, including thoracentesis, pleural drainage, bronchoscopy, or escalation of oxygen therapy.
The frequency of individual PPC components was summarized in Table S2. For model development, the composite PPC endpoint was analyzed as a binary outcome, defined as the presence or absence of at least one clinically relevant PPC event within 30 days after surgery.
Data processing
Prior to model development, candidate variables with more than 20% missingness were excluded. The development cohort was subsequently randomly divided into a training set (70%) and an internal testing set (30%). All model-development-related preprocessing procedures, including feature transformation, scaling, and feature selection, were performed exclusively within the training cohort to minimize the risk of information leakage.
The proportion of missing values for each candidate predictor before imputation is summarized in Table S3 and Figure S1. Among the retained predictors with missing data, the proportion of missingness ranged from 3.3% to 12.5%. Missing predictor values were handled using multiple imputation by chained equations (MICE) under the assumption that data were missing at random (MAR) (21).
The imputation model incorporated the retained predictors from multiple clinical domains, including demographic characteristics, comorbidities, tumor-related characteristics, laboratory parameters, and perioperative variables. Five imputed datasets were generated for the development cohort. The PPC outcome was not included in the imputation procedure because outcome status was completely observed for all patients.
Missing-data imputation was performed separately for the training, internal testing, and external validation cohorts using the same prespecified MICE specifications, without incorporating information from the internal testing and external validation cohorts into model development.
Continuous predictors were standardized using Z-score transformation parameters estimated from the training cohort, and the same parameters were applied to the internal testing and external validation cohorts. Categorical predictors were transformed using one-hot encoding based on categories identified in the training cohort. For model development, each algorithm was trained independently within each imputed dataset using the prespecified modeling pipeline.
Predicted probabilities from the five imputed datasets were subsequently pooled to obtain final probability estimates for performance evaluation.
Feature selection
Following data preprocessing, feature selection was performed exclusively within the training cohort to reduce predictor redundancy and minimize the risk of overfitting. A dual-method strategy combining least absolute shrinkage and selection operator (LASSO) regression and random forest recursive feature elimination (RF-RFE) was applied using the preprocessed training data only. For LASSO regression, 10-fold cross-validation was used to determine the optimal regularization parameter (λ).
The one-standard-error (1-SE) criterion was applied to identify a more parsimonious predictor subset while reducing multicollinearity and limiting model complexity (22). In parallel, RF-RFE was performed to capture predictors with potential nonlinear associations and interaction effects that may not be adequately represented by linear shrinkage methods. Variables were recursively ranked and eliminated according to model performance within the training cohort until the optimal feature subset was identified (23).
Predictors consistently selected by both LASSO and RF-RFE were retained as the final predictor set for subsequent model development. The selected predictors were fixed before model training and applied consistently across all machine-learning algorithms and imputed datasets. No information from the internal testing cohort or external validation cohort was used during feature selection.
Model development and validation
Eight machine-learning algorithms were developed, including logistic regression (LR), random forest (RF), Extreme Gradient Boosting (XGBoost), k-nearest neighbors (KNN), decision tree (DT), Naïve Bayes (NB), Light Gradient Boosting Machine (LightGBM), and support vector machine (SVM) (24,25). These algorithms were prespecified to represent complementary modeling paradigms applicable to structured perioperative clinical data. LR was included as a conventional linear benchmark.
DT and tree-based ensemble methods (RF, XGBoost, and LightGBM) were selected because of their ability to capture nonlinear predictor-outcome relationships and interactions without requiring these relationships to be predefined. SVM was included as a kernel-based classifier capable of constructing nonlinear decision boundaries, KNN as a nonparametric distance-based approach, and NB as a parsimonious probabilistic classifier suitable for moderate-sized clinical datasets. Model development and hyperparameter optimization were performed exclusively within the training cohort.
For each algorithm, grid-search tuning with 5-fold cross-validation was conducted to identify optimal model-specific parameters. To address outcome imbalance, cost-sensitive learning using class weights was applied for algorithms supporting this strategy. Class weights were calculated according to the PPC distribution within the training cohort, assigning greater penalties to misclassification of PPC-positive patients (26,27).
Following hyperparameter optimization, each algorithm was refitted using the complete training cohort with the optimized parameters. Optimized hyperparameters for all algorithms are provided in Table S4.
For multiple imputed datasets, each machine-learning algorithm was independently trained within each imputed dataset using the identical modeling pipeline. Five-fold out-of-fold (OOF) predictions generated within each imputed dataset were subsequently pooled using mean probability averaging to obtain final training probability estimates. These pooled OOF probabilities were used for model evaluation, calibration assessment, and threshold determination.
Model performance was evaluated using a multidimensional framework incorporating discrimination, classification performance under class imbalance, calibration, and clinical utility. Discrimination was assessed using the receiver operating characteristic area under the curve (AUC) and the area under the precision-recall curve (PR-AUC) (28). Classification performance was assessed using sensitivity, specificity, precision (positive predictive value), negative predictive value (NPV), balanced accuracy, and F1-score.
Because the intended clinical application was postoperative identification of patients requiring enhanced respiratory surveillance, particular emphasis was placed on sensitivity and NPV to minimize missed high-risk patients, while balanced accuracy and F1-score were used to evaluate the trade-off between sensitivity and precision.
Calibration was assessed using calibration plots, calibration intercept, calibration slope, Brier score, and log-loss. Logistic recalibration was performed using pooled training OOF predictions only, and the resulting recalibration model was subsequently applied to the internal testing and external validation cohorts without using validation outcomes. Decision-curve analysis (DCA) was performed to evaluate potential clinical net benefit across clinically relevant threshold probabilities.
The final model selection incorporated discrimination (AUC and PR-AUC), classification performance (balanced accuracy, sensitivity, NPV, and F1-score), calibration performance, and clinical utility assessed by DCA. The operating threshold was determined using pooled training OOF predictions (Youden index) and fixed before evaluation in validation cohorts. All discrimination, calibration, classification, and clinical utility metrics were subsequently reported for the internal testing and external validation cohorts.
Model interpretability and clinical deployment
To improve the interpretability of the final prediction model, Shapley Additive Explanations (SHAP) analysis was performed for the final model to quantify the contribution of individual predictors to model-derived PPC risk estimates (29). Feature importance was assessed by aggregating the absolute SHAP values, and SHAP summary plots were generated to visualize the magnitude and direction of individual predictor effects on model predictions.
For clinical translation, a web-based application was developed using the R Shiny package (30), enabling healthcare providers to input patient-specific perioperative parameters and obtain individualized estimates of PPC risk. The prespecified classification threshold (Youden index) is presented to facilitate postoperative risk stratification. The calculator is intended primarily for immediate postoperative risk stratification, which may assist clinicians in identifying patients who could benefit from enhanced postoperative respiratory surveillance and targeted preventive management after hepatectomy.
The study flowchart is presented in Figure 1.
Sensitivity analysis
To evaluate the stability of the final prediction model under an alternative clinically relevant outcome definition, a sensitivity analysis was performed using severe PPCs as the outcome. The original training-internal testing partition was retained, and the predictor set identified in the primary analysis was kept unchanged to evaluate outcome-definition robustness rather than to develop a new optimized model. The final optimal model architecture and modeling framework were maintained, and the model was retrained in the original training cohort using severe PPC occurrence as the alternative outcome.
The retrained model was subsequently evaluated in the unchanged internal testing cohort.
Severe PPCs were defined according to the Clavien-Dindo classification grade IIIa or higher, including respiratory complications requiring invasive interventions (e.g., pleural drainage or bronchoscopy), life-threatening respiratory complications requiring intensive care management, or other PPC-related interventions beyond routine postoperative care (6,31). This severity-based definition was selected because individual PPC components, including pneumonia, pleural effusion, and atelectasis, may differ substantially in clinical severity, therapeutic requirements, and prognostic implications.
Statistical analysis
Statistical analyses were performed using R version 4.4.2 (R Foundation for Statistical Computing, Vienna, Austria). Continuous variables were presented as medians with interquartile ranges (IQRs) and compared using the Mann-Whitney U test. Categorical variables were expressed as frequencies and percentages (%) and compared using the Chi-squared test or Fisher’s exact test, as appropriate.
A two-sided P value <0.05 was considered statistically significant. Baseline comparisons were performed for descriptive purposes only. Candidate predictor selection and model development followed the prespecified machine-learning framework within the training cohort and were not based on univariable statistical significance testing.
Results
Baseline characteristics of patients
The development cohort included 906 eligible patients, with a median age of 58 years (IQR, 46–72 years). More than half of the patients were male (58.8%), and most were diagnosed with hepatocellular carcinoma (HCC) (86.2%). Hypertension was the most prevalent comorbidity (27.0%).
Additionally, 74.7% of the patients had hepatitis B virus/hepatitis C virus (HBV/HCV) infection, and 73.4% underwent open surgery. The overall incidence of PPCs was 14.5% (131/906). Among patients who developed PPCs, pleural effusion (34.4%), respiratory infection (24.4%), and pneumonia (20.6%) were the most frequently observed complications (Table S2).
Univariate analysis showed that age, BMI, chronic respiratory disease, Child-Pugh stage, ASA classification, surgical approach, hepatectomy scope, extent of hepatectomy, portal triad clamping duration, crystalloid administration, blood transfusion, ALB and PNI were statistically significant factors associated with PPC occurrence (P<0.05). Further details are provided in Table 1.
The development cohort was subsequently randomly divided into a training set (n=635, including 93 PPC cases) and an internal testing set (n=271, including 38 PPC cases). Baseline characteristics were comparable between the two cohorts, with no statistically significant differences observed for the evaluated variables (all P>0.05), indicating a balanced distribution between the training and internal testing cohorts (Table S5).
Feature selection
Feature selection was performed using a combined strategy incorporating LASSO regression and RF-RFE. For LASSO regression, coefficient trajectories under different regularization parameters were visualized (Figure 2A). The optimal penalty parameter (λ) was determined using the 10-fold cross-validation error curve, and the 1-SE criterion was applied to obtain a more parsimonious predictor subset.
This approach identified nine predictors that were retained for subsequent analysis (Figure 2B, Figure S2A). In parallel, RF-RFE was performed within the training cohort to identify predictors associated with model performance. The cross-validation performance reached its maximum at a subset containing 10 variables, which were subsequently retained as the RF-RFE-selected predictors (Figure 2C).
The relative importance ranking of these predictors is presented in Figure S2B. Finally, the intersection of the predictors identified by LASSO and RF-RFE resulted in the eight candidate variables selected for model development: age, ASA status, hepatectomy type, surgical approach, intraoperative blood transfusion, portal triad clamping duration, chronic respiratory disease, and PNI (Figure 2D).
Model performance and comparisons
Eight machine-learning models were developed and evaluated for predicting PPCs after hepatectomy. Model development performance was assessed using pooled OOF predictions from the training cohort. The results showed that, in the training cohort, LR achieved the highest AUC [0.893, 95% confidence interval (CI): 0.862–0.924], whereas NB achieved the highest PR-AUC (0.667, 95% CI: 0.575–0.748).
XGBoost demonstrated comparable performance (AUC =0.888, 95% CI: 0.855–0.922; PR-AUC =0.640, 95% CI: 0.538–0.730), followed by LR (PR-AUC =0.638, 95% CI: 0.538–0.725) (Figure 3 and Figure 4A; Table S6). In the internal testing cohort, LR showed the highest discrimination, with an AUC of 0.858 (95% CI: 0.775–0.942) and a PR-AUC of 0.697 (95% CI: 0.534–0.820). LightGBM achieved a comparable AUC of 0.857 (95% CI: 0.780–0.934), whereas NB maintained stable performance with an AUC of 0.851 (95% CI: 0.767–0.934) and a PR-AUC of 0.668 (95% CI: 0.485–0.798) (Figure 3B,3D and Figure 4B).
Although LR demonstrated slightly higher AUC and PR-AUC, NB provided the most favorable overall classification profile at the prespecified operating threshold. Using the Youden-index threshold of 0.221 determined exclusively from training-cohort OOF predictions (Table S6), NB achieved the highest accuracy (0.878), specificity (0.906), precision (0.551), and F1-score (0.621) among the eight candidate models, while maintaining acceptable sensitivity (0.711). In comparison, LR achieved higher sensitivity (0.842) but showed lower specificity (0.738), precision (0.344), and F1-score (0.489).
The probabilistic performance of NB was also favorable. In the internal testing cohort, the NB Brier score was 0.075, close to that of LR (0.073), and its calibration intercept was −0.019 with a calibration slope of 0.821, indicating limited overall calibration-in-the-large error with some deviation from the ideal calibration slope. Calibration curves for the candidate models are presented in Figure 5A,5B.
DCA suggested that NB provided a favorable net clinical benefit across a broad range of threshold probabilities in both the training and internal testing cohorts (Figure 5C,5D). Consistent classification performance of NB was further illustrated by the confusion matrices (Figure 6). Considering the overall balance between discrimination, minority-class prediction performance, calibration, threshold-based classification characteristics, and clinical utility, NB was selected as the final model for external validation.
External validation
The external performance and transportability of the developed models were further assessed in an independent external validation cohort consisting of 388 patients, among whom 66 (17.0%) developed PPCs (Table S7). Overall, model discrimination remained stable across the eight algorithms. The NB model demonstrated the best overall discrimination, achieving the highest AUC (0.861, 95% CI: 0.810–0.911) and the highest PR-AUC (0.650, 95% CI: 0.516–0.759) among all evaluated models (Figure 7A,7B; Table S8).
At the predefined operating threshold of 0.221 derived from the training cohort, NB achieved an accuracy of 0.822, sensitivity of 0.636, specificity of 0.860, precision of 0.483, and F1 score of 0.549 (Figure 7C). NB also demonstrated favorable overall probabilistic performance, with the lowest Brier score among the evaluated models (0.094). Calibration analysis showed good agreement between predicted and observed risks, with a calibration intercept of 0.217 and a calibration slope of 0.898, indicating preserved calibration performance with slight underestimation of PPC risk (Figure 7C).
DCA further demonstrated that NB provided a favorable net clinical benefit across a clinically relevant range of threshold probabilities (Figure 7D). Collectively, these external validation findings supported the robustness and potential clinical applicability of the NB model for postoperative PPC risk stratification after hepatectomy within the evaluated validation setting.
Sensitivity analysis for severe PPCs
To evaluate the robustness of the final model under an alternative outcome definition, a sensitivity analysis was performed using severe PPCs defined according to Clavien-Dindo grade IIIa or higher. Severe PPCs occurred in 87 patients (9.6%) and 45 patients (11.6%) in the development and external validation cohorts, respectively. Using the same predictor set and modeling framework as the primary analysis, the NB model demonstrated generally consistent discriminative performance across the evaluated cohorts.
The AUC was 0.844 (95% CI: 0.793–0.895) based on training OOF predictions, 0.872 (95% CI: 0.791–0.953) in the internal testing cohort, and 0.838 (95% CI: 0.779–0.897) in the external validation cohort (Table S9). Corresponding PR-AUC values were 0.403, 0.657 and 0.511, respectively. The Brier scores remained low across cohorts (0.064, 0.074 and 0.082 for training, internal testing, and external validation cohorts, respectively), suggesting preserved probabilistic performance.
Furthermore, sensitivity and specificity were 0.800 and 0.748 in the training cohort, 0.781 and 0.870 in the internal testing cohort, and 0.622 and 0.790 in the external validation cohort, respectively (Table S9). Overall, these findings indicated that the NB model maintained generally consistent predictive performance when the outcome definition was restricted to clinically severe PPCs. However, given the smaller number of severe PPC events, these results should be interpreted as a supportive sensitivity analysis rather than definitive evidence of model performance for severe complications.
Model interpretability analysis
To enhance the interpretability of the final model, SHAP analysis was performed to quantify the contribution of each predictor to the NB model’s PPC risk predictions. As shown in Figure 8A, the eight predictors included in the final model were ranked according to their mean absolute SHAP values, reflecting their overall influence on model output. Among them, age, intraoperative blood transfusion, and portal triad clamping duration were the three most influential predictors.
The SHAP summary plot (Figure 8B) further illustrated both the magnitude and direction of the associations between individual predictors and predicted PPC risk. In this plot, each point represents an individual patient, and the color gradient reflects the feature value, with red indicating lower values and yellow indicating higher values. Overall, advanced age, ASA class III–IV, open surgery, intraoperative blood transfusion, prolonged portal triad clamping duration, and the presence of chronic respiratory disease were associated with increased PPC risk.
In contrast, a higher PNI and resection sites other than segments VII/VIII were associated with lower predicted PPC risk.
To further demonstrate the clinical interpretability of the model, individualized SHAP waterfall plots were generated for representative high-risk and low-risk patients (Figure 8C,8D). These plots display the directional contribution of each predictor to the final prediction, with yellow bars indicating risk-increasing effects and red bars indicating risk-reducing effects. For the representative high-risk patient (Figure 8C), the final predicted PPC probability increased to 1.01 from a baseline expected value of 0.15.
In contrast, for the representative low-risk patient (Figure 8D), the final predicted probability decreased to 0.0175 relative to the same baseline expected value. These findings illustrate how the final NB model provides both population-level and patient-level interpretability for PPC risk prediction.
Online application
To facilitate clinical translation, a web-based risk calculator was developed on the basis of the final NB model (Figure 9). The application provides a user-friendly interface for rapid bedside risk stratification by allowing clinicians to enter routinely available perioperative variables. In addition to the predicted probability, the application also provides individualized SHAP waterfall plots to visualize the contribution of each predictor to the estimated risk, thereby improving model transparency and interpretability in clinical practice.
The tool may assist perioperative clinicians and nursing staff in identifying patients at increased risk of PPCs who may benefit from enhanced postoperative respiratory surveillance and targeted preventive management. The application is freely accessible at: https://mlmodel-livercancer.shinyapps.io/mlmodel-livercancer/.
Discussion
PPCs impose substantial medical and financial burdens on patients undergoing hepatectomy. Therefore, early identification of patients at increased risk, together with timely and targeted preventive strategies, may help optimize postoperative management. To address this clinical need, in the present study, we developed and externally evaluated an explainable machine-learning prediction model for PPC risk stratification after hepatectomy in patients with PLC using routinely available perioperative clinical variables.
Among the evaluated algorithms, the NB model demonstrated the most balanced overall performance across the development and internal testing cohorts and maintained stable predictive performance when assessed in an independent but geographically and institutionally proximate external validation cohort. To improve transparency and facilitate clinical interpretation, SHAP analysis was applied to quantify both global feature importance and patient-level predictor contributions. The final model was subsequently implemented as a web-based risk calculator, providing individualized PPC risk estimates and SHAP-based explanations to support postoperative risk stratification.
Main findings
With the increasing availability of electronic health data, clinical prediction modeling has emerged as a valuable approach for individualized risk estimation and perioperative decision support. Previous studies have explored PPC prediction after hepatectomy using conventional statistical approaches and machine-learning methods. For example, Wang et al. developed a nomogram for intensive care unit (ICU) patients after hepatectomy with moderate discrimination performance (AUC =0.713) (32), while Xu et al. developed LR-based risk estimation models using retrospective clinical datasets (33).
More recently, machine-learning approaches have been applied to postoperative risk prediction in patients undergoing hepatectomy, demonstrating potential advantages in capturing complex relationships among heterogeneous clinical variables (34,35). Li et al. developed machine-learning models for predicting PPCs after laparoscopic hepatectomy and identified LR as the optimal algorithm in their dataset (36). However, differences in patient populations, surgical procedures, predictor availability, and validation strategies limit direct comparison among existing models.
In the present study, we developed and externally evaluated an explainable machine-learning prediction model for PPC risk stratification after hepatectomy using routinely collected perioperative clinical variables. Eight algorithms representing complementary modeling strategies were evaluated within a prespecified prediction-model development framework. Model selection was not based solely on retrospective discrimination performance but incorporated multiple clinically relevant domains, including discrimination, precision-recall performance under class imbalance, calibration, classification performance, and DCA.
Among the evaluated algorithms, the NB model demonstrated the most balanced overall performance and was selected as the final model. Although flexible tree-based ensemble methods, including XGBoost and LightGBM, achieved higher apparent discrimination in the training cohort, their performance was attenuated during internal testing and external validation. This finding suggests that increased model complexity did not necessarily translate into improved generalizability in this dataset.
Similarly, although LR and RF demonstrated favorable discrimination-related metrics, their relatively lower precision indicated a greater proportion of false-positive classifications, which may reduce clinical efficiency when applied for targeted postoperative surveillance. Given the moderate sample size and event frequency of this cohort, a relatively parsimonious model may provide a more favorable balance between predictive performance, calibration, and robustness (37). These findings highlight the importance of evaluating clinical prediction models across multiple performance domains rather than prioritizing a single discrimination metric.
The NB model demonstrated consistent predictive performance across the internal testing and the geographically and institutionally proximate external validation cohort. The favorable performance observed in this study likely reflects the combined contribution of the selected predictor set, preprocessing strategy, and modeling framework rather than intrinsic superiority of the NB algorithm itself. Therefore, these findings should be interpreted as model-specific observations within the present clinical context, and further validation in diverse healthcare settings is required before broader application.
In addition, direct comparisons with established PPC risk scores or conventional clinical prediction tools were beyond the scope of this study and should be addressed in future investigations. To further evaluate model robustness against potential heterogeneity of the composite PPC endpoint, a sensitivity analysis was performed using severe PPCs as an alternative outcome definition. Although the primary endpoint was based on standardized EPCO criteria, individual PPC components may differ in severity and clinical implications.
The NB model maintained consistent predictive performance under this stricter outcome definition, with AUC values remaining above 0.80 across the training, internal testing, and external validation cohorts, suggesting that the model captured clinically meaningful respiratory deterioration rather than only less severe complications. However, these findings should be interpreted cautiously because severe PPCs occurred less frequently, resulting in greater statistical uncertainty. Larger multicenter studies with sufficient numbers of severe events are required to further validate and recalibrate the model for severity-specific prediction.
Despite their predictive potential, machine-learning models are often considered difficult to interpret because of their complex computational structures (38). To improve transparency, SHAP analysis was applied to the final NB model to quantify the contribution of individual predictors to individualized PPC risk estimates. Age, portal triad clamping duration, and intraoperative blood transfusion showed the greatest contributions to model predictions, followed by chronic respiratory disease, ASA classification, surgical approach, hepatectomy type, and PNI.
Patient-related characteristics identified by SHAP analysis provide clinically plausible explanations for individual risk estimates. Advanced age may reflect reduced pulmonary reserve, impaired respiratory mechanics, and decreased physiological tolerance to surgical stress (7,39). Chronic respiratory diseases may increase susceptibility to postoperative respiratory deterioration through impaired airway function, reduced pulmonary reserve, and increased vulnerability to anesthesia-related respiratory stress (6,40).
Lower PNI values may indicate impaired nutritional and immune status, which have been associated with reduced physiological recovery capacity and increased postoperative morbidity (41). Higher ASA classifications may similarly reflect greater systemic disease burden and limited physiological reserve (42,43).
Several surgical and intraoperative variables also contributed substantially to model predictions. An open surgical approach may increase PPC risk through greater postoperative pain, impaired diaphragmatic movement, and reduced respiratory mechanics compared with minimally invasive approaches (44,45). Resections involving segments VII or VIII may represent technically demanding procedures associated with increased operative complexity and potential diaphragmatic manipulation (9,46).
Longer portal triad clamping duration may reflect greater surgical complexity and may contribute to systemic inflammatory responses associated with postoperative organ dysfunction (47,48). Intraoperative blood transfusion has also been reported to correlate with adverse pulmonary outcomes through mechanisms including transfusion-related inflammatory responses and fluid-related complications (49,50). Importantly, SHAP-derived feature contributions represent associations with model predictions rather than causal relationships.
Nevertheless, the identified predictors provide clinically interpretable information that may assist perioperative teams in recognizing patients who could benefit from enhanced postoperative respiratory surveillance.
Clinical implications and future research
The NB-based prediction model was developed as a web-based calculator to facilitate individualized postoperative risk stratification after hepatectomy. Because several predictors incorporated into the final model, including portal triad clamping duration and intraoperative blood transfusion, become available only after completion of surgery, the model is not intended for preoperative counseling, preoperative respiratory optimization, or intraoperative modification of anesthetic or fluid management strategies. Instead, the model was designed for immediate postoperative risk assessment, particularly during transition of care from the operating room to the post-anesthesia care unit (PACU) or surgical ward, when all required predictors become available.
By entering routinely collected perioperative variables, including baseline clinical characteristics and key intraoperative factors such as surgical approach, portal triad clamping duration, and intraoperative blood transfusion, clinicians can obtain an individualized estimated probability of PPC occurrence. Patients identified as having elevated predicted risk may benefit from closer postoperative clinical assessment and enhanced respiratory surveillance, including more frequent monitoring of respiratory status and oxygenation, early mobilization, respiratory physiotherapy, optimized analgesia, airway secretion management, and careful fluid management according to institutional protocols and clinician judgment. Conversely, patients with lower predicted risk may continue standard postoperative management, potentially supporting more individualized allocation of postoperative monitoring resources.
The web-based calculator is intended as an adjunctive clinical decision-support tool rather than an autonomous clinical decision system. The predicted probability and predefined classification threshold derived from the development cohort are designed for risk stratification and should not be interpreted as treatment thresholds or automatic triggers for specific interventions. Instead, the model provides an objective risk estimate that can complement clinical assessment and facilitate communication among surgeons, anesthesiologists, and nursing teams.
Furthermore, the integration of SHAP-based explanations enables visualization of individual predictor contributions, improving transparency and supporting clinician understanding of personalized risk estimates.
Limitations
Several limitations should be acknowledged. First, although this study included an independent external validation cohort from a separate hospital, both institutions were located within the same city and affiliated with the same university healthcare system. Therefore, similarities may exist in surgical expertise, perioperative management pathways, EMR structures, referral patterns, and patient characteristics.
Accordingly, the current evaluation should be interpreted as an independent but geographically and institutionally proximate external validation rather than definitive evidence of broad model transportability across different healthcare systems. Future studies involving geographically diverse centers, unrelated healthcare networks, and prospective multicenter cohorts are required to further evaluate model transportability, recalibration requirements, and clinical applicability.
Second, PPCs were assessed within 30 days after surgery, and the current study did not capture the temporal sequence of individual complications, long-term respiratory outcomes, or post-discharge pulmonary events. Although a sensitivity analysis using severe PPCs demonstrated generally consistent model performance under an alternative severity-based outcome definition, the number of severe PPC events was substantially smaller than that of the primary composite endpoint. Therefore, these findings should be interpreted as supportive evidence of model robustness rather than definitive validation for severe PPC prediction, and further studies with larger numbers of severe events are required.
Third, several potentially relevant predictors were unavailable in the EMR systems, including intraoperative ventilation parameters, cumulative smoking exposure, and comprehensive pulmonary function test results. The absence of these variables may have limited comprehensive perioperative risk characterization, introduced residual confounding, and affected model performance and transportability. Future studies incorporating additional respiratory-related variables may further improve risk estimation.
Fourth, although the composite PPC endpoint improves event capture and reflects clinically relevant postoperative respiratory morbidity, heterogeneity among PPC components may introduce variability in underlying mechanisms and severity. Future studies with larger sample sizes may allow development of component-specific prediction models. Furthermore, direct comparisons with established PPC risk scores or conventional clinical prediction tools were beyond the scope of the present study and should be addressed in future comparative effectiveness studies.
Finally, although SHAP analysis improved model transparency by illustrating the contribution of individual predictors to individualized predictions, these model-derived associations should not be interpreted as causal relationships. The identified predictors may serve as hypothesis-generating factors for future mechanistic investigations. Prospective implementation studies are needed to determine whether integration of the prediction model into clinical workflows and risk-adapted management pathways can improve postoperative outcomes, enhance resource allocation, or reduce PPC-related morbidity.
Conclusions
This study developed and independently evaluated an explainable machine-learning model for individualized PPC risk stratification after hepatectomy in patients with PLC. Among the evaluated algorithms, the NB model demonstrated the most balanced overall performance across discrimination, precision-recall performance, calibration, classification performance, and clinical utility. SHAP analysis provided interpretable insights into individualized predictions, with advanced age, intraoperative blood transfusion, and prolonged portal triad clamping duration identified as major contributors to model-derived PPC risk estimates.
The final NB model was implemented as a web-based calculator that may assist perioperative teams in identifying patients at increased risk and supporting individualized postoperative respiratory surveillance after hepatectomy. However, the current model should be considered a decision-support tool rather than a replacement for clinical assessment or an established intervention pathway. Further prospective multicenter studies involving geographically diverse populations are required to evaluate model transportability, recalibration requirements, clinical impact, and comparative performance against existing PPC risk assessment tools before broader clinical implementation.
Supplementary