Study design · Research feature

Development and validation of a clinical prediction model for postoperative atrial fibrillation after lung cancer surgery: a machine-learning-based study

The study developed and validated a prediction model for postoperative atrial fibrillation (POAF) in 540 patients undergoing lung cancer surgery.

Adapted from research by Yi Xu, Ting Lu, Ke Xu and colleagues.

Journal publication · 2026-06-04 · Attribution & reuse
In this article
Editorial illustration of aperture mechanism.

Editor’s introduction

The study developed and validated a prediction model for postoperative atrial fibrillation (POAF) in 540 patients undergoing lung cancer surgery. Using LASSO regression, researchers identified six predictors: age, education level, hypertension, marital status, postoperative pain score, and surgical approach. It achieved an AUC of 0.855 and demonstrated acceptable precision, recall, and F1 score, with good calibration and net benefit across clinically relevant thresholds. The model was translated into a nomogram for practical use in clinical settings. The evidence supports the model’s ability to provide individualized risk estimates, though performance declined in the test cohort compared to training, indicating limitations in generalizability. The study highlights that simpler models can outperform complex ones in real-world clinical applications when interpretability and consistency are prioritized.

Introduction

Postoperative atrial fibrillation (POAF) is a common cardiac complication after thoracic surgery, particularly following lung cancer resection, with reported incidence rates ranging from 2%–20%. Although POAF is often transient, it is associated with adverse clinical outcomes including haemodynamic instability, thromboembolic events, stroke, heart failure, prolonged hospitalisation, higher healthcare costs, and increased postoperative mortality. Early identification of patients at high risk of POAF is therefore essential for optimising perioperative monitoring and preventive strategies.

Current approaches to POAF risk assessment rely mainly on individual clinical factors such as advanced age, cardiovascular comorbidities, and the invasiveness of surgery. Several risk models have been developed, primarily in cardiac surgery populations (–); however, their applicability to lung cancer surgery is limited due to differences in patient characteristics, surgical stress, and perioperative management. Moreover, many existing models include a restricted number of predictors and fail to account for complex interactions among demographic factors, perioperative variables, inflammatory responses, and cardiac structural or functional parameters. Consequently, reliable surgery-specific prediction tools for POAF after lung cancer resection remain lacking.

Machine-learning (ML) techniques have recently attracted increasing attention in perioperative risk prediction because of their ability to integrate multidimensional clinical data and model non-linear relationships among predictors. Prior studies have shown that ML-based models can outperform traditional statistical methods in predicting postoperative complications. Nevertheless, highly complex models are prone to overfitting and often lack interpretability, which may limit their clinical applicability and acceptance by clinicians. In the perioperative setting, an ideal prediction model should achieve a balance between discrimination, calibration, robustness, and interpretability to support individualised clinical decision-making.

Therefore, the aim of this study was to develop and validate a prediction model for POAF in patients undergoing lung cancer surgery using routinely available perioperative data. Multiple ML algorithms were systematically compared, and the most clinically robust model was selected based on discrimination, calibration, and clinical utility. Using predictors identified by least absolute shrinkage and selection operator (LASSO) feature selection, an interpretable nomogram was constructed to facilitate individualised POAF risk estimation and to support perioperative risk stratification and personalised management. This approach addresses the current lack of dedicated POAF prediction tools for lung surgery patients and leverages machine-learning techniques to potentially improve risk stratification in this population.

Outcome and candidate predictors

The primary outcome was the occurrence of POAF. POAF was defined as new-onset atrial fibrillation occurring during the postoperative hospital stay, from postoperative day 0 to discharge, lasting at least 30 s and documented by standard 12-lead electrocardiography or continuous electrocardiographic monitoring. Postoperative rhythm monitoring was performed according to institutional routine practice. Patients routinely underwent continuous bedside electrocardiographic monitoring during the early postoperative period, generally for 24–72 h depending on clinical condition, surgical complexity, and perioperative risk. After discontinuation of continuous monitoring, additional 12-lead electrocardiography or rhythm assessment was performed when patients developed symptoms such as palpitations, chest discomfort, dyspnoea, haemodynamic instability, or abnormal pulse/rhythm findings during routine ward observation. All POAF episodes detected during the postoperative hospital stay were recorded.

Candidate predictors were selected a priori based on clinical relevance and existing literature, and included demographic characteristics, comorbidities, perioperative variables, laboratory parameters, inflammatory markers, cardiac functional indices, and postoperative pain scores. All candidate predictors were collected preoperatively or during the early postoperative period before the occurrence of POAF. Accordingly, the resulting model was intended for early postoperative risk stratification rather than purely preoperative prediction. Postoperative pain score was assessed using the Numeric Rating Scale after recovery from anaesthesia during the early postoperative period. For patients who developed POAF, the earliest available pain score recorded before the onset or diagnosis of POAF was used. Pain scores recorded after POAF onset were not used as predictors. For patients without POAF, the corresponding early postoperative pain score recorded during routine postoperative assessment was used. In this study, lung cancer surgery referred to therapeutic pulmonary resection performed for patients with lung cancer. According to operative records, surgical approach was classified as video-assisted thoracoscopic surgery (VATS) or open thoracotomy. The extent of resection included wedge resection, segmentectomy, and lobectomy. Surgical approach and extent of resection were extracted from medical records as perioperative candidate variables because they may reflect differences in surgical invasiveness, operative stress, and POAF risk. Continuous variables included age, postoperative pain score, laboratory values, cardiac functional indices (e.g., left ventricular ejection fraction, atrial dimensions), operative time, and length of chest drainage. Categorical variables included sex, education level, marital status, hypertension status, surgical approach, extent of resection, tumour characteristics, and medication history.

Data preprocessing

Prior to model development, data preprocessing was performed to handle missing values and prepare variables for analysis. Continuous variables were kept on their original scale, and any missing values were imputed using the median value derived from the training cohort. Categorical variables were encoded as dummy variables (one-hot encoding). If a categorical predictor had missing entries, a separate “Unknown” category was created to retain those cases without introducing bias, and to avoid excessive data loss. All preprocessing steps (imputation and encoding) were performed using only the training set, and then applied to the test set, to prevent data leakage. The same final set of predictors was used for all models to ensure comparability of performance.

Feature selection using LASSO regression

To identify the most informative predictors while minimising overfitting, feature selection was performed with LASSO regression on the training cohort. After dummy encoding of categorical variables, a 10-fold cross-validation procedure (with a fixed fold assignment and random seed for reproducibility) was run to determine the optimal regularisation parameter (λ) based on the binomial deviance. We selected the largest λ within one standard error of the minimum deviance (the λ_1se criterion) to derive a parsimonious and stable feature set. Predictors with non-zero coefficients at λ_1se were retained for subsequent model development. This procedure yielded six predictors: age, education level, hypertension, marital status, postoperative pain score, and surgical approach (Figures 2A,B shows the LASSO coefficient profiles and cross-validation curve for λ selection.)

Statistical analysis

Baseline characteristics were summarised using appropriate descriptive statistics. Continuous variables were reported as mean ± standard deviation (SD) and compared between groups using Student’s t-test or the Mann–Whitney U-test, as appropriate based on normality of distribution. Categorical variables were expressed as counts and percentages and compared using the χ2 test or Fisher’s exact test when expected cell counts were low. For model development, the training set was used for all feature selection and model training, and the test set was used only for evaluating final model performance. The primary discrimination metric for each model was the AUC, with higher AUC indicating better differentiation between patients with and without POAF. We also calculated accuracy, precision, recall, and F1 score to provide a comprehensive assessment of classification performance in both cohorts. ROC curves were generated for each model in both the training and test sets to visualise discriminative ability. Model calibration was assessed by plotting predicted vs. observed event rates and examining how closely the curves followed the 45° reference line. Clinical utility was evaluated via DCA, as described above, by comparing net benefits. All statistical analyses and model training were performed using R software (version 4.4.2). Key R packages used included glmnet, caret, pROC, rms, rmda, ggplot2, randomForest, xgboost, e1071, and nnet. All significance tests were two-sided, and a P value < 0.05 was considered statistically significant.

Discussion

In this study, we developed and validated a prediction model for POAF in patients undergoing lung cancer surgery using routinely available perioperative clinical data. By applying LASSO regression for feature selection and systematically comparing multiple ML algorithms, we identified logistic regression (LR) as the most robust and clinically applicable model in this context. We then constructed an interpretable nomogram based on the LR model to facilitate individualised POAF risk estimation at the point of care. This work contributes to thoracic surgical risk stratification by providing a POAF-focused tool tailored to lung cancer surgery patients. By focusing specifically on lung cancer surgery and prioritising both robustness and interpretability, this study complements existing POAF research and addresses a clinically relevant gap in thoracic surgical risk stratification. Importantly, this study emphasises that model robustness and clinical translatability may be more relevant than maximising apparent predictive accuracy in real-world perioperative settings when developing perioperative risk prediction tools.

The reported incidence of POAF after lung cancer surgery varies substantially across studies, reflecting marked heterogeneity in patient populations, surgical extent, and perioperative management. For example, Cardinale et al. reported that the incidence of POAF after lung cancer surgery could be as high as 42%, particularly in patients undergoing extensive resections. In contrast, Ishibashi et al. observed a lower incidence ranging from 6.4% to 12.6% following pulmonary lobectomy. Similarly, Ruan et al. reported a POAF incidence of 8.38% in a cohort of patients with non–small cell lung cancer undergoing lung resection. These discrepancies across studies suggest that the incidence of POAF after lung cancer surgery is not a fixed value but varies substantially depending on surgical extent, patient characteristics, perioperative monitoring strategies, and study design. Notably, Tong et al. reported an incidence of 2.6% for clinically important new-onset POAF in a large Chinese cohort. This incidence was substantially lower than that observed in the present study. However, this discrepancy should not be attributed to age alone, because the mean age of the two cohorts was broadly comparable. Several methodological and clinical differences may explain the higher incidence observed in our study. First, the outcome definition differed: Tong et al. focused on clinically important new-onset POAF, whereas our study recorded electrocardiographically documented POAF occurring during the postoperative hospital stay, including potentially transient or less symptomatic episodes. Second, the surgical case mix differed, with approximately one-third of our cohort undergoing open thoracotomy, which may be associated with greater surgical trauma, inflammatory response, postoperative pain, and sympathetic activation. Third, differences in postoperative rhythm monitoring duration and modality may influence the detection of silent or transient POAF. Therefore, direct comparison of POAF incidence across studies should be made cautiously, taking into account differences in outcome definition, monitoring strategy, surgical approach, and case mix. This further underscores the importance of developing institution-specific and procedure-specific risk prediction models rather than relying on a single universal incidence estimate.

In addition, two sociodemographic variables—marital status and education level—were retained in the final model through LASSO feature selection. These variables should not be interpreted as direct mechanistic or pathophysiological determinants of POAF, as they do not provide a direct biological explanation for atrial electrical instability. Their retention may instead reflect contextual or care-related associations related to nuanced factors, such as differences in health literacy, symptom reporting, care-seeking behaviour, perioperative adherence, access to postoperative support, or other residual confounding. It is also possible that their predictive contribution partly reflects centre-specific patterns or statistical noise in this retrospective dataset. Therefore, these variables should be interpreted cautiously and should not be used in isolation for clinical decision-making. Their role in the model requires further assessment in external cohorts with different social and healthcare contexts.

Although several complex machine-learning models, including random forest, neural networks, and XGBoost, demonstrated excellent apparent performance in the training cohort, their discrimination and calibration deteriorated substantially in the independent test cohort. The near-perfect AUCs observed for some flexible algorithms in the training cohort should therefore be interpreted as apparent performance rather than evidence of true predictive superiority. In a moderate-sized dataset with a limited number of POAF events, highly flexible models may fit random noise, centre-specific practice patterns, or idiosyncratic correlations in the training data. The decline in performance in the independent test cohort suggests potential overfitting and reduced transportability even within the same institution. This finding reinforces the importance of evaluating not only discrimination but also calibration, clinical utility, and stability across datasets when selecting a model for clinical translation. This performance degradation persisted despite the use of cross-validation and standard hyperparameter tuning strategies, suggesting that model instability was driven by data characteristics rather than insufficient optimisation. Overall, these findings highlight an important methodological consideration in perioperative risk prediction. Postoperative atrial fibrillation after lung cancer surgery represents a multifactorial clinical outcome characterised by moderate event rates, heterogeneous perioperative influences, and a relatively high signal-to-noise ratio. This may explain why highly flexible algorithms showed reduced generalisability when applied to unseen patients. In contrast, the logistic regression model demonstrated consistently stable performance across training and test cohorts, with preserved discrimination, acceptable calibration, and favourable net benefit across clinically relevant threshold probabilities. In the decision curve analysis, the LR model provided greater net benefit than the treat-all and treat-none strategies across clinically relevant threshold probabilities, further supporting its potential clinical usefulness. This robustness is particularly relevant for clinical risk stratification, where reproducibility and reliability often outweigh marginal gains in apparent predictive accuracy. In surgical risk prediction, a modest reduction in apparent discrimination may be acceptable if accompanied by improved reproducibility, calibration, and clinical interpretability. From a methodological perspective, penalised regression-based approaches are well suited to moderate-sized clinical datasets with limited event counts, as they balance model complexity and variance while maintaining interpretability.

Importantly, the choice of logistic regression in this study was not merely a default or conservative option, but rather a deliberate decision aligned with the intended clinical application of the model. Risk prediction tools in thoracic surgery must support transparent decision-making, facilitate external validation, and enable bedside implementation. Compared with more complex algorithms, logistic regression offers clear advantages in interpretability, stability, and translational potential, particularly when the ultimate goal is to inform perioperative management rather than to maximise algorithmic performance in isolation. In particular, this nomogram may be most useful during the early postoperative period, when decisions regarding monitoring intensity and preventive strategies are actively made.

Recent studies have increasingly explored artificial intelligence and machine learning applications in thoracic surgery, including pulmonary nodule detection and characterisation, radiomics-based tumour classification, three-dimensional reconstruction, surgical planning, and postoperative outcome prediction. In parallel, artificial intelligence has also been increasingly applied in thoracic imaging, with emerging roles in image interpretation, lesion detection, quantitative imaging analysis, and clinical decision support. More specifically, AI-assisted endobronchial ultrasound has been evaluated for differentiating benign and malignant thoracic lymph nodes using pathological reference standards, providing a relevant example of how robust reference outcomes can support the interpretation of model performance and diagnostic generalizability. In addition, Ozcelik et al. compared eight pre-trained convolutional neural network models for malignancy prediction using EBUS images with pathology-confirmed outcomes and reported stable training–testing performance for selected models, providing further context for interpreting model robustness, overfitting, and generalizability in clinically oriented AI studies. These studies highlight the potential of AI to integrate multidimensional clinical and imaging data to support diagnosis, staging, perioperative decision-making, and postoperative management. However, recent evidence also emphasises persistent methodological challenges, including heterogeneous model development, limited external validation, overfitting, insufficient interpretability, and variable clinical transferability. In this context, our findings are consistent with the broader literature suggesting that AI-based models in thoracic medicine should not be evaluated solely by apparent discrimination, but also by calibration, robustness, interpretability, and clinical utility. From a clinical translation perspective, the present findings should be interpreted with caution until the model is externally validated in independent cohorts. Although the LR-based nomogram showed more stable performance than more flexible algorithms, its generalizability to other institutions, surgical populations, and monitoring protocols remains uncertain. Future work should focus on external validation, prospective impact assessment, and integration into perioperative workflows to determine whether model-guided monitoring or preventive strategies can improve patient outcomes.

Conclusions

In conclusion, we have developed a robust and interpretable prediction model for POAF following lung cancer surgery. Compared to more complex ML algorithms, the logistic regression model demonstrated superior generalisability, ease of use, and clinical usefulness in this setting. We translated this model into a nomogram that provides surgeons and anesthesiologists with a practical tool for quantifying an individual patient’s risk of POAF. This tool can aid in personalised perioperative decision-making, such as identifying patients who may benefit from enhanced monitoring or preventive therapies. Our study emphasizes that in this scenario, simpler may be better—a carefully validated and interpretable model can achieve superior generalisability and gain clinician trust. Before recommending routine clinical use of our nomogram, further external validation is required, and we encourage prospective studies to assess whether implementing such risk-guided strategies can indeed reduce POAF incidence or improve patient outcomes. With appropriate validation, this predictive tool has the potential to improve perioperative care by enabling early, individualized interventions for patients at risk of POAF.