An explainable attention-gated stacking ensemble model for predicting survival in non-small cell lung cancer: development and validation
Original Article

An explainable attention-gated stacking ensemble model for predicting survival in non-small cell lung cancer: development and validation

Chenrui Yin1#, Zhi Wang1,2#, Anni Zhang3#, Yi Wang4, Dingqin Cai5, Lijiao Xie1, Lvjun Yan6, Kai Niu1, Chunli Jian1, Linpeng Zheng1, Bin Fang4, Yi Zhou1, Zepeng Liu4, Jianguo Sun1

1Cancer Institute, Xinqiao Hospital, Army Medical University, Chongqing, China; 2The 940 Hospital Joint Logistic Support Force of PLA, Lanzhou, China; 3School of Finance, Southwestern University of Finance and Economics, Chengdu, China; 4School of Computer Science, Chongqing University, Chongqing, China; 5The 921st Hospital of PLA (Second Affiliated Hospital of Hunan Normal University), Changsha, China; 6Tumor and Hematology Department, University-Town Hospital of Chongqing Medical University, Chongqing, China

Contributions: (I) Conception and design:; (II) Administrative support: ; (III) Provision of study materials or patients: ; (IV) Collection and assembly of data:; (V) Data analysis and interpretation:; (VI) Manuscript writing: All authors; (VII) Final approval of manuscript: All authors.

#These authors contributed equally to this work.

Correspondence to: Yi Zhou, MD. Physician, Cancer Institute, Xinqiao Hospital, Army Medical University, Chongqing 400037, China. Email: zhouy2011@163.com; Zepeng Liu, PhD. Professor, School of Computer Science, Chongqing University, Chongqing 400044, China. Email: liuzepeng0610@163.com; Jianguo Sun, MD. Director, Cancer Institute, Xinqiao Hospital, Army Medical University, Chongqing 400037, China. Email: sunjianguo@tmmu.edu.cn.

Background: Non-small cell lung cancer (NSCLC) remains the leading cause of cancer-related mortality worldwide, and accurate survival prediction is essential for individualized treatment planning. Existing prognostic models often rely on single algorithms with limited capacity to capture the complexity inherent in clinical data. This study aimed to develop, validate, and interpret an attention-gated stacking ensemble model for predicting 1-, 3-, 5-year overall survival (OS) in NSCLC patients.

Methods: A retrospective cohort of 67,400 NSCLC patients from the Surveillance, Epidemiology, and End Results (SEER) database (2004–2021) was analyzed. A dual-filtering strategy combining Pearson and Spearman correlation analysis identified 11 prognostic features. An attention-gated stacked ensemble model was constructed, consisting of eleven diverse base learners plus a feature attention-gated mechanism, which ultimately generated survival probability estimate of 1, 3, and 5 years. Model performance was assessed using area under the receiver operating characteristic curve (AUC), confusion matrices, calibration curves with Brier scores, and decision curve analysis (DCA). An independent external validation cohort of 623 patients from Xinqiao Hospital (2015–2023) was used to evaluate generalizability. SHapley Additive exPlanations (SHAP) analysis was employed for model explanation. A web-based tool was developed for clinical application.

Results: On the internal test set, the attention-gated stacking ensemble model achieved AUC values of 0.799, 0.799, and 0.778 for 1-, 3-, and 5-year OS prediction, respectively, outperforming all eleven individual base learners and a conventional stacking model without the attention gate. On external validation, AUC values reached 0.817, 0.807, and 0.825, with Brier scores of 0.127, 0.107, and 0.095, demonstrating robust cross-population generalizability. SHAP analysis identified metastasis (M) stage, tumor size, and lymph node (N) stage as the three most influential predictors, and the learned attention gate weights exhibited concordant importance rankings. A publicly accessible web-based calculator was deployed to facilitate personalized survival estimation at the point of care.

Conclusions: The proposed attention-gate stacking ensemble model provides accurate and explainable survival predictions for NSCLC patients, outperforming conventional single-algorithm and standard stacking approaches. The integration of a feature-wise attention gate mechanism enhances both predictive performance and clinical transparency, supporting its potential utility in personalized oncological decision-making. The deployed web-based clinical decision support tool further bridges the gap between algorithmic development and bedside application.

Keywords: Non-small cell lung cancer (NSCLC); stacking ensemble; attention mechanism; survival prediction; machine learning; SHapley Additive exPlanations (SHAP); clinical decision support


Submitted Mar 28, 2026. Accepted for publication May 28, 2026. Published online Jun 23, 2026.

doi: 10.21037/jtd-2026-0848


Highlight box

Key findings

• (Report here about the key findings of the study)

What is known and what is new?

• Non-small cell lung cancer (NSCLC) survival prediction traditionally relies on tumor-node-metastasis (TNM) staging, which provides population-level estimates but may not capture individual outcome heterogeneity. Ensemble machine learning methods have shown promise in cancer prognosis, but conventional stacking architectures treat all base learners equally without adaptive feature weighting. The Surveillance, Epidemiology, and End Results (SEER) database spans multiple American Joint Committee on Cancer (AJCC) editions (v7, v8, v9), introducing temporal heterogeneity in T stage definitions that complicates direct prognostic comparisons across eras.

• We propose an attention-gated stacking ensemble model that integrates 11 diverse base learners with a sigmoid-based feature-wise attention gate to dynamically prioritize informative predictive signals on a patient-specific basis. Instead of using the evolving categorical T stage, we substitute continuous primary tumor size—an edition-invariant parameter—to circumvent staging-version confounding in multi-decade registry data. The model achieves areas under the receiver operating characteristic curve (AUC) of 0.799, 0.799, and 0.778 for 1-, 3-, and 5-year overall survival (OS) prediction on internal testing, and robust external validation AUCs of 0.817, 0.807, and 0.825 on a geographically distinct Chinese cohort (N=623).

What is the implication, and what should change now?

• The attention-gated architecture provides intrinsic interpretability via learned attention weights, corroborated by SHapley Additive exPlanations (SHAP) analysis identifying metastasis (M) stage, tumor size, and N stage as the top prognostic determinants—consistent with clinical consensus.

• A publicly accessible web-based clinical decision support tool is deployed to facilitate personalized survival estimation at the point of care, bridging the gap between algorithmic development and bedside application.


Introduction

Lung cancer remains the most commonly diagnosed malignancy and the leading cause of cancer-related death globally, accounting for approximately 2.2 million new cases and 1.8 million deaths annually (1). Non-small cell lung cancer (NSCLC) constitutes approximately 80–85% of all lung cancer diagnoses (2). Despite substantial advances in surgical techniques, targeted therapy, and immunotherapy, the overall five-year survival rate remains disappointingly low, ranging from approximately 60% for stage I to less than 10% for stage IV disease (3). Accurate postoperative survival prediction is critical for guiding individualized treatment strategies and optimizing resource allocation (4).

Traditional prognostic assessment has relied predominantly on the tumor-node-metastasis (TNM) staging system. While clinically valuable, it provides population-level estimates that may inadequately capture individual outcome heterogeneity (5). Furthermore, the TNM system has undergone several revisions [American Joint Committee on Cancer (AJCC) versions 7, 8, and 9] during the period covered by large-scale registries, with the T classification subject to the most substantial modifications regarding size thresholds and descriptors (5). In databases spanning multiple decades such as the Surveillance, Epidemiology, and End Results (SEER) program, temporal heterogeneity may introduce systematic inconsistencies that complicate direct prognostic comparisons (6). To circumvent this limitation, the present study adopted primary tumor size—a continuous, edition-invariant variable—as a direct substitute for T stage. N and M stages, being relatively stable across editions, were retained as categorical variables. This approach mitigates staging-version confounding while enhancing clinical interpretability.

In recent years, machine learning (ML) has demonstrated promise in capturing complex, non-linear patterns that traditional statistical models may miss (7). Several ML algorithms, including gradient boosting machines, random forests, and neural networks, have been applied to NSCLC survival prediction with varying degrees of success.

Individual ML models are inherently constrained by their respective inductive biases; for example, tree-based methods may struggle with smooth decision boundaries, whereas linear models often fail to capture complex non-linear interactions without exhaustive feature engineering (8). To address these limitations, ensemble learning—specifically stacking (stacked generalization)—combines predictions from diverse base learners through a meta-learner. This approach leverages the complementary strengths of different algorithms while mitigating their individual shortcomings (9).

Nevertheless, traditional stacking architectures typically treat the outputs of all base learners with equal weight, lacking a dynamic mechanism to prioritize the most informative signals. Originally pioneered in natural language processing, attention mechanisms have emerged as a robust framework for adaptive feature weighting, enabling models to selectively focus on the most relevant inputs for each specific prediction. Incorporating an attention mechanism into an ensemble framework can significantly enhance both predictive precision and model explainability of feature weighting. Furthermore, SHapley Additive exPlanations (SHAP) ensure the necessary global and local transparency required for clinical adoption.

Despite these advances, gaps persist: most studies rely on single-algorithm approaches, attention mechanisms remain underexplored in oncology, external validation on geographically distinct populations is frequently absent (10), and the deployment of validated models as accessible clinical tools remains rare (11). To address these gaps, this study aimed to: (I) develop an attention-gate stacking ensemble model for predicting 1-, 3-, and 5-year overall survival (OS) in NSCLC; (II) comprehensively evaluate performance on internal and external cohorts; (III) provide transparent interpretation via SHAP and attention weights; and (IV) deploy the model as a web-based decision support tool. We present this article in accordance with the TRIPOD reporting checklist (available at https://jtd.amegroups.com/article/view/10.21037/jtd-2026-0848/rc) (10).


Methods

Cohort selection and dataset stratification

Data were obtained from the SEER Incidence Database (November 2023 submission), which covers approximately 47.9% of the U.S. population and provides comprehensive, population-based cancer registry data. We initially identified 149,953 patients diagnosed with NSCLC between 2004 and 2021. Patient identification was based on the International Classification of Diseases for Oncology, Third Edition (ICD-O-3) topography codes (C34.0–C34.9 for lung and bronchus) and morphology codes corresponding to adenocarcinoma, squamous cell carcinoma, adenosquamous carcinoma, large cell carcinoma, and other relevant NSCLC subtypes (12).

Patients were included if they had pathologically confirmed primary NSCLC and were 18 years of age or older at diagnosis. Exclusion criteria were: (I) missing or unknown clinicopathological information (including TNM stage, histopathological grade, or histological subtype); (II) survival time less than one month; (III) incomplete follow-up data; and (IV) classification as clinical stage I or stage IV as well as histopathological Grade I or Grade IV. Patients with stage I and IV tumors, as well as Grade I and IV tumors, were excluded to strictly align the SEER training cohort with histopathological grading distribution (Grade 2–3) of the external validation dataset from Xinqiao Hospital. After applying these criteria, 67,400 patients were included in the final analysis (Table 1).

Table 1

The clinical baseline characteristics of patients with NSCLC in different cohort of this study

Characteristics Training cohort (N=56,166) Testing cohort (N=11,234) Hospital cohort (N=623) G1 subgroup cohort (N=8,300)
Sex 29,935 (53.3) 6,042 (53.8) 448 (71.9) 3,275 (39.5)
Age group (years)
   <65 17,430 (31.0) 3,502 (31.2) 419 (67.3) 2,282 (27.5)
   65–74 20,703 (36.9) 4,124 (36.7) 168 (27.0) 3,055 (36.8)
   75–84 15,243 (27.1) 3,046 (27.1) 35 (5.6) 2,473 (29.8)
   ≥85 2,790 (5.0) 562 (5.0) 1 (0.2) 490 (5.9)
Histopathological grade
   1 31,409 (55.9) 6,218 (55.3) 402 (64.5) 7,541 (90.9)
   2 21,715 (38.7) 4,406 (39.2) 206 (33.1) 669 (8.1)
   3 1,423 (2.5) 293 (2.6) 11 (1.8) 19 (0.2)
   4 1,290 (2.3) 255 (2.3) 0 5 (0.1)
   5 329 (0.6) 62 (0.6) 4 (0.6) 66 (0.8)
Tumor grade
   1 0 0 0 8,300 (100.0)
   2 25,953 (46.2) 5,250 (46.7) 290 (46.5) 0
   3 30,213 (53.8) 5,984 (53.3) 333 (53.5) 0
N stage
   0 30,561 (54.4) 6,150 (54.7) 95 (15.2) 6,801 (81.9)
   1 5,933 (10.6) 1,144 (10.2) 29 (4.7) 350 (4.2)
   2 15,213 (27.1) 3,076 (27.4) 254 (40.8) 901 (10.9)
   3 4,459 (7.9) 864 (7.7) 245 (39.3) 248 (3.0)
M stage 15,601 (27.8) 3,073 (27.4) 526 (84.4) 1,193 (14.4)
   Brain metastasis 4,106 (7.3) 795 (7.1) 141 (22.6) 208 (2.5)
   Bone metastasis 5,649 (10.1) 1,126 (10.0) 264 (42.4) 325 (3.9)
   Liver metastasis 2,285 (4.1) 456 (4.1) 135 (21.7) 111 (1.3)
   Lung metastasis 5,025 (8.9) 1,020 (9.1) 270 (43.3) 520 (6.3)
   Tumor size (mm) 41.5 [25.2] 41.2 [24.9] 49.8 [22.8] 29.6 [21.8]
Tumor size by quartiles
   Q1 (≤21 mm) 14,068 (25.0) 2,808 (25.0) 63 (10.1) 3,915 (47.2)
   Q2 (21–35 mm) 15,093 (26.9) 3,035 (27.0) 131 (21.0) 2,323 (28.0)
   Q3 (35–57 mm) 13,261 (23.6) 2,713 (24.1) 195 (31.3) 1,148 (13.8)
   Q4 (>57 mm) 13,744 (24.5) 2,678 (23.8) 234 (37.6) 914 (11.0)
OS (95% CI) (%)
   1-year OS rate 64.9 (64.5–65.3) 64.4 (63.5–65.3) 87.6 (85.1–90.3) 84.12 (83.3–84.9)
   3-year OS rate 41.0 (40.6–41.4) 41.2 (40.3–42.2) 50.5 (46.6–54.8) 66.63 (65.6–67.7)
   5-year OS rate 22.8 (22.4–23.2) 22.6 (21.7–23.4) 31.3 (27.6–35.5) 46.54 (45.3–47.8)

Data are presented as n (%) or mean [standard deviation] unless otherwise specified. CI, confidence interval; M, metastasis; N, lymph node; NSCLC, non-small cell lung cancer; OS, overall survival.

To optimize clinical utility and align with tertiary hospital practice, we used a histopathological grade-based partitioning strategy. The primary derivation cohort included only Grade 2–3 tumors (N=67,400), excluding the clinically rare and indolent Grade 1 cases to prevent model dilution. This cohort was randomly split into a training cohort (N=56,166) and an internal testing cohort (N=11,234) using stratified sampling (Table 1). To rigorously assess model generalizability, the independent G1 subgroup cohort (Grade 1, N=8,300) was completely isolated as an out-of-distribution (OOD) validation set, separate from all model development stages (Table 1). This enabled a stress test of whether a model trained solely on Grade 2–3 tumors could maintain predictive value in a clinically distinct low-grade subgroup. From this cohort, 17 candidate clinical variables were initially extracted: age at diagnosis, sex, race, primary site, laterality, histological subtype, histopathological grade, tumor size, N stage, M stage, bone metastasis, brain metastasis, liver metastasis, lung metastasis, first malignant primary indicator (FMPI), treatment sequence and marital status. The median follow-up time for the entire SEER cohort was 28.0 months [interquartile range (IQR), 9.0–83.0 months], estimated by the reverse Kaplan-Meier method. Notably, our study population represented a real-world clinical mix of both surgical (postoperative) and non-surgical patients, with detailed treatment sequences documented in Table 1. The primary outcome assessed was OS status at 1, 3, and 5 years from the date of diagnosis.

External validation cohort

An independent external validation cohort was established from Xinqiao Hospital, Army Medical University, Chongqing, China (2015–2023). From an initial pool of over 6,000 NSCLC patients identified through probability sampling, 623 met the same eligibility criteria applied to the SEER cohort and were included for external validation (Table 1). The median follow-up time for the hospital cohort was 39.6 months (IQR, 18.9–78.0 months). The last follow-up date was December 2025.

This geographically and ethnically distinct cohort enabled assessment of the model’s cross-population generalizability, which is essential for establishing clinical validity beyond the derivation population (13). The SEER database does not contain detailed treatment information (e.g., specific chemotherapy regimens, immunotherapy, or surgical approaches). Therefore, treatment details were not included as predictors. The external validation cohort also lacked standardized treatment records, limiting adjustment for treatment-related confounding.

Data preprocessing and feature categorization

Continuous variables (age at diagnosis and tumor size) were normalized using z-score standardization to ensure zero mean and unit variance, thereby eliminating scale-dependent biases in distance-based and gradient-based algorithms (14). For tumor size specifically, its presentation in Table 1 follows the same quartile-based approach used for the variable in Figure 1. Tumor size quartiles (Q1–Q4) are defined based on the training cohort distribution (Q1 ≤21 mm, Q2 21–35 mm, Q3 35–57 mm, Q4 >57 mm). Categorical variables were transformed through one-hot encoding to avoid imposing artificial ordinal relationships among categorical levels. The final analysis cohort (n=67,400) was randomly partitioned into a training set (83%, n=56,166) and an internal test set (17%, n=11,234) using stratified sampling to maintain consistent outcome distributions across both subsets. To address class imbalance, the Synthetic Minority Oversampling Technique (SMOTE) was applied exclusively to the training set to generate synthetic minority samples. The internal test set and external validation set remained unaltered to prevent data leakage and to ensure that model performance was evaluated on the original data distribution. Outcome assessment was based on SEER registry data and hospital records; because the data were retrospectively collected, no blinding was performed.

Figure 1 Kaplan-Meier overall survival curves for 11 selected prognostic features were stratified. (A) Sex. (B) Age group. (C) Histologic type. (D) Tumor size group. (E) Tumor grade (Grade 2–3). (F) N stage (N0–N3). (G) M stage (M0 vs. M1). (H) Lung metastasis. (I) Bone metastasis. (J) Brain metastasis. (K) Liver metastasis. All comparisons reached statistical significance by log-rank test (P<0.001). The horizontal axis represents follow-up time (in months), and the vertical axis represents overall survival probability. Ranges in parentheses represent 95% confidence intervals. Q1: ≤21 mm; Q2: 21–35 mm; Q3: 35–57 mm; Q4: >57 mm. HR, hazard ratio; M, metastasis; N, lymph node; T, tumor.

Feature selection

Given that some clinical features are discrete variables that do not conform to a normal distribution, and the relationships between variables may be nonlinear, both Pearson correlation coefficients and Spearman rank correlation coefficients were used to assess the association between clinical features and survival time. To perform the dual-filtering strategy, we applied both selection criteria in parallel to all 17 original candidate variables, rather than in a sequential stepwise manner. A clinical feature was only retained for downstream modeling if it simultaneously satisfied both of the following independent filters: (I) exhibiting a statistically significant linear correlation with OS (Pearson P<0.05), and (II) possessing a non-negligible monotonic relationship with OS (Spearman |r| >0.05). Out of the 17 initial candidate variables, exactly 11 features concurrently met both criteria, demonstrating a high degree of consistency between the two mathematical approaches.

The choice of using the P value for the Pearson filter and the correlation coefficient |r| for the Spearman filter was strategically designed to balance statistical significance and clinical effect size. For the Pearson analysis, we utilized the P value to perform a rigorous hypothesis test of linear independence, thereby strictly controlling the type I error rate and ensuring that the identified linear trends were statistically reliable (15). Conversely, because large sample sizes can easily render extremely weak and clinically irrelevant associations statistically significant (P<0.05), we applied the Spearman rank correlation coefficient (|r| >0.05) as a practical effect-size threshold. This secondary filter successfully excluded features with statistically significant but clinically negligible or trivial monotonic associations, thereby mitigating the risk of overfitting and ensuring the robustness of downstream predictions (16). This dual-filtering strategy, integrating statistical correlation analysis with clinically relevant feature screening, enhances model robustness and the clinical interpretability of the selected feature set while reducing the inclusion of redundant and weakly informative variables (16).

Model design and evaluation

Model architecture

The proposed model employed a two-level stacking architecture augmented with a feature-wise attention gate mechanism (Figure 2).

Figure 2 Overall system architecture of the study. AUC, area under the receiver operating characteristic curve; CatBoost, categorical boosting; CV, cross-validation; GNB, Gaussian Naive Bayes; KNN, K-Nearest Neighbors; LDA, Linear Discriminant Analysis; LightGBM, Light Gradient Boosting Machine; MLP, multilayer perceptron; NSCLC, non-small cell lung cancer; Pbase; SEER, Surveillance, Epidemiology, and End Results; SGD, Stochastic Gradient Descent; SHAP, SHapley Additive exPlanations; SMOTE, Synthetic Minority Oversampling Technique; XGBoost, eXtreme Gradient Boosting.

Base learners

Eleven ML algorithms were selected as first-level base learners to maximize algorithmic diversity: eXtreme Gradient Boosting (XGBoost) (17), Light Gradient Boosting Machine (LightGBM) (18), Categorical Boosting (CatBoost) (19), Random Forest (19), Logistic Regression, Multilayer Perceptron (MLP), Stochastic Gradient Descent (SGD), Decision Tree, Linear Discriminant Analysis (LDA), Gaussian Naive Bayes (GNB), and K-Nearest Neighbors (KNN). Hyperparameters were optimized via grid search with five-fold cross-validation. To prevent data leakage, out-of-fold (OOF) predictions were generated, ensuring the meta-learner was trained exclusively on predictions unseen by the base learners during their initial training. The selection of these diverse algorithms was strategically motivated by the core principle of stacked generalization, which stipulates that the meta-learner performs optimally when the base learners possess distinct inductive biases and error profiles (20). Specifically, our selection spans tree-based ensemble methods (XGBoost, LightGBM, CatBoost, Random Forest, Decision Tree) to capture complex non-linear feature interactions and high-dimensional decision boundaries; parametric and linear models (Logistic Regression, SGD, LDA) to capture stable linear relationships; probabilistic approaches (GNB) for robust likelihood estimation; instance-based methods (KNN) to leverage localized clinical patterns; and neural networks (MLP) for hierarchical representation learning. This comprehensive variety ensures that the meta-classifier can leverage complementary algorithmic strengths, minimize individual model variance, and enhance prediction stability across heterogeneous clinical cohorts (21).

Attention gate mechanism

Predicted probabilities from the base learners were concatenated with the original 11 clinical features to form a 21-dimensional augmented vector. A sigmoid-based attention gate was applied for adaptive feature-wise weighting:

α=σ(Wx+b)x=αx

where σ denotes the sigmoid activation function, W and b are learnable parameters, x is the augmented feature vector, α represents the learned attention weights, and ⊙ denotes element-wise (Hadamard) multiplication. This mechanism allows the model to dynamically prioritize informative input dimensions while suppressing noisy or redundant signals (22), conceptually mirroring clinical feature selection.

Meta-classifier

Attention-weighted features were processed by an MLP meta-classifier comprising one hidden layer [32 neurons, rectified linear unit (ReLU) activation] with dropout (rate =0.3) to mitigate overfitting. The output layer used sigmoid activation to estimate survival probabilities for 1-, 3-, and 5-year horizons. The entire framework was trained end-to-end using binary cross-entropy loss and the Adam optimizer (learning rate =0.01, epoch =200, patience =20 epochs).

Model evaluation

The ability of the model to discriminate was assessed by the area under the receiver operating characteristic curve (AUC) and the confusion matrices. Calibration was evaluated using calibration curves and Brier scores, where lower Brier scores indicate better agreement between predicted probabilities and observed outcomes. Clinical utility was assessed through decision curve analysis (DCA), which quantifies the net benefit of the model against “treat all” and “treat none” reference strategies across a range of clinically relevant threshold probabilities (23). No model updating (e.g., recalibration) was performed on the external validation cohort; the model was evaluated as originally developed without any adjustments.

Computational framework

To ensure rigorous reproducibility, all data preprocessing, model implementation, and evaluation were performed using the Python programming language (version 3.9.23) within the Visual Studio Code integrated development environment (version 1.121). The foundational ML algorithms and evaluation frameworks were built using scikit-learn (version 1.5.2), lightgbm (version 4.6.0), xgboost (version 2.1.4), and catboost (version 1.2.8). The attention gate mechanism and MLP meta-classifier were developed using the PyTorch framework (torch, version 2.7.1+cu128). Data manipulation and balancing were managed via numpy (version 1.26.4), pandas (version 2.3.0), and imbalanced-learn (version 0.12.4). Model interpretation and survival metrics were implemented using shap (version 0.49.1) and lifelines (version 0.30.0). All performance plots and clinical decision curves were generated using matplotlib (version 3.9.4). All model training, hyperparameter grid searching, and deep learning operations were accelerated using an NVIDIA GeForce RTX 5090 D GPU.

Model explainability and interpretability

SHAP analysis was employed to provide post-hoc explainability of the model’s predictions at both global and local levels (9). SHAP values, grounded in cooperative game theory, quantify the marginal contribution of each feature to an individual prediction, providing a mathematically rigorous and theoretically consistent framework for model explanation. SHAP summary plots were generated to visualize global feature importance rankings and the directionality of each feature’s effect on survival predictions. SHAP dependence plots were constructed for the top-ranked features to examine non-linear relationships and potential feature interactions. Additionally, the learned attention gate weights were extracted from the trained model to provide model-intrinsic interpretability, offering insight into the transparent reasoning encoded within the model architecture, and complementing the post-hoc SHAP analysis and enabling cross-validation of explainability and interpretability findings (9).

Web-based clinical decision support tool

To bridge the gap between algorithmic development and clinical application, the trained and validated attention-gated stacking ensemble model was deployed as an interactive web-based calculator using the Streamlit framework. The tool allows clinicians to input the 11 prognostic variables through intuitive dropdown menus and slider controls and instantly receive personalized 1-, 3-, and 5-year survival probability estimates along with risk-group classification (24).

Statistical analysis

Ethical approval

The study was conducted in accordance with the Declaration of Helsinki and its subsequent amendments (25). The use of de-identified SEER data was exempt from institutional review board approval per the SEER data use agreement. The external validation study involving Xinqiao Hospital patients was approved by the Ethics Committee of Xinqiao Hospital (approval No. 2024-262-01). Written informed consent was obtained from all participants in the external validation cohort.


Results

Prognostic factor identification and feature selection

Pearson correlation analysis was performed on all 17 candidate clinical variables. Eleven variables demonstrated statistically significant associations with OS (P<0.05), including age at diagnosis, sex, histological subtype, tumor size, histopathological grade, N stage, M stage, bone metastasis, brain metastasis, liver metastasis, and lung metastasis (Figure 3A). The three variables most negatively correlated with survival months were M stage (r=−0.393), followed by N stage (r=−0.360) and tumor size (r=−0.276). Weaker negative correlations were observed for histological subtype (r=−0.066) and FMPI (r=−0.028). In contrast, minimal positive correlations were found for primary site (r=0.017), treatment sequence (r=0.010), and laterality (r=0.005), while race recode showed a negligible association (r=−0.001). Spearman rank correlation analysis yielded highly consistent rankings based on the strength of associations (Figure 3B), with the three highest coefficients observed for M stage (ρ=0.436), tumor size (ρ=0.391), and N stage (ρ=0.376).

Figure 3 Feature selection results. (A) Lollipop chart of Pearson correlation coefficients for 17 candidate clinical variables, where orange indicates a negative correlation with survival time and blue indicates a positive correlation. (B) Spearman ranking of the 17 candidate clinical variables. FMPI, first malignant primary indicator; M, metastasis; N, lymph node; Treat_seq, treatment sequence.

The result revealed predominantly weak-to-moderate intercorrelations among prognostic variables, suggesting acceptable independence for multivariable modeling. Based on predefined Pearson (P<0.05) and Spearman (|r| >0.05) correlation thresholds, six variables (race, FMPI, primary site, laterality, marital status, and treatment sequence) were excluded due to insufficient independent predictive value.

The final feature set comprised 11 prognostic variables: age at diagnosis, sex, histological subtype, histopathological grade, tumor size, N stage, M stage, bone metastasis, brain metastasis, liver metastasis, and lung metastasis. This dual-filtering strategy effectively reduced dimensionality while retaining clinically meaningful and statistically robust predictors.

Survival analysis

Kaplan-Meier analysis with log-rank testing confirmed statistically significant associations between all 11 selected features and OS (all P<0.001; Figure 1). The survival curves demonstrated clear and clinically meaningful separation across subgroups for each prognostic variable, thereby validating the feature selection results obtained from the dual-filtering strategy.

Male sex and advanced age (stratified into <65, 65–74, 75–84, and ≥85 years, with survival probability declining progressively with each advancing age category) were significantly associated with an inferior prognosis (Figure 1A,1B, respectively), consistent with established epidemiological evidence in NSCLC (26). Male patients exhibited a steeper decline in survival probability throughout the follow-up period compared with female patients, potentially reflecting differences in smoking prevalence, comorbidity burden, and tumor biology.

Larger tumor size, higher histopathological grade (Grade 3 versus Grade 2), and large cell carcinoma histological subtype were all significantly associated with shortened survival (see Figure 1H,1I,1L, respectively). Among all the variables, M stage had the most significant impact on prognosis. The prognosis of patients with stage M1 is extremely poor compared to patients with stage M0 (Figure 1G), which confirms the accepted conclusion in the previous literature about the prognosis of distant metastatic disease (27). The survival curves for M0 and M1 subgroups diverged sharply within the first 12 months and maintained wide separation throughout the observation period, highlighting that metastatic status as the dominant determinant of survival in NSCLC.

Progressive nodal involvement from N0 to N3 was associated with stepwise reductions in survival probability (Figure 1F). Patients with N0 disease exhibited the most favorable prognosis, whereas those with N3 involvement demonstrated the poorest outcomes, consistent with the known prognostic significance of regional lymph node burden in determining disease dissemination and therapeutic responsiveness (28).

Among distant metastatic sites, liver metastasis conferred the poorest prognosis (Figure 1K), followed by bone metastasis (Figure 1I), brain metastasis (Figure 1J), and lung metastasis (Figure 1H), aligning with prior reports highlighting organ-specific survival differences in metastatic NSCLC (29). The presence of any single-organ metastasis was associated with markedly diminished survival compared with the absence of metastatic involvement at that site, with liver metastasis demonstrating the steepest early decline in survival probability.

Based on the above, these findings validate the clinical relevance of the 11 selected features as robust prognostic determinants and provide a solid epidemiological foundation for their use as input variables in subsequent predictive model development.

Model performance on the training set

The attention-gated stacking ensemble model was first evaluated on the SEER training set. Receiver operating characteristic (ROC) analysis (Figure 4A-4C) demonstrated AUC values of 0.836, 0.836, and 0.864 for 1-, 3-, and 5-year survival prediction, respectively. The attention-gated model consistently surpassed all eleven individual base learners and the conventional stacking model without an attention gate (AUC: 0.833, 0.831, and 0.856 for 1-, 3-, and 5-year, respectively). Among individual base learners, KNN (AUC: 0.814, 0.829, and 0.838) and logistic regression (AUC: 0.809, 0.809, and 0.816) achieved the highest standalone discrimination, whereas SGD exhibited the lowest discriminative performance (AUC: 0.711, 0.705, and 0.700).

Figure 4 Performance evaluation on the training set (n=56,166). (A-C) ROC curves for 1-, 3-, and 5-year survival prediction. The attention-gated model (orange) is compared against 11 base learners and a conventional stacking model; shaded areas represent 98% confidence intervals. (D-F) Confusion matrices at the optimal threshold. Rows: true labels (N = non-survivor, P = survivor); columns: predicted labels. (G-I) Decision curve analysis comparing net benefit against “treat all” and “treat none” strategies. (J-L) Calibration curves with Brier scores annotated; dashed diagonal line represents perfect calibration. AUC, area under the receiver operating characteristic curve; CatBoost, categorical boosting; CI, confidence interval; DCA, decision curve analysis; DT, Decision Tree; FPR, false positive rate; GNB, Gaussian Naive Bayes; KNN, K-Nearest Neighbors; LDA, Linear Discriminant Analysis; LightGBM, Light Gradient Boosting Machine; LR, logistic regression; MLP, multilayer perceptron; N, negative; P, positive; RF, Random Forest; ROC, receiver operating characteristic; SGD, Stochastic Gradient Descent; TPR, true positive rate; XGBoost, eXtreme Gradient Boosting.

Confusion matrix analysis (Figure 4D-4F) demonstrated balanced classification performance across all three-time horizons. For the 1-year endpoint, the model correctly identified 22,181 true negatives and 22,211 true positives, with 6,998 false positives and 6,968 false negatives. Similar classification patterns were observed for the 3-year and 5-year endpoints.

DCA (Figure 4G-4I) demonstrated that the attention-gated model provided superior net benefit compared to both “treat all” and “treat none” reference strategies across a clinically relevant range of threshold probabilities (approximately 0.05–0.80) for all three time horizons, indicating meaningful clinical utility (29).

Calibration curves (Figure 4J-4L) closely approximated the ideal diagonal line, with Brier scores of 0.166, 0.172, and 0.147 for 1-, 3-, and 5-year prediction, respectively, indicating satisfactory agreement between predicted probabilities and observed outcomes (30).

Model performance on the internal test set

The model’s generalizability was assessed on the held-out internal test set (n=11,234). ROC analysis (Figure 5A-5C) yielded AUC values of 0.799, 0.799, and 0.778 for 1-, 3-, and 5-year prediction, respectively. For the 1-year endpoint, the attention-gated model outperformed XGBoost (0.775), LightGBM (0.779), CatBoost (0.771), Random Forest (0.794), and the conventional stacking model (0.797). For the 3-year endpoint, performance was comparable to logistic regression (0.803) and LDA (0.803) while surpassing all tree-based and neural network-based learners. For the 5-year endpoint, the attention-gated model achieved an AUC of 0.778, outperforming the conventional stacking model (0.770) and most individual base learners, with GNB (0.788) showing the highest standalone performance. The performance decrement from training to internal testing (ΔAUC ≈0.04–0.09) was within an acceptable range, indicating that overfitting was adequately controlled through the implemented regularization strategies (31).

Figure 5 Performance evaluation on the internal test set (n=11,234). (A-C) ROC curves of the attention-gated model with 98% confidence intervals. (D-F) Confusion matrices. (G-I) Decision curve analysis. (J-L) Calibration curves with Brier scores. Layout and annotations follow Figure 4. AUC, area under the receiver operating characteristic curve; CatBoost, categorical boosting; CI, confidence interval; DCA, decision curve analysis; DT, Decision Tree; FPR, false positive rate; GNB, Gaussian Naive Bayes; KNN, K-Nearest Neighbors; LDA, Linear Discriminant Analysis; LightGBM, Light Gradient Boosting Machine; LR, Logistic Regression; MLP, multilayer perceptron; N, negative; P, positive; RF, Random Forest; ROC, receiver operating characteristic; SGD, Stochastic Gradient Descent; TPR, true positive rate; XGBoost, eXtreme Gradient Boosting.

Confusion matrices (Figure 5D-5F) revealed 5,636 true negatives and 2,626 true positives for 1-year prediction. A trend toward increasing false negative rates was observed at longer prediction horizons (3-year and 5-year), attributable to the inherent uncertainty associated with long-term survival estimation in oncological populations (32).

DCA (Figure 5G-5I) confirmed positive net benefit across threshold probabilities of approximately 0.10–0.75 for all endpoints. Calibration analysis (Figure 5J-5L) yielded Brier scores of 0.176, 0.181, and 0.181 for 1-, 3-, and 5-year prediction—slightly higher than training set values but within accepted benchmarks for clinical prediction models (33).

External validation

The attention-gated model was validated on an independent cohort of 623 NSCLC patients from Xinqiao Hospital (Figure 6). Although this cohort differed from the SEER derivation population in age distribution, sex proportion, and stage composition—presenting a rigorous test of cross-population generalizability (29)—the model demonstrated remarkable robustness. Notably, the external validation AUCs actually exceeded those of the internal test set (0.817 vs. 0.799 for 1-year; 0.825 vs. 0.778 for 5-year). This phenomenon is likely attributable to the highly curated, clinical nature of the Xinqiao cohort, which generally contains less systematic noise than large-scale, population-based registries (34).

Figure 6 Performance evaluation on the external validation cohort (n=623). (A-C) ROC curves for 1-, 3-, and 5-year prediction. The attention-gated model achieved AUCs of 0.817, 0.807, and 0.825, respectively. (D-F) Confusion matrices. (G-I) Decision curve analysis. (J-L) Calibration curves with Brier scores of 0.127, 0.107, and 0.095. Layout and annotations follow Figure 4. AUC, area under the receiver operating characteristic curve; CatBoost, categorical boosting; CI, confidence interval; DCA, decision curve analysis; DT, Decision Tree; FPR, false positive rate; GNB, Gaussian Naive Bayes; KNN, K-Nearest Neighbors; LDA, Linear Discriminant Analysis; LightGBM, Light Gradient Boosting Machine; LR, Logistic Regression; MLP, multilayer perceptron; N, negative; P, positive; RF, Random Forest; ROC, receiver operating characteristic; SGD, Stochastic Gradient Descent; TPR, true positive rate; XGBoost, eXtreme Gradient Boosting.

ROC analysis (Figure 6A-6C) confirmed the model’s superior discriminative power, yielding AUCs of 0.817, 0.807, and 0.825 for 1-, 3-, and 5-year survival predictions, respectively. The attention-gated model consistently outperformed all eleven base learners and the conventional stacking model across all time horizons, with the advantage over conventional stacking being most pronounced at 5 years (0.825 vs. 0.805). Among the base learners, Random Forest and Logistic Regression demonstrated strong performance, whereas GNB and SGD exhibited poor external generalizability.

Table 2 summarizes key classification metrics. While the attention-gated and conventional stacking models performed highly comparably in threshold-based metrics (accuracy, precision, recall, and F1 score), the attention-gated architecture demonstrated distinct superiority in probabilistic accuracy. Confusion matrices (Figure 6D-6F) confirmed stable classification with high sensitivity (e.g., 91.3% recall for 1-year prediction).

Table 2

Performance comparison of 11 machine learning models, standard stacking models, and attention-gated models

Timeline Model Accuracy Precision Recall F1 score
1-year CatBoost 0.842 0.867 0.951 0.907
DT 0.833 0.845 0.972 0.904
GNB 0.836 0.867 0.941 0.903
KNN 0.770 0.886 0.821 0.852
LDA 0.847 0.879 0.941 0.909
LightGBM 0.849 0.870 0.955 0.911
LR 0.852 0.879 0.947 0.912
MLP 0.842 0.879 0.933 0.905
RF 0.842 0.864 0.955 0.907
SGD 0.757 0.893 0.795 0.841
XGBoost 0.837 0.880 0.925 0.902
Stacking 0.856 0.896 0.929 0.912
Att-gate 0.856 0.909 0.913 0.911
3-year CatBoost 0.847 0.864 0.968 0.913
DT 0.847 0.856 0.980 0.914
GNB 0.857 0.882 0.956 0.917
KNN 0.818 0.868 0.920 0.893
LDA 0.856 0.873 0.966 0.917
LightGBM 0.862 0.869 0.982 0.922
LR 0.862 0.874 0.974 0.921
MLP 0.867 0.883 0.968 0.924
RF 0.861 0.869 0.980 0.921
SGD 0.768 0.891 0.820 0.854
XGBoost 0.857 0.868 0.976 0.919
Stacking 0.864 0.873 0.978 0.923
Att-gate 0.867 0.876 0.978 0.924
5-year CatBoost 0.867 0.893 0.961 0.926
DT 0.857 0.870 0.980 0.922
GNB 0.878 0.903 0.961 0.931
KNN 0.876 0.898 0.965 0.931
LDA 0.880 0.897 0.972 0.933
LightGBM 0.878 0.892 0.976 0.932
LR 0.880 0.894 0.976 0.933
MLP 0.881 0.908 0.959 0.933
RF 0.873 0.892 0.970 0.929
SGD 0.878 0.892 0.976 0.932
XGBoost 0.853 0.897 0.937 0.917
Stacking 0.881 0.894 0.978 0.934
Att-gate 0.880 0.891 0.980 0.933

Att-gate, attention-gated; CatBoost, categorical boosting; DT, Decision Tree; GNB, Gaussian Naive Bayes; KNN, K-Nearest Neighbors; LDA, Linear Discriminant Analysis; LightGBM, Light Gradient Boosting Machine; LR, Logistic Regression; MLP, multilayer perceptron; RF, Random Forest; SGD, Stochastic Gradient Descent; XGBoost, eXtreme Gradient Boosting.

Furthermore, clinical utility and reliability were rigorously verified. DCA (Figure 6G-6I) confirmed a positive net clinical benefit across a wide range of threshold probabilities (0.05–0.85). Finally, calibration curves (Figure 6J-6L) demonstrated excellent consistency between predicted and observed probabilities. Brier scores on the external validation set for 1, 3, and 5 years (0.127, 0.107, and 0.095) significantly outperformed those on the internal test set (0.176, 0.181, and 0.181), confirming the model’s superior calibration and translational potential in independent clinical settings.

Model explainability and interpretability

Assessing the importance of key features is crucial for understanding the model’s predictive outcomes and their clinical significance. In 1-year survival prediction (Figure 7A), SHAP analysis identified M stage, tumor size, and N stage as the top-three critical determinants. The corresponding beeswarm plot (Figure 7B) further illustrates that distant metastasis, larger tumor size, and higher N stage are strongly correlate with an increased risk of mortality. This hierarchical importance remains largely consistent in 3-year survival predictions (Figure 7C,7D), where N stage, M stage, and tumor size remained key factors influencing survival outcomes. In 5-year survival prediction (Figure 7E,7F), N stage and M stage remained paramount, alongside older age, which significantly elevates mortality risk.

Figure 7 The distribution and feature importance of SHAP values for predicting 1-year survival rate by the attention-gated model (A,B), 3-year survival rate (C,D), and 5-year survival rate (E,F). In the right column (B,D,F), each data point represents a patient record, with color intensity indicating the magnitude of each feature’s corresponding value, ranging from blue to red. The x-axis represents the SHAP value, where larger absolute values indicate a greater contribution of the feature to the risk of patient mortality. M, metastasis; N, lymph node; SHAP, SHapley Additive exPlanations.

A notable strength of the attention-gated model is its ability to capture the dynamic, time-dependent prognostic value of age. Specifically, the global importance of age steadily increases from 0.313 at 1 year, to 0.327 at 3 years, and reaches 0.388 at 5 years. This temporal shift aligns seamlessly with clinical experience, confirming age as a definitive determinant of long-term survival (35). This finding is highly consistent with existing oncology knowledge, indicating that the model can effectively capture biologically significant indicators, and therefore has great practical value in identifying high-risk patients with poor long-term prognosis.

While the specific metastasis sites (bone, brain, liver, lung) rank relatively low in overall global importance (mean |SHAP| ranging from 0.04 to 0.13), their occurrence triggers a stark rightward shift in individual SHAP values. Notably, among patients with distant disease, bone metastasis consistently emerges as the most detrimental site-specific factor impairing long-term prognosis across all time horizons.

Web-based prediction tool deployment

The deployed web-based clinical decision support tool is illustrated in Figure 8. The interface enables clinicians to input 11 patient-specific clinical variables through an intuitive controls system, including a slider for age, drop-down menus for categorical variables (sex, histological subtype, tumor grade, N stage, M stage, and four metastasis sites), and a numeric input field for tumor size. Upon clicking the “Predict” button, the system generates personalized 1-, 3-, and 5-year survival probability estimates along with a risk-group classifications. The tool is publicly accessible at http://127.0.0.1:7692. Since the web-based tool is intended to serve Xinqiao Hospital, it is deployed in the internal environment of Xinqiao Hospital. Access is available upon request by contacting the corresponding authors.

Figure 8 Screenshot of the web-based clinical decision support tool.

Subgroup analysis in G1 patients

To further rigorously evaluate the generalizability of the model, we assessed its performance on Grade 1 (G1) patients from the SEER database—a subgroup entirely excluded from the initial training phase. Notably, despite being trained only on G2–G3 cases, the model still achieved robust discriminative ability, with AUCs of 0.798, 0.771, and 0.764 for 1-, 3-, and 5-year survival, respectively (Figure 9A). Calibration analysis (Figure 9B) showed satisfactory agreement between predicted and observed outcomes, although minor biases were observed as the prediction range was extended to 5 years (Brier =0.373). Detailed classification performance visualized via confusion matrices (Figure 9C-9E), confirmed the model’s reliability in risk stratification for this G1 cohort, characterized by high precision in identifying negative cases alongside stable sensitivity. Notably, DCA (Figure 9F-9H) shows that the model provides superior net gains across different threshold probabilities, particularly at 1-year and 3-year intervals, supporting its clinical applicability in G1 patient management. Although a natural performance decline was observed over the 5-year period, the model remained clinically informative. These results demonstrate that the attention-gated architecture effectively captures fundamental prognostic features beyond specific histological grades, maintaining significant predictive utility even in patient populations outside the original training distribution.

Figure 9 Results of the proposed model for predicting outcomes in patients with G1 tumors, which were not included in the training dataset. (A) ROC curves for 1-, 3-, and 5-year prediction, with a confidence interval of 98%. The AUC values are 0.798, 0.771, and 0.764, respectively. (B) The Brier scores of the calibration curves for 1, 3, and 5 years were 0.108, 0.227, and 0.373, respectively. (C-E) Confusion matrices. (F-H) Decision curve analysis. AUC, area under the receiver operating characteristic curve; CI, confidence interval; DCA, decision curve analysis; FPR, false positive rate; TPR, true positive rate.

Discussion

In the present study, we developed, validated, and explained an attention-gated stacking ensemble model for predicting 1-, 3-, and 5-year OS in NSCLC patients. The proposed model integrates eleven algorithmically diverse base learners with a sigmoid-based feature-wise attention gate and an MLP meta-classifier, achieving superior discriminative performance over all individual base learners and a conventional stacking model without the attention gate on both internal and external validation cohorts.

Several findings merit discussion. First, the consistent improvement in AUC (0.3–0.4% absolute increase) underscores the value of adaptive feature weighting. Unlike conventional stacking, the attention gate dynamically amplifies informative features while attenuating noise for each patient, conceptually paralleling the clinical reasoning process where oncologists weigh prognostic factors differentially based on patient presentation (36). Additionally, clinical data are often affected by measurement errors and distribution biases. Relying solely on Pearson correlation for feature selection may underestimate nonlinear features, whereas Spearman correlation provides nonparametric validation. Dual screening further ensures that reliable variables are incorporated into downstream attention models, enhancing predictive accuracy and the clinical relevance of the selected feature set (37).

Secondly, the external validation set based on a geographically distinct cohort from Xinqiao Hospital showed that the AUC values were higher than those of the internal test set performance across all time spans (e.g., 5-year: 0.825 vs. 0.778). This is noteworthy because external validation performance typically declines due to population heterogeneity (10). This improvement may be attributed to composition of the external cohort, which may include more surgically treated and fully staged patients. This provides strong evidence for the robustness of the model across different populations.

Thirdly, SHAP analysis identified M stage, tumor size, N stage and age as the most influential predictors, consistent with established oncology knowledge (38). The consistency between SHAP-based explainability and attention-based interpretability provides two-layer transparency—the attention weights offer an interpretable intrinsic signal of feature relevance, while SHAP provides post-hoc explainability—which is crucial for building clinician trust (39).

Fourth, deploying web-based interactive tools is an important step in translating ML research into practice. The integration of dynamic SHAP visualizations supports shared decision-making by providing individualized post-hoc explanations of model predictions (40).

Importantly, when compared to existing literature, our methodology offers distinct advantages. Previous studies have successfully demonstrated the utility of advanced algorithms, such as deep learning frameworks, for predicting NSCLC survival (41). However, these conventional ML approaches often act as opaque “black boxes”, applying static feature weights across the entire patient cohort. To address the growing demand from healthcare professionals for understandable and transparent artificial intelligence (AI) tools (21), our approach distinguishes itself by implementing an attention-gated stacking framework. This architecture dynamically adjusts feature weights on an individualized basis. By integrating individual-level dynamic weighting with globally recognized clinical prognosticators, our model bridges the gap between high predictive accuracy and the essential transparency required for clinical trust. Interestingly, our model exhibited a promising transferability in G1 stage patients. This suggests that features learned from G2 and G3 may share certain biological commonalities with G1. However, G1 performed worse than G2/G3, which was expected because G1 patients had smaller tumor sizes and a lower risk of lymph node or distant metastasis (42). Nevertheless, the decline of performance in G1 patients highlights the potential impact of distributional differences and suggests that including G1 samples in future training sets may further improve model robustness. Despite this limitation, the model still demonstrated a certain predictive capability for tumor grades not represented during training, indicating that the structure has some transferability.

Such robust early-stage predictive performance facilitates the rapid translation of the model into clinical practice, providing oncologists with a reliable, evidence-based tool for risk stratification. By accurately identifying high-risk individuals even within traditionally “low-risk” subgroups, this model contributes significantly to personalized patient management. This capability enables more timely clinical interventions and optimized monitoring strategies, ultimately bridging the gap between advanced data science and bedside care to improve long-term survival outcomes for NSCLC patients.

The SHAP feature rankings are highly consistent with established clinical consensus and the AJCC staging paradigm (3), where M stage, N stage, and tumor size are the main determinants of risk. This consistency demonstrates that the proposed attention-gated model operates based on a biologically and clinically meaningful paradigm, rather than as an opaque “black box”. Importantly, this explainability is essential for clinical implementation, as it shows that the model’s decision-making process is consistent with established pathological mechanisms and accepted oncological knowledge.

One methodologically noteworthy aspect of this study is the substitution of T stage with primary tumor size. As mentioned in the introduction, the SEER database spans three AJCC versions (v7, v8, v9), during which T stage definitions underwent substantive modifications. Applying these evolving criteria to decades of data introduces systematic noise, where the identical T categories across eras may represent distinct biological profiles. By using raw tumor size—a continuous, directly measured, and edition-invariant parameter—our model avoids temporal confounding entirely. Tumor size, as the primary driver of T-classification, preserves fundamental biological relevance, achieving cross-era comparability while maintaining prognostic validity. SHAP analysis confirmed tumor size as one of the top-three predictors, validating its inclusion as a direct continuous variable. This hybrid strategy, combining continuous tumor size with N and M stages, enhances the explainability (by using a directly understandable continuous variable) and generalizability of heterogeneous populations across time.

This study has several limitations. First, the SEER database, while comprehensive, lacks certain clinically relevant variables, including treatment modality details (e.g., specific chemotherapy regimens, immunotherapy status, surgical approach), Eastern Cooperative Oncology Group (ECOG) performance status, molecular markers (e.g., EGFR, ALK, PD-L1 expression), and pulmonary function data. The absence of these variables may limit the model’s ability to capture important prognostic heterogeneity, and future iterations should incorporate such features as they become systematically available in large-scale registries (43). Second, the retrospective design introduces inherent selection and information biases that cannot be entirely eliminated through statistical adjustment. Third, although the external validation cohort was geographically and ethnically distinct, its relatively modest sample size (n=623) may limit the statistical power to detect subgroup-specific performance variations. Prospective, multi-center external validation studies with larger cohorts are warranted. Fourth, the current model predicts OS at fixed time points (1, 3, and 5 years) rather than modeling the complete survival function; future work could integrate the attention-gated stacking framework with time-to-event modeling approaches such as DeepSurv or neural Cox regression to provide continuous-time survival estimates (44). Fifth, the web-based tool has not yet undergone formal clinical usability testing or impact assessment; prospective studies evaluating its effect on clinical decision-making and patient outcomes are necessary prior to widespread adoption.


Conclusions

Accurate survival prediction for NSCLC remains challenging because traditional TNM staging provides population-level estimates, and successive AJCC revisions introduce temporal staging heterogeneity in multi-decade registries like SEER. To circumvent this staging-version confounding, this study substituted the evolving categorical T stage with continuous primary tumor size—an edition-invariant parameter—while retaining the relatively stable N and M stages. Methodologically, the study developed an attention-gated stacking ensemble model integrating eleven diverse base learners to predict 1-, 3-, and 5-year OS. Unlike conventional stacking, which assigns uniform feature importance, this model incorporated a sigmoid-based feature-wise attention gate to dynamically prioritize informative predictive signals on a patient-specific basis, conceptually mirroring clinical reasoning. The proposed model demonstrated superior discriminative performance over individual base learners and conventional stacking architectures. Notably, during external validation on a geographically and ethnically distinct cohort, the model achieved exceptional cross-population robustness, with AUC values exceeding those of the internal test set across all time horizons (e.g., 5-year AUC of 0.825 externally versus 0.778 internally). To ensure clinical transparency, SHAP analysis was employed, identifying M stage, primary tumor size, and N stage as the most influential prognostic factors. This robust ranking empirically validated the decision to substitute tumor size for T stage. Bridging the gap between algorithmic development and bedside utility, the validated model was deployed as an interactive, web-based clinical decision support tool featuring individualized SHAP visualizations. While the study is limited by the retrospective nature of the SEER database—which lacks data on specific systemic treatments and molecular biomarkers—and models fixed temporal milestones rather than continuous survival curves, the attention-gated ensemble framework provides a highly explainable, intrinsically interpretable, cross-era compatible, and robust tool to facilitate shared decision-making in oncological care.


Acknowledgments

None.


Footnote

Reporting Checklist: The authors have completed the TRIPOD reporting checklist. Available at https://jtd.amegroups.com/article/view/10.21037/jtd-2026-0848/rc

Data Sharing Statement: Available at https://jtd.amegroups.com/article/view/10.21037/jtd-2026-0848/dss

Peer Review File: Available at https://jtd.amegroups.com/article/view/10.21037/jtd-2026-0848/prf

Funding: This study was supported by Noncommunicable Chronic Diseases-National Science and Technology Major Project (No. 2023ZD0502100), National Natural Science Foundation of China (Nos. 82172670, 81972858, and 82473261), Technology Innovation and Application Development Project of Chongqing (Nos. 2023DBXM002 and CSTB2022TIAD-KPX0176), Chongqing Medical Leading Talent Project (No. YXLJ202405 to J.S.), and Clinical Research Talents Training Program of Army Medical University (No. 2018XLC1010).

Conflicts of Interest: All authors have completed the ICMJE uniform disclosure form (available at https://jtd.amegroups.com/article/view/10.21037/jtd-2026-0848/coif). The authors have no conflicts of interest to declare.

Ethical Statement: The authors are accountable for all aspects of the work in ensuring that questions related to the accuracy or integrity of any part of the work are appropriately investigated and resolved. The study was conducted in accordance with the Declaration of Helsinki and its subsequent amendments. The use of de-identified SEER data was exempt from institutional review board approval per the SEER data use agreement. The external validation study involving Xinqiao Hospital patients was approved by the Ethics Committee of Xinqiao Hospital (approval No. 2024-262-01). Written informed consent was obtained from all participants in the external validation cohort.

Open Access Statement: This is an Open Access article distributed in accordance with the Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License (CC BY-NC-ND 4.0), which permits the non-commercial replication and distribution of the article with the strict proviso that no changes or edits are made and the original work is properly cited (including links to both the formal publication through the relevant DOI and the license). See: https://creativecommons.org/licenses/by-nc-nd/4.0/.


References

  1. Sung H, Ferlay J, Siegel RL, et al. Global Cancer Statistics 2020: GLOBOCAN Estimates of Incidence and Mortality Worldwide for 36 Cancers in 185 Countries. CA Cancer J Clin 2021;71:209-49. [Crossref] [PubMed]
  2. Hendriks LEL, Remon J, Faivre-Finn C, et al. Non-small-cell lung cancer. Nat Rev Dis Primers 2024;10:71. [Crossref] [PubMed]
  3. Goldstraw P, Chansky K, Crowley J, et al. The IASLC Lung Cancer Staging Project: Proposals for Revision of the TNM Stage Groupings in the Forthcoming (Eighth) Edition of the TNM Classification for Lung Cancer. J Thorac Oncol 2016;11:39-51. [Crossref] [PubMed]
  4. Steyerberg EW. Introduction. In: Steyerberg EW, editor. Clinical Prediction Models: A Practical Approach to Development, Validation, and Updating. Cham: Springer International Publishing; 2019:1-11.
  5. Detterbeck FC, Boffa DJ, Kim AW, et al. The Eighth Edition Lung Cancer Stage Classification. Chest 2017;151:193-203.
  6. Steyerberg EW. Applications of Prediction Models. In: Steyerberg EW, editor. Clinical Prediction Models: A Practical Approach to Development, Validation, and Updating. Cham: Springer International Publishing; 2019:15-36.
  7. Kourou K, Exarchos TP, Exarchos KP, et al. Machine learning applications in cancer prognosis and prediction. Comput Struct Biotechnol J 2015;13:8-17. [Crossref] [PubMed]
  8. Dietterich TG. Ensemble Methods in Machine Learning. Proceedings of the First International Workshop on Multiple Classifier Systems. Springer-Verlag; 2000:1-15.
  9. Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need. Proceedings of the 31st International Conference on Neural Information Processing Systems; Long Beach, California, USA. Curran Associates Inc.; 2017:6000-10.
  10. Collins GS, Reitsma JB, Altman DG, et al. Transparent reporting of a multivariable prediction model for individual prognosis or diagnosis (TRIPOD): the TRIPOD statement. BMJ 2015;350:g7594. [Crossref] [PubMed]
  11. Kelly CJ, Karthikesalingam A, Suleyman M, et al. Key challenges for delivering clinical impact with artificial intelligence. BMC Med 2019;17:195. [Crossref] [PubMed]
  12. Fritz AG. International Classification of Diseases for Oncology: ICD-O. World Health Organization; 2000.
  13. Kuhn M, Johnson K. Introduction. In: Kuhn M, Johnson K, editors. Applied Predictive Modeling. New York, NY: Springer New York; 2013:1-16.
  14. Kuhn M, Johnson K. Data Pre-processing. In: Kuhn M, Johnson K, editors. Applied Predictive Modeling. New York, NY: Springer New York; 2013:27-59.
  15. Halsey LG, Curran-Everett D, Vowler SL, et al. The fickle P value generates irreproducible results. Nat Methods 2015;12:179-85. [Crossref] [PubMed]
  16. Guyon I, Elisseeff A. An introduction to variable and feature selection. J Mach Learn Res 2003;3:1157-82.
  17. Chen T, Guestrin C. XGBoost: A Scalable Tree Boosting System. Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining; August 13-17, 2016, San Francisco, CA, USA. ACM; 2016:785-94.
  18. Ke G, Meng Q, Finley T, et al. LightGBM: A Highly Efficient Gradient Boosting Decision Tree. 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA. 2017.
  19. Breiman L. Random Forests. Machine Learning 2001;45:5-32.
  20. Durán-Rosal AM, Ashley T, Pérez-Rodríguez J, et al. Global and Diverse Ensemble model for regression. Neurocomputing 2025;647:130520.
  21. Barton M, Lennox B. Model stacking to improve prediction and variable importance robustness for soft sensor development. Digital Chemical Engineering 2022;3:100034.
  22. Oktay O, Schlemper J, Le Folgoc L, et al. Attention U-Net: Learning Where to Look for the Pancreas. 2018. [Preprint]. doi:10.48550/arXiv.1804.03999.
  23. Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need. Advances in Neural Information Processing Systems 2017;30.
  24. Iasonos A, Schrag D, Raj GV, et al. How to build and interpret a nomogram for cancer prognosis. J Clin Oncol 2008;26:1364-70. [Crossref] [PubMed]
  25. World Medical Association. World Medical Association Declaration of Helsinki: ethical principles for medical research involving human subjects. JAMA 2013;310:2191-4. [Crossref] [PubMed]
  26. Kenmotsu H, Naito T, Kimura M, et al. The risk of cytotoxic chemotherapy-related exacerbation of interstitial lung disease with lung cancer. J Thorac Oncol 2011;6:1242-6. [Crossref] [PubMed]
  27. Riihimäki M, Hemminki A, Fallah M, et al. Metastatic sites and survival in lung cancer. Lung Cancer 2014;86:78-84. [Crossref] [PubMed]
  28. Ma R, Yang H, Ge Y, et al. Prognostic Implications of Lymph Node Status in Non-Small-Cell Lung Cancer Patients Before and After Neoadjuvant Chemoimmunotherapy: A Multicenter Retrospective Study. Clin Lung Cancer 2025;26:370-83. [Crossref] [PubMed]
  29. Debray TP, Riley RD, Rovers MM, et al. Individual participant data (IPD) meta-analyses of diagnostic and prognostic modeling studies: guidance on their use. PLoS Med 2015;12:e1001886. [Crossref] [PubMed]
  30. Steyerberg EW, Vickers AJ, Cook NR, et al. Assessing the performance of prediction models: a framework for traditional and novel measures. Epidemiology 2010;21:128-38. [Crossref] [PubMed]
  31. Riley RD, Ensor J, Snell KIE, et al. Calculating the sample size required for developing a clinical prediction model. BMJ 2020;368:m441. [Crossref] [PubMed]
  32. Rudin C. Stop Explaining Black Box Machine Learning Models for High Stakes Decisions and Use Interpretable Models Instead. Nat Mach Intell 2019;1:206-15. [Crossref] [PubMed]
  33. Rufibach K. Use of Brier score to assess binary predictions. J Clin Epidemiol 2010;63:938-9; author reply 939. [Crossref] [PubMed]
  34. Austin PC, Lee DS, D'Agostino RB, et al. Developing points-based risk-scoring systems in the presence of competing risks. Stat Med 2016;35:4056-72. [Crossref] [PubMed]
  35. Zhong W, Yuan H, Li T, et al. Therapeutic patterns and outcomes in older patients (aged ≥ 65 years) with stage III inoperable non-small cell lung cancer (NSCLC): An investigational study from the SEER database. PLoS One 2025;20:e0327458. [Crossref] [PubMed]
  36. Multimodal data integration improves immunotherapy response prediction. Nat Cancer 2022;3:1149-50.
  37. Lundberg SM, Erion G, Chen H, et al. From Local Explanations to Global Understanding with Explainable AI for Trees. Nat Mach Intell 2020;2:56-67. [Crossref] [PubMed]
  38. Moons KG, Kengne AP, Grobbee DE, et al. Risk prediction models: II. External validation, model updating, and impact assessment. Heart 2012;98:691-8.
  39. Visser A, Vrieling A, Murugesu L, et al. Determinants of adherence to recommendations for cancer prevention among Lynch Syndrome mutation carriers: A qualitative exploration. PLoS One 2017;12:e0178205. [Crossref] [PubMed]
  40. Stiggelbout AM, Van der Weijden T, De Wit MP, et al. Shared decision making: really putting patients at the centre of healthcare. BMJ 2012;344:e256. [Crossref] [PubMed]
  41. She Y, Jin Z, Wu J, et al. Development and Validation of a Deep Learning Model for Non-Small Cell Lung Cancer Survival. JAMA Netw Open 2020;3:e205842. [Crossref] [PubMed]
  42. Endo T, Crane J, Trivedi J, et al. Does grade matter? Evaluation of histologic grade in patients with stage 1 non-small cell lung cancer using the National Cancer Database. JTCVS Open 2025;25:393-405.
  43. Luo H, Zhao Q, Wei W, et al. Circulating tumor DNA methylation profiles enable early diagnosis, prognosis prediction, and screening for colorectal cancer. Sci Transl Med 2020;12:eaax7533. [Crossref] [PubMed]
  44. Fine JP, Gray RJ. A Proportional Hazards Model for the Subdistribution of a Competing Risk. Journal of the American Statistical Association 1999;94:496-509.
Cite this article as: Yin C, Wang Z, Zhang A, Wang Y, Cai D, Xie L, Yan L, Niu K, Jian C, Zheng L, Fang B, Zhou Y, Liu Z, Sun J. An explainable attention-gated stacking ensemble model for predicting survival in non-small cell lung cancer: development and validation. J Thorac Dis 2026;18(7):752. doi: 10.21037/jtd-2026-0848

Download Citation