Development and validation of a machine learning-driven framework for differentiating pediatric bronchopneumonia from lobar pneumonia: a multicenter investigation Authors: Zihan Cai, Shoupeng Ding, Jinghua Gao Published: 2025 ABSTRACT AbstractObjectiveThis investigation aims to establish and substantiate a machine learning-driven predictive framework designed to precisely distinguish between pediatric bronchopneumonia and lobar pneumonia. This endeavor seeks to elevate the accuracy of early clinical support, refine treatment decision-making, and curtail superfluous medical interventions.MethodsThis study was executed at Siyang Hospital, enrolling 2304 pediatric patients diagnosed with either bronchopneumonia or lobar pneumonia from January 2020 to December 2024. Participants were randomized in a 7:3 ratio into training (n = 1612) and testing (n = 692) sets, supplemented by an external validation set (n = 454) to evaluate the model’s generalizability. Hematological and serum biochemical parameters were gathered, with feature selection conducted using eXtreme Gradient Boosting (XGBoost), Support Vector Machine-Recursive Feature Elimination (SVM-RFE), and Random Forest algorithms. A suite of twelve machine learning models—including Random Forest, Gradient Boosting, and Support Vector Machines—was developed, with parameters fine-tuned through five-fold cross-validation. Model efficacy was assessed via receiver operating characteristic (ROC) curves, area under the curve (AUC), sensitivity, specificity, and F1 score, while feature significance was quantified using SHAP values. A nomogram was formulated based on critical features, its clinical value affirmed through calibration curves, and decision curve analysis (DCA). Statistical evaluations incorporated Mann–Whitney U tests, chi-square tests, and DeLong tests, with a threshold of P < 0.05 denoting significance.ResultsNotable disparities emerged between the bronchopneumonia (n = 1868) and lobar pneumonia (n = 436) cohorts across several hematological markers, such as large platelet count (P-LCT), Lymphocyte percentage (LYM%), and creatinine (CREA) (P < 0.01). Feature selection pinpointed P-LCT, LYM%, and CREA as key predictors. The Gradient Boosting model demonstrated exemplary performance, yielding an AUC of 0.947 (95% CI 0.934–0.960) in the training set, 0.968 (95% CI 0.954–0.982) in the testing set, and 0.989 (95% CI 0.981–0.997) in the external validation set, underscoring its outstanding discriminative prowess and robust generalizability. SHapley Additive exPlanations (SHAP) analysis underscored P-LCT (Mean Absolute SHAP: 0.057) and LYM% (0.065) as predominant predictors, exhibiting a strong correlation with disease severity. The nomogram attained an AUC of 0.962, with impeccable calibration (C-index = 0.962), and DCA substantiated considerable net benefit at moderate risk thresholds.ConclusionThe Gradient Boosting model, as delineated in this study, markedly advances the differential diagnosis of pediatric bronchopneumonia and lobar pneumonia, delivering high precision and resilience. It serves as an efficacious and dependable clinical decision-support instrument. By incorporating pivotal biomarkers like P-LCT and LYM%, this model illuminates pathophysiological traits, enhances antibiotic stewardship, and guides hospitalization choices, thereby diminishing healthcare resource wastage and ameliorating patient outcomes. These insights furnish vital backing for precision medicine and acute care management.Supplementary InformationThe online version contains supplementary material available at 10.1186/s40001-025-03742-6.Keywords: Machine learning, Bronchopneumonia, Lobar pneumonia, Gradient boosting, SHAP analysis Introduction Pneumonia remains a predominant acute respiratory infection among pediatric populations, exhibiting particularly high incidence and mortality rates in infants and immunocompromised children [1, 2]. Bronchopneumonia and lobar pneumonia constitute two primary subtypes, distinguished by profound differences in their pathophysiological mechanisms and clinical manifestations [3]. Traditional diagnostic methods predominantly rely on clinical symptoms, imaging techniques (e.g., chest radiography), and standard hematological assessments [4, 5]. Although these approaches facilitate diagnosis, they are impeded by limitations such as protracted diagnostic timelines, suboptimal precision, and limited interpretability. Notably, early-stage imaging in lobar pneumonia often fails to delineate characteristic lesions, increasing the risk of misdiagnosis with bronchopneumonia. This diagnostic ambiguity frequently leads to non-specific therapeutic interventions, which may exacerbate disease progression and predispose patients to severe immune-mediated complications, such as persistent atelectasis and multi-organ dysfunction [6–8]. Consequently, the timely and precise differentiation of these pneumonia subtypes is critical for optimizing pediatric clinical decision-making. In recent years, despite the proliferation of omics‑based, host‑derived immune biomarkers across the transcriptome [9], proteome [10], metabolome [11], and immune profile [12], rigorous clinical validation remains lacking, and reliance on high‑end instrumentation impedes implementation in resource‑limited settings. Meanwhile, machine learning has demonstrated substantial potential in diagnosing pulmonary diseases. For instance, Kukker et al. [13] respectively employed fuzzy Q‑learning and fuzzy lattice‑assisted Q‑learning to classify pneumonia and tuberculosis, achieving an accuracy of up to 96.75%. However, these methods rely heavily on X‑ray images. Similarly, Guan et al. [14] employed deep learning to identify lung diseases. Although these studies demonstrated strong performance, they did not circumvent dependence on imaging. This limitation constrains their applicability for minimizing radiation exposure and reducing costs. Although existing studies have confirmed that conventional hematological indicators have value for differentiating pneumonia subtypes [15, 16], no single marker affords precise diagnosis, and consensus on the optimal combination of indicators remains absent. Previous studies have shown significant differences in procalcitonin (PCT) and other routine laboratory indicators between patients with lobar pneumonia and bronchopneumonia [17]. However, no consensus has yet emerged on the best combination as a potential diagnostic signature. Meanwhile, a few studies have undertaken a comprehensive evaluation of all these indicators, even though such an assessment appears readily feasible. With advances in medical technology, machine learning has been widely applied to clinical disease diagnosis [18, 19]. Owing to their high efficiency and powerful predictive capability, machine learning methods have achieved remarkable results in medical data analysis [20]. Unlike the aforementioned studies that rely on imaging or complex omics techniques, this research aims to fill a key gap: developing an integrated machine learning framework based on conventional, low‑cost hematological data for the differential diagnosis of bronchopneumonia and lobar pneumonia in children. By integrating multiple machine learning algorithms, we not only enhance the stability of feature selection and the model’s predictive performance but also employ SHAP to address the “black‑box” problem, providing transparent and reliable explanations for the model’s predictions. Accordingly, this approach provides clinicians with an efficient and interpretable auxiliary diagnostic tool that is particularly suitable for resource‑constrained environments [21]. This study focuses on accelerating the diagnosis of pediatric pneumonia by harnessing machine learning models to perform feature selection on clinical hematological markers, thereby distinguishing bronchopneumonia from lobar pneumonia. By incorporating SHAP analysis, we aim to clarify the contributions of individual hematological features to disease prediction. Through this approach, we seek to elevate the diagnostic precision of pediatric pneumonia, equipping clinicians with an accurate and dependable decision-support tool, particularly for facilitating rapid diagnosis and timely therapeutic interventions. Materials and methods Ethical statement This study was granted approval by the Institutional Review Board of Siyang Hospital, with informed consent secured from all participants or their legal guardians. All clinical data were anonymized prior to analysis to ensure the protection of patient confidentiality. Study population and data collection The experimental workflow is shown in Fig. 1. This investigation was conducted at Siyang Hospital, a tertiary care institution, enrolling pediatric patients diagnosed with bronchopneumonia or lobar pneumonia between January 2020 and December 2024. The cohort was randomly partitioned in a 7:3 ratio into training (n = 1612) and testing (n = 692) datasets using stratified sampling by diagnosis, age, and sex to preserve distributional balance. To assess generalizability, an independent external validation cohort (n = 454) was sourced from additional healthcare institutions. This design supports model robustness across diverse populations and provides a reliable foundation for subsequent feature selection and classification. Experimental flow Diagnostic adjudication followed integrated clinical and radiographic criteria. Bronchopneumonia was diagnosed based on clinical manifestations (e.g., cough, wheeze, tachypnea, fever) together with imaging evidence of peribronchial thickening and multifocal/patchy consolidations. Lobar pneumonia was diagnosed by focal lobar consolidation with air bronchograms on chest radiograph or CT, supported by compatible symptoms (e.g., fever, cough, dyspnea). All diagnoses were established using a combination of clinical assessments, laboratory results, and radiological findings, including chest X-rays and, where available, CT scans. The radiological reports were part of routine clinical care and were interpreted by experienced radiologists or attending physicians. Patients were categorized into bronchopneumonia or lobar pneumonia groups based on these combined assessments. Respiratory specimens (sputum, pharyngeal swabs, or bronchoalveolar lavage fluid) were collected for bacteriological culture to aid pathogen identification. Exclusion criteria were as follows: (1) prior antibacterial therapy within the preceding two months; (2) age < 1 month or > 14 years; and (3) severe cardiopulmonary, immunologic, or other significant comorbidities. This study was approved by the Siyang Hospital Institutional Review Board, and informed consent was obtained from the legal guardians of all participants. Hematological and biochemical parameters were collected from routine laboratory panels drawn within 24 h of index presentation/admission (if multiple results were available within 24–48 h, the earliest value was used; same‑day duplicates were averaged). The a priori selection prioritized routinely available markers that reflect key pathophysiological axes relevant to pediatric pneumonia and have consistent measurement across laboratories: inflammation/immune response (white blood cell count (WBC), neutrophils, lymphocytes, neutrophil‑to‑lymphocyte ratio [NLR], C-reactive protein (CRP), ferritin, procalcitonin), coagulation (platelets), tissue injury/cell turnover (LDH), hepatic function (aspartate aminotransferase (AST), alanine aminotransferase (ALT), total/direct bilirubin, albumin), renal function (creatinine, eGFR), and electrolytes/metabolic status (Na, K, Cl, Ca, glucose, total protein). Derived ratios (e.g., neutrophil-to-lymphocyte ratio (NLR), platelet‑to‑lymphocyte ratio) were computed when components were available. Variables with low clinical relevance, near‑zero variance, or > 30% missingness were excluded prior to modeling; when pairs of features were highly correlated (|r|> 0.85), we retained the clinically more informative marker (e.g., albumin over total protein). Data pre-processing Pre‑processing of raw data followed a prespecified pipeline applied within the training data to prevent information leakage. Units were harmonized across records, duplicates removed, and biologically implausible values flagged for verification. Extreme outliers were handled using winsorization at the 1st/99th percentiles or IQR‑based rules while preserving clinically plausible extremes. Remaining missing values were imputed in the training folds only (median for continuous variables; mode for categorical lab flags), and the learned imputation parameters were then applied to the internal test and external validation cohorts. Right‑skewed markers (e.g., CRP, ferritin, LDH) underwent log transformation; all continuous features were standardized (z‑score) using means and standard deviations estimated from the training set. In sensitivity analyses involving multi‑center data, we evaluated site indicators to probe potential batch effects. Given the inherent imbalance between the bronchopneumonia and lobar pneumonia cohorts, we employed several strategies to mitigate the bias introduced by the unequal distribution during model training and evaluation. We applied stratified sampling during the data partitioning process to ensure that the training, validation, and test datasets were balanced with respect to both the diagnosis (bronchopneumonia vs. lobar pneumonia) as well as age and sex. All resampling steps were performed within the training folds to prevent information leakage. Additionally, we used class weights based on the inverse frequency of each class, applied during model fitting to adjust the loss function for models that do not inherently handle imbalance. For tree-based models (e.g., Random Forest, Gradient Boosting), we used the class_weight parameter to assign higher weights to the minority class. We also employed threshold optimization on the validation dataset to select the threshold that maximized the F1 score and balanced accuracy, ensuring both classes were equally considered. Moreover, probability calibration techniques, such as Platt scaling and isotonic regression, were applied to adjust the predicted probabilities, particularly for the minority class, ensuring more accurate classification. Evaluation metrics included macro-averaged F1 score, ROC-AUC (both macro-averaged and one-vs-rest), Precision-Recall AUC, and confusion matrices to report class-specific performance metrics like sensitivity, specificity, positive predictive value (PPV), and negative predictive value (NPV). By employing these strategies, we ensured that the model was robust to class imbalance, reflecting real-world clinical distribution without favoring one class over the other. Routine laboratory assessments Peripheral venous blood samples, anticoagulated with ethylenediaminetetraacetic acid (EDTA), were collected and analyzed using the Mindray BC-6800 automated hematology analyzer (Mindray Bio-Medical Electronics Co., Ltd., Shenzhen, China), in strict accordance with the manufacturer’s protocols. Hematological parameters encompassed white blood cell count (WBC), neutrophil count (NEU), lymphocyte count (LYM), monocyte count (MONO), eosinophil count (EOS), basophil count (BAS), neutrophil percentage (NEU%), LYM%, monocyte percentage (MONO%), eosinophil percentage (EOS%), basophil percentage (BAS%), red blood cell count (RBC), hemoglobin concentration (HGB), hematocrit (HCT), mean corpuscular volume (MCV), mean corpuscular hemoglobin (MCH), mean corpuscular hemoglobin concentration (MCHC), red cell distribution width-standard deviation (RDW-SD), red cell distribution width-coefficient of variation (RDW-CV), platelet count (PLT), platelet distribution width (PDW), plateletcrit (PCT), mean platelet volume (MPV), P-LCR, and large platelet count (P-LCT). Concurrently, peripheral venous blood samples were analyzed for serum biochemical markers using the Beckman Coulter automated biochemistry analyzer (Beckman Coulter, Brea, CA, USA), adhering rigorously to manufacturer guidelines. Measured parameters included total bilirubin (TBIL), direct bilirubin (DBIL), indirect bilirubin (IBIL), aspartate aminotransferase (AST), aspartate aminotransferase-to-alanine aminotransferase ratio (AST/ALT), alanine aminotransferase (ALT), alkaline phosphatase (ALP), gamma-glutamyl transferase (GGT), creatine kinase (CK), lactate dehydrogenase (LDH), glucose (GLU), total protein (TP), albumin (ALB), globulin (GLOB), albumin-to-globulin ratio (A/G), retinol-binding protein (RBP), urea nitrogen (UREA), creatinine (CREA), urea-to-creatinine ratio (UREA/CREA), uric acid (UA), potassium (K⁺), sodium (Na⁺), chloride (Cl⁻), calcium (Ca2⁺), phosphate (P), magnesium (Mg2⁺), carbon dioxide combining power (CO₂), total cholesterol (CHOL), triglycerides (TG), low-density lipoprotein cholesterol (LDL-C), high-density lipoprotein cholesterol (HDL-C), adenosine deaminase (ADA), and 5’-nucleotidase (5’-NT). All serum samples were promptly processed and refrigerated post-collection, with analyses performed in strict compliance with laboratory protocols to ensure precision and reproducibility of results. Feature selection In this study, a multi-stage feature selection strategy was employed to identify the most salient hematological predictors. Initially, the eXtreme Gradient Boosting (XGBoost) algorithm was utilized to perform a preliminary feature ranking [22, 23]. By quantifying the contribution of each feature—specifically, its cumulative gain across all decision trees—XGBoost provided an initial assessment of variable importance. Subsequently, this feature set was refined using the Support Vector Machine-Recursive Feature Elimination (SVM-RFE) method. This iterative process involved recursively training an SVM model and eliminating the least influential features at each step, thereby distilling the feature set to its most discriminative components. As a final step, a Random Forest (RF) model was implemented to corroborate the feature importance rankings, evaluating the relative significance of each variable based on its Mean Decrease in Impurity across the ensemble of trees [24]. To control for potential confounding, key demographic and clinical variables, including age, gender, and major comorbidities, were explicitly included as covariates throughout the modeling process. This ensured that their influence on the outcome was statistically adjusted for and accurately quantified. For instance, within the SVM-RFE framework, these confounders were retained, while other predictors were recursively eliminated, effectively preserving their structural influence on the model. Ultimately, the final feature set was determined by synthesizing the results from all three machine learning methods (XGBoost, SVM-RFE, and Random Forest). This integrated approach ensures that the selected features not only optimize the model’s predictive performance and interpretability but also account for the effects of critical confounders, thereby enhancing the overall stability and clinical relevance of the final model. Machine learning model development In this study, a comprehensive suite of machine learning algorithms was leveraged to develop and compare disease prediction models. The algorithms evaluated included Random Forest (RF), Gradient Boosting (GB), Support Vector Machine (SVM) with Kernel, Logistic Regression (LR), K-Nearest Neighbors (KNN), Partial Least Squares (PLS), Neural Network (NN), Naive Bayes (NB), Discriminant Analysis (DA), Lasso, and Adaptive Boosting (AdaBoost). To ensure model robustness and result generalizability, we implemented a five-fold stratified cross-validation methodology for parameter tuning and model training. Specifically, the entire dataset was randomly partitioned into five subsets, or “folds,” maintaining proportional representation of key categorical variables (e.g., disease types like bronchopneumonia and lobar pneumonia, and patient demographics such as age and gender) across each fold. This stratification strategy effectively ameliorates the potential impact of class imbalance and mitigates the risk of overfitting, thereby enhancing the model’s generalization capacity. The model’s performance was further corroborated using an independent external validation set. This rigorous data-partitioning and cross-validation protocol substantiates the reliability of our evaluation process. Detailed mathematical formulations and parameters for the machine learning algorithms, including loss functions, optimization methods, convergence criteria, and the R packages employed, are provided in Supplementary Tables 3 and 4. Model performance was comprehensively assessed using a panel of metrics, including accuracy, precision, recall, F1-score, and specificity. Ultimately, the model demonstrating optimal predictive performance across both cross-validation and independent testing was selected, with the objective of enhancing the accuracy and clinical utility of early disease diagnosis and prediction. Decision curve analysis (DCA) To ascertain the clinical utility of the predictive model, we performed a Decision Curve Analysis (DCA). This method quantifies the net benefit of employing the model across a spectrum of risk thresholds, thereby evaluating its real-world applicability. The net benefit is mathematically defined as In this formula, TP and FP represent the counts of true positives and false positives, respectively; N is the total patient cohort size; and pt is the designated risk threshold probability. This metric provides a clinically intuitive measure by weighing the benefit of true positive identifications against the detriment of false positive results. It allows for a direct comparison of the model’s performance against the default clinical strategies of “treat all” or “treat none.” The selection of the threshold probability range was informed by clinical pragmatism and established literature. We focused on a range of 0.2–0.6, as this interval represents a common zone of clinical uncertainty in pneumonia diagnostics, where clinicians are most likely to use predictive probabilities to guide subsequent diagnostic or therapeutic decisions. This range reflects authentic clinical scenarios while avoiding potential biases introduced by extreme, clinically irrelevant thresholds. The DCA curves were generated using the rmda package in the R statistical environment, and confidence intervals were estimated via a bootstrap procedure with 1,000 resamples to ensure the robustness of the findings. Model feature importance analysis using Shapley Additive Explanations To enhance model interpretability, we utilized the SHAP methodology to systematically analyze feature importance [21]. Grounded in the Shapley value principle from game theory, SHAP quantifies the marginal contribution of each feature to the model’s predictions, thereby elucidating its precise influence on the final output. This approach not only assesses the global importance of each feature but also deconstructs individual predictions to illustrate how features collaboratively influence the model’s output. In this study, we further leveraged SHAP interaction analysis to probe the interplay between key features. Interaction SHAP values capture the joint contributions of features to the prediction outcome, unveiling synergistic effects that transcend individual variables. This methodology allows us to discern how features interact and collectively impact predictions under varying conditions, affording a more profound understanding of their combined influence. From a mathematical modeling perspective, these non-linear and interaction effects manifest through distinct mechanisms in various algorithms. For instance, gradient boosting models recursively partition the feature space via multiple decision trees, which inherently models non-linear relationships and interactions among features. This process can be conceptualized as a piecewise function, wherein the contribution of one feature is contingent upon the value range of another. Conversely, neural networks execute complex non-linear mappings from input features to output predictions through a combination of multi-layered linear transformations and non-linear activation functions (e.g., ReLU or sigmoid). Throughout this process, the hidden layers progressively ascertain high-order interaction patterns between features. By integrating SHAP’s global importance analysis with its interaction analytics, we not only identify the significance of individual features but also visually elucidate the synergistic mechanisms through which these variables operate in model predictions. Collectively, these analyses furnish more profound and robust explanations for disease prediction models, thereby augmenting their utility and practical value in clinical decision-making. Nomogram construction and validation A nomogram for disease risk prediction was formulated using laboratory markers, implemented via the “rms” package in R. This model quantifies the contribution of each predictor through a “total points” system, assigning point values based on feature significance. Calibration curves were utilized to evaluate predictive precision, while decision curve analysis (DCA) assessed the model’s clinical utility. These analyses collectively ensure the model’s reliability and practical value in disease prediction. To construct a nomogram for disease prediction, we developed a multivariate logistic regression model designed to integrate multiple predictors and quantify the probability of pneumonia. The underlying model is mathematically expressed as the log-odds (logit) of the probability p: logit(p) = β0 + β1X1 + β2X2 + ⋯ + βkXk. In this equation, p denotes the probability of the target event (e.g., lobar pneumonia), βᵢ represents the regression coefficient for each predictor, and Xᵢ is the corresponding predictor variable. For the nomogram’s construction, these regression coefficients were linearly transformed into a points-based scoring system. Conventionally, the predictor with the largest absolute coefficient value was assigned a maximum of 100 points, and the scores for the remaining variables were scaled proportionally. The sum of these points for an individual patient yields a total score, which is then mapped back through the logistic function to provide a direct estimate of the event probability. The nomogram’s calibration was rigorously assessed through a multi-faceted approach. Calibration curves were generated to visually compare the nomogram-predicted probabilities against the actual observed frequencies. To ensure the stability of this assessment and mitigate overfitting, we employed a bootstrap resampling procedure with 1000 iterations. The Hosmer–Lemeshow goodness-of-fit test was subsequently performed to statistically evaluate the concordance between predicted and observed risks. A non-significant P-value (P > 0.05) was considered indicative of adequate model calibration. Furthermore, the Brier score was calculated to quantify the mean squared error between the predicted probabilities and the actual outcomes, where a lower score signifies superior calibration. This comprehensive validation protocol, combining graphical assessment with statistical testing, confirms the nomogram’s robust calibration and reliability for clinical application. Statistical analysis Continuous variables are summarized as mean ± standard deviation (SD) or median [interquartile range], while categorical variables are presented as frequencies and percentages (n, %). For intergroup comparisons, the Mann–Whitney U test was employed for continuous variables, and the chi-square test was used for categorical variables, with a two-tailed p-value < 0.05 considered statistically significant. Formal comparison of ROC curves between models was performed using the DeLong test for correlated ROC curves, with statistical significance defined as p < 0.05. Assumptions for each statistical test were verified. The effect size for the Mann–Whitney U test was reported using the rank-biserial correlation coefficient (r), with thresholds of 0.1, 0.3, and 0.5 representing small, medium, and large effects, respectively. For the chi-square test, the effect size was quantified using Cramér’s V, with values < 0.2, 0.2–0.4, and > 0.4 indicating small, moderate, and large effects, respectively. The discriminatory ability of individual markers and comprehensive models to differentiate between pneumonia subtypes was evaluated using Receiver Operating Characteristic (ROC) curve analysis. The Area Under the Curve (AUC), sensitivity, specificity, positive predictive value (PPV), and negative predictive value (NPV) were calculated, along with their 95% confidence intervals (CIs). The DeLong test was used to formally compare AUCs. All statistical analyses were performed using R version 4.4.1 (R Foundation for Statistical Computing, Vienna, Austria). Results Comparative analysis of hematological characteristics Supplementary Table 1 presents a comprehensive comparison of hematological parameters between the bronchopneumonia (n = 1868) and lobar pneumonia (n = 436) cohorts, revealing pronounced differences across multiple markers (P < 0.01). Specifically, the bronchopneumonia cohort exhibited significantly elevated levels of lymphocyte percentage (LYM%), large platelet count (P-LCT), platelet–larger cell ratio (P-LCR), plateletcrit (PCT), lymphocyte absolute count (LYM#), mean platelet volume (MPV), aspartate aminotransferase (AST), red cell distribution width-standard deviation (RDW-SD), platelet count (PLT), white blood cell count (WBC), creatine kinase (CK), monocyte percentage (MONO%), red cell distribution width-coefficient of variation (RDW-CV), triglycerides (TG), lactate dehydrogenase (LDH), albumin-to-globulin ratio (A/G), phosphate (P), aspartate aminotransferase-to-alanine aminotransferase ratio (AST/ALT), potassium (K⁺), urea-to-creatinine ratio (UREA/CREA), alanine aminotransferase (ALT), glucose (GLU), chloride (Cl⁻), uric acid (UA), and mean corpuscular volume (MCV) compared to the lobar pneumonia cohort. Conversely, levels of creatinine (CREA), eosinophil absolute count (EOS#), total protein (TP), retinol-binding protein (RBP), neutrophil percentage (NEU%), globulin (GLOB), albumin (ALB), high-sensitivity C-reactive protein (hsCRP), urea (UREA), hemoglobin (HGB), low-density lipoprotein cholesterol (LDL-C), sodium (Na⁺), red blood cell count (RBC), magnesium (Mg2⁺), total cholesterol (CHOL), adenosine deaminase (ADA), total bilirubin (TBIL), mean corpuscular hemoglobin concentration (MCHC), carbon dioxide combining power (CO₂), direct bilirubin (DBIL), indirect bilirubin (IBIL), and hematocrit (HCT) were significantly diminished. These marked disparities in hematological profiles underscore fundamental pathophysiological distinctions between bronchopneumonia and lobar pneumonia, establishing a robust foundation for subsequent diagnostic classification. Feature selection using machine learning A suite of machine learning algorithms was utilized to systematically evaluate and prioritize the hematological features capable of differentiating bronchopneumonia from lobar pneumonia. During this feature selection phase, potential confounding variables such as age, gender, and comorbidities were deliberately excluded from the models. This methodological approach was adopted to isolate and identify the intrinsic hematological markers with the most potent discriminatory power between the two pneumonia subtypes. Initial feature importance analysis using the XGBoost model (Fig. 2A) revealed that a high plateletcrit (P-LCT), absolute lymphocyte count (LYM#), and creatinine (CREA) level were associated with significant predictive gains, underscoring their primary contributions to the classification task. The Support Vector Machine-Recursive Feature Elimination (SVM-RFE) analysis (Fig. 2B) demonstrated that as the feature count increased from 0 to 14, the five-fold cross-validation error rate progressively decreased from 0.105 to a plateau of 0.0749, thereby yielding an optimal feature subset of 14 markers. This subset notably included P-LCT, globulin (GLOB), and CREA (Fig. 2C; Supplementary Table 2). Concurrently, the error rate analysis from the Random Forest model (Fig. 2D) indicated model convergence and robustness, as the out-of-bag error stabilized below 0.10 after approximately 100 trees were grown. The corresponding feature importance analysis (Fig. 2E; Supplementary Table 3) further corroborated the pivotal role of platelet-large cell ratio (P-LCR), LYM#, and mean platelet volume (MPV) in maximizing the mean decrease in Gini impurity. Feature Selection Results Using Multiple Machine Learning Methods for Hematological Characteristics of Bronchopneumonia and Lobar Pneumonia Patients A Feature importance analysis from the XGBoost model. B, C Feature selection using Support Vector Machine-Recursive Feature Elimination (SVM-RFE). D, E Error rate and feature importance analysis from the Random Forest model. F Venn diagram depicting feature overlap among XGBoost, SVM-RFE, and Random Forest models, with 62.3% (33 markers) unique to XGBoost, 11.3% (6 markers) unique to Random Forest, and 28.4% (14 markers) as shared core features with no overlap in a null set To leverage the complementary strengths of these disparate algorithms, we synthesized their outputs into a consensus feature selection strategy. This integration capitalized on the synergy between gradient-based importance (XGBoost), recursive elimination of non-discriminative features (SVM-RFE), and ensemble-based impurity reduction (Random Forest). A Venn diagram (Fig. 2F) illustrated the overlap among the feature sets identified by each model: 62.3% of features (33 markers) were unique to XGBoost, 11.3% (6 markers) were unique to Random Forest, and a core set of 28.4% (14 markers) represented the consensus features identified by all three methods. Diagnostic utility of machine learning models Given the limitations of single biomarkers in diagnosing pediatric lobar pneumonia, this study evaluated the diagnostic potential of multi-feature combinations using advanced machine learning methodologies. Receiver Operating Characteristic (ROC) curve analyses of individual biomarkers (e.g., NEU%, LYM%, EOS%, GLU) revealed modest performance, with Area Under the Curve (AUC) values of 0.722 (NEU%), 0.702 (LYM%), and 0.574 (EOS%) in the training cohort (Fig. 3A, B). These AUC values, all below 0.8, underscore the constrained predictive capacity of individual markers, inadequate for meeting the precision requirements of clinical diagnostics. Performance of individual markers and machine learning models in training and testing cohorts. A, B ROC curves and corresponding AUC values for individual biomarkers, illustrating their discriminative capacity for classification tasks. C, D ROC curves and AUC values for multiple machine learning models in training and testing cohorts, evaluating overall classification performance. E, F Decision curve analysis for training and testing cohorts, depicting net benefits across risk thresholds to assess clinical utility To address this limitation, twelve machine learning algorithms, including Random Forest, SVM Kernel, Neural Network, and Gradient Boosting, were developed and evaluated through ROC curve analyses across training, testing, and external validation cohorts (Fig. 3C, D). A detailed comparison of performance metrics for all twelve machine learning models is presented in Table 1. The Gradient Boosting model exhibited exemplary performance, achieving an AUC of 0.947 (95% CI 0.934–0.960) in the training cohort, with a sensitivity of 79.6%, specificity of 97.6%, positive likelihood ratio (LR +) 33.2, negative likelihood ratio (LR −) 0.21, positive predictive value (PPV) of 86.4%, negative predictive value (NPV) of 92.6%, and F1 score of 75.2% (Supplementary Table 4 and Table 1). In the testing cohort, the AUC improved to 0.968 (95% CI 0.954–0.982), with a sensitivity of 79.8%, specificity of 97.9%, positive likelihood ratio (LR +) 37.9, negative likelihood ratio (LR −) 0.21, PPV of 89.1%, NPV of 94.3%, and F1 score of 81.3% (Supplementary Table 5 and Table 1). Confusion matrix analyses (Fig. 4A, B) demonstrated accuracies of 92.9% and 92.6% in the training and testing cohorts, respectively, affirming the Gradient Boosting model’s superior efficacy in distinguishing bronchopneumonia from lobar pneumonia, rendering it highly suitable for clinical screening or diagnostic support. Table 1Performance metrics of machine learning models for the training set and testing setTraining set (n = 1612, 1307BP, 305 LP)ModelRFGBSVMLRKNNPLSBoostNNNBDALassoAdaSensitivity (95% CI)0.630 (0.593–0.666)0.796 (0.764–0.826)0.590 (0.553–0.627)0.672 (0.635–0.707)0.623 (0.586–0.659)0.510 (0.473–0.547)0.662 (0.625–0.698)0.623 (0.586–0.659)0.639 (0.602–0.675)0.600 (0.563–0.636)0.603 (0.566–0.639)0.670 (0.633–0.705)Specificity (95% CI)0.992 (0.984–0.997)0.976 (0.964–0.985)0.993 (0.985–0.997)0.966 (0.951–0.977)0.977 (0.965–0.986)0.990 (0.981–0.995)0.982 (0.971–0.990)0.979 (0.968–0.987)0.963 (0.948–0.975)0.970 (0.956–0.981)0.987 (0.978–0.993)0.970 (0.956–0.981)Accuracy (95% CI)0.923 (0.902–0.941)0.917 (0.895–0.935)0.917 (0.895–0.935)0.910 (0.888–0.929)0.910 (0.888–0.929)0.900 (0.877–0.920)0.922 (0.901–0.940)0.912 (0.890–0.931)0.902 (0.879–0.922)0.900 (0.877–0.920)0.914 (0.892–0.933)0.920 (0.899–0.938)PPV (95% CI)0.946 (0.915–0.968)0.864 (0.831–0.893)0.952 (0.922–0.973)0.820 (0.783–0.853)0.864 (0.829–0.894)0.950 (0.917–0.972)0.898 (0.863–0.927)0.876 (0.841–0.906)0.802 (0.763–0.837)0.850 (0.812–0.883)0.915 (0.882–0.941)0.870 (0.836–0.900)NPV (95% CI)0.920 (0.898–0.939)0.926 (0.906–0.943)0.912 (0.889–0.931)0.927 (0.907–0.944)0.917 (0.896–0.935)0.890 (0.866–0.911)0.926 (0.906–0.943)0.918 (0.897–0.936)0.920 (0.899–0.938)0.910 (0.888–0.929)0.914 (0.893–0.932)0.920 (0.899–0.938)F1-score0.7560.7520.7290.7390.7240.6600.7620.7280.7120.7000.7270.760Youden’s Index0.6210.6410.5830.6380.6000.5000.6450.6020.6030.5700.5900.650Test set (n = 692, 565 BP, 127 LP)Sensitivity (95% CI)0.702 (0.619–0.777)0.798 (0.721–0.862)0.664 (0.580–0.742)0.730 (0.648–0.802)0.695 (0.611–0.770)0.557 (0.471–0.640)0.725 (0.642–0.798)0.779 (0.699–0.846)0.702 (0.619–0.777)0.672 (0.588–0.749)0.626 (0.541–0.706)0.718 (0.635–0.792)Specificity (95% CI)0.986 (0.975–0.993)0.979 (0.966–0.988)0.986 (0.975–0.993)0.950 (0.930–0.966)0.986 (0.975–0.993)0.993 (0.984–0.998)0.979 (0.966–0.988)0.957 (0.938–0.972)0.966 (0.949–0.979)0.977 (0.964–0.986)0.982 (0.970–0.990)0.986 (0.975–0.993)Accuracy (95% CI)0.932 (0.912–0.949)0.935 (0.915–0.951)0.925 (0.904–0.943)0.910 (0.887–0.929)0.931 (0.911–0.948)0.910 (0.887–0.929)0.931 (0.911–0.948)0.923 (0.902–0.941)0.916 (0.894–0.935)0.919 (0.897–0.938)0.915 (0.893–0.934)0.935 (0.915–0.951)PPV (95% CI)0.920 (0.856–0.961)0.891 (0.825–0.938)0.916 (0.847–0.960)0.780 (0.706–0.843)0.919 (0.854–0.961)0.948 (0.882–0.982)0.888 (0.821–0.936)0.810 (0.737–0.870)0.829 (0.754–0.889)0.871 (0.800–0.924)0.891 (0.819–0.941)0.922 (0.860–0.962)NPV (95% CI)0.934 (0.914–0.951)0.943 (0.924–0.958)0.926 (0.905–0.944)0.930 (0.909–0.947)0.933 (0.913–0.950)0.906 (0.883–0.926)0.938 (0.919–0.954)0.949 (0.930–0.964)0.933 (0.913–0.950)0.927 (0.906–0.945)0.918 (0.897–0.936)0.937 (0.918–0.953)F1-score0.7970.8130.7700.7500.7910.7020.7980.7940.7600.7590.7350.807Youden’s Index0.6880.7270.6500.6800.6800.5500.7040.7360.6680.6490.6080.703BP Bronchopneumonia, LP Lobar pneumonia, RF RandomForest, GB GradientBoosting, SVM SVM_Kernel, LR LogisticModel, KNN NeighborMethod, PLS PLSModel, Boost BoostingMethod, NN NeuralNet, NB BayesMethod, DA DiscriminantModel, Lasso Lasso, Ada AdaptiveBoosting Performance metrics of machine learning models for the training set and testing set BP Bronchopneumonia, LP Lobar pneumonia, RF RandomForest, GB GradientBoosting, SVM SVM_Kernel, LR LogisticModel, KNN NeighborMethod, PLS PLSModel, Boost BoostingMethod, NN NeuralNet, NB BayesMethod, DA DiscriminantModel, Lasso Lasso, Ada AdaptiveBoosting Confusion matrices and model accuracy in training and testing cohorts. A, B Confusion matrices for the training (A) and testing (B) cohorts, alongside corresponding model accuracies. These matrices visually represent classification performance by comparing predicted versus actual labels, with accuracies of 92.9% (training) and 92.6% (testing), indicating stable and effective model performance across datasets To further assess the clinical utility of our models, a Decision Curve Analysis (DCA) was conducted to compare their net benefits across a range of clinically relevant risk thresholds (Fig. 3E, F). The analysis was performed over a threshold probability (pt) range of 0.2–0.6, which reflects the typical decision-making spectrum in pneumonia diagnostics. The results revealed that several models, notably Gradient Boosting and Random Forest, demonstrated a superior net benefit compared to the default strategies of “Treat All” or “Treat None” across this range. This indicates that their application could substantially enhance clinical decision-making by optimizing patient outcomes while simultaneously mitigating the risks associated with unnecessary medical interventions. Model performance evaluation in an independent validation cohort To assess model robustness, all models were evaluated on an independent external validation cohort. Although the Partial Least Squares (PLS) and SVM Kernel models achieved perfect AUC values of 1.00, we acknowledge that such performance, while possible, raises concerns about potential overfitting. To mitigate this, we carefully examined model regularization, performed five-fold cross-validation with grid search during training, and verified that the external validation set was entirely independent from the training data. Moreover, additional performance metrics—including accuracy, precision, recall, F1-score, and specificity—were consistent with the reported AUC values, supporting the robustness of these findings. Nevertheless, considering the risk of overfitting associated with perfect discrimination, we identified the Gradient Boosting (GB) model as the most clinically reliable classifier (Fig. 5). To statistically confirm the superior performance of the Gradient Boosting model, we compared its AUC against other top models (Random Forest, Neural Network) using the DeLong test. The results demonstrated that the Gradient Boosting model’s AUC was significantly higher (p < 0.05) on the testing and external validation sets (Supplementary Table 6). It achieved an AUC of 0.989 (95% CI 0.981–0.997) for distinguishing bronchopneumonia from lobar pneumonia, with a sensitivity of 79.6% and specificity of 100% (Table 2, Fig. 5A, and Supplementary Table 7). Decision curve analysis (Fig. 5B) confirmed that the Gradient Boosting and Neural Network models yielded substantial net benefits within a 0.2–0.6 threshold range, underscoring their potential to guide therapeutic decisions and reduce unnecessary interventions. Model performance in the external validation cohort. A ROC curves and corresponding AUC values for multiple machine learning models, assessing classification performance. B Decision curve analysis, illustrating net benefits across risk thresholds to validate clinical utility Table 2Performance metrics of machine learning models for the external validation setModelRFGBSVMLRKNNPLSBoostNNNBDALassoAdaBoostSensitivity (95% CI)0.066 (0.024–0.139)0.796 (0.716–0.862)0.744 (0.659–0.817)0.771 (0.688–0.841)0.286 (0.204–0.380)0.419 (0.325–0.518)0.194 (0.124–0.282)0.811 (0.732–0.875)0.656 (0.567–0.738)0.784 (0.703–0.853)0.709 (0.622–0.786)0.458 (0.364–0.555)Specificity (95% CI)1.000 (0.990–1.000)1.000 (0.990–1.000)1.000 (0.990–1.000)0.996 (0.984–0.999)1.000 (0.990–1.000)1.000 (0.990–1.000)1.000 (0.990–1.000)1.000 (0.990–1.000)1.000 (0.990–1.000)0.974 (0.955–0.987)1.000 (0.990–1.000)0.987 (0.972–0.995)Accuracy (95% CI)0.533 (0.485–0.580)0.853 (0.817–0.885)0.872 (0.837–0.902)0.883 (0.849–0.912)0.643 (0.596–0.688)0.709 (0.665–0.751)0.597 (0.550–0.643)0.905 (0.874–0.930)0.828 (0.790–0.862)0.879 (0.845–0.908)0.855 (0.819–0.887)0.722 (0.678–0.763)PPV (95% CI)1.000 (0.594–1.000)1.000 (0.955–1.000)1.000 (0.947–1.000)0.994 (0.941–1.000)1.000 (0.844–1.000)1.000 (0.898–1.000)1.000 (0.775–1.000)1.000 (0.958–1.000)1.000 (0.932–1.000)0.967 (0.906–0.991)1.000 (0.945–1.000)0.972 (0.882–0.997)NPV (95% CI)0.517 (0.469–0.565)0.728 (0.671–0.780)0.796 (0.744–0.841)0.813 (0.762–0.857)0.584 (0.532–0.635)0.632 (0.579–0.683)0.554 (0.501–0.606)0.841 (0.792–0.883)0.744 (0.691–0.792)0.819 (0.768–0.863)0.775 (0.722–0.822)0.646 (0.592–0.697)F1-score0.1240.7910.8540.8680.4450.5900.3250.8950.7930.8660.8300.623Youden’s Index0.0660.8060.7440.7670.2860.4190.1940.8110.6560.7580.7090.445 Performance metrics of machine learning models for the external validation set SHAP analysis and model interpretability To enhance model interpretability, Shapley Additive Explanations (SHAP) analysis was utilized to elucidate feature significance (Mean Absolute SHAP), feature value distributions (Bee Swarm plot), and feature interdependencies (Fig. 6). The analysis identified large platelet count (P-LCT, Mean Absolute SHAP: 0.057) and lymphocyte percentage (LYM%, 0.065) as primary predictive drivers (Fig. 6A). The pronounced significance of these features underpins the Gradient Boosting model’s exemplary performance, reflecting robust associations between elevated P-LCT and LYM% values and disease risk, such as severe infection or inflammation (Supplementary Figure S1). The Bee Swarm plot (Fig. 6B) further demonstrated that high P-LCT and LYM% values (depicted in red) correlated with heightened disease risk predictions, emphasizing their pivotal role in assessing disease severity. Feature dependency scatter plots (Fig. 6C) illustrated non-linear relationships and interaction effects between features such as LYM% and P-LCT with SHAP values, suggesting that elevated LYM% values, indicative of vigorous immune responses, correspond to increased SHAP contributions. Collectively, P-LCT and LYM% emerged as cornerstone biomarkers, not only enhancing the model’s diagnostic efficacy but also facilitating rapid identification of high-risk patients (e.g., those with suspected sepsis or pneumonia), thereby guiding antibiotic therapy and hospitalization decisions to optimize acute care and immunomodulatory strategies. Feature importance and SHAP value analysis. A Mean Absolute SHAP values, reflecting the overall influence of each feature on model predictions. B SHAP value distribution (Bee Swarm plot), illustrating the direction and magnitude of feature impacts on model outputs. C SHAP value versus feature value plots for key features, revealing non-linear relationships between feature changes and model outputs Clinical prediction model development To consolidate our findings, a clinical prediction model was constructed and rigorously evaluated via a nomogram, ROC curves, calibration plots, and decision curve analyses (DCA). The nomogram (Fig. 7A) synthesizes multiple biomarkers (e.g., NEU, LYM, hsCRP, AST) into a cumulative risk score, facilitating rapid clinical risk stratification. These selected markers capture multidimensional pathophysiological profiles: hsCRP serves as an inflammatory index, AST and GLOB denote hepatic integrity, and CREA reflects renal function. While this multifactorial architecture enhances the model’s diagnostic comprehensiveness, its complexity necessitates that clinicians remain cognizant of the specific clinical significance of each biomarker. Development and evaluation of a multi-marker clinical prediction model. A Nomogram based on multiple markers for predicting lobar pneumonia probability, with each marker assigned points mapped to risk probabilities. B ROC curve for the nomogram model, demonstrating high classification accuracy (AUC = 0.962). C Calibration curve, assessing consistency between predicted probabilities and actual risks (C-index = 0.962). D Decision curve analysis, illustrating the nomogram’s net benefit across thresholds, highlighting its clinical utility The ROC curve (Fig. 7B, AUC = 0.962) substantiated the model’s robust discriminative efficacy, while the calibration plot (Fig. 7C, C-index = 0.962) corroborated exceptional concordance between predicted and observed probabilities. Decision curve analysis (Fig. 7D) indicated that the model yielded a superior net benefit compared to the “treat all” strategy at moderate risk thresholds. This effectively mitigates unwarranted medical interventions while outperforming the “treat none” approach across most thresholds, thereby facilitating the precise identification of patients necessitating treatment. Collectively, these findings validate the model’s clinical utility as a robust diagnostic tool for discriminating between bronchopneumonia and lobar pneumonia. Discussion Differentiating pediatric bronchopneumonia from lobar pneumonia poses substantial diagnostic challenges, particularly in atypical presentations or in younger pediatric cohorts, where the specific identification of lobar pneumonia is frequently obscured. While radiological findings remain the gold standard for distinguishing between these two conditions, our study explores the potential for hematological parameters to aid in subtype differentiation, especially in clinical environments where imaging may be delayed, inaccessible, or unavailable. Accumulating evidence highlights the insufficiency of single biomarkers in yielding precise diagnoses, necessitating the adoption of multi-marker strategies as a prevailing paradigm [25–28]. However, identifying optimal biomarker combinations and establishing standardized decision frameworks remains fraught with difficulties. Specifically, existing studies often underutilize validated markers, thereby curtailing their diagnostic utility. Moreover, complex interactions among established markers may mask the incremental value of novel candidates. Consequently, to meet clinical demands while containing diagnostic expenditures, a rigorous reappraisal of the latent potential within existing, clinically accessible markers is imperative to expedite their translation into routine practice. Our research demonstrates the efficacy of an integrated machine learning approach in discriminating bronchopneumonia from lobar pneumonia. Feature‑selection results highlighted markers such as P‑LCT, LYM#, and CREA, which capture divergent inflammatory phenotypes across pneumonia subtypes. For example, lymphopenia (decreased LYM#) may signal infection‑associated immunosuppression in certain bronchopneumonia cases, whereas elevated CREA may reflect dehydration commonly accompanying bacterial lobar pneumonia. This observation aligns with Sdougka et al.[29], who reported the predictive value of analogous biomarkers in pediatric respiratory tract infections. The integrated approach improves feature stability (Jaccard similarity increasing from 0.68 to 0.75 with single methods to 0.85), attenuates noise, and yields more reliable biomarker identification. In addition, leveraging multiple machine learning algorithms, our system systematically revealed profound hematological differences between bronchopneumonia and lobar pneumonia in children, establishing the superior diagnostic performance of the Gradient Boosting model (AUC = 0.947–0.989). These results exceed those of prior pneumonia‑classification studies (typical AUC 0.717–0.830 in the literature), underscoring robustness on imbalanced datasets [30]. Through SHAP (Shapley Additive Explanations) analysis, the large platelet ratio (P‑LCT) and lymphocyte percentage (LYM%) emerged as core biomarkers, providing efficient tools for precise diagnosis and risk stratification. This advance not only addresses the limitations of single‑biomarker diagnostics but also illustrates the transformative potential of artificial intelligence for classifying complex pediatric diseases through interpretable modeling, laying a robust foundation for optimizing early clinical support and treatment decision‑making in childhood pneumonia. Furthermore, a key consideration for clinical translation, especially in resource-limited settings, is the minimal set of tests required for accurate prediction. Our SHAP analysis identified P-LCT, LYM%, and CREA as the predominant drivers of model performance. This minimal feature set facilitates the development of accessible clinical decision aids, such as a paper-based nomogram or a lightweight mobile application, ensuring that the benefits of this model can be extended to small hospitals and primary care clinics. The pivotal roles of large platelet count (P-LCT) and lymphocyte percentage (LYM%) likely arise from their integral functions within the immune-inflammatory networks of pediatric infectious pneumonia [31]. Elevated P-LCT levels may reflect heightened platelet activation within the inflammatory microenvironment, particularly in bronchopneumonia, potentially linked to the release of platelet factor 4 (PF4) or P-selectin, which precipitate localized microvascular injury and coagulation cascades [32–34]. Conversely, an elevated LYM% suggests a vigorous adaptive immune response in bronchopneumonia, possibly driven by T-cell subset activation in response to viral or atypical pathogens (e.g., respiratory syncytial virus or Mycoplasma pneumoniae), whereas the neutrophil-dominated profile in lobar pneumonia aligns with acute inflammatory patterns characteristic of bacterial infections (e.g., Streptococcus pneumoniae) [35]. These distinctions not only underscore the etiological and inflammatory heterogeneity of pediatric pneumonia but also reflect the immature immune system and dynamic infection progression in children. The non-linear interaction effects between P-LCT and LYM%, as elucidated by Shapley Additive Explanations (SHAP) analysis, further suggest that synergistic immune-inflammatory responses may modulate disease progression through specific signaling pathways, such as TLR4 or NF-κB [36–38]. Moreover, the top predictive features identified by our model—P-LCT and LYM%—were reviewed by pediatric clinical experts on our team and were deemed to have high clinical relevance, as their roles align closely with the established pathophysiology of pediatric respiratory infections. Future investigations leveraging single-cell transcriptomics or metabolomics to explore associations between P-LCT, LYM%, and inflammatory cytokines (e.g., IL-6, TNF-α) could illuminate the molecular pathophysiology of pediatric pneumonia, potentially identifying novel therapeutic targets [39]. Relative to global research on pediatric pneumonia diagnostics, this study evinces marked superiority in diagnostic precision, interpretability, and methodological innovation. Traditional investigations have predominantly relied on singular biomarkers, such as high-sensitivity C-reactive protein (hsCRP) or neutrophil percentage (NEU%), which are constrained by moderate AUC values ranging from 0.70 to 0.85 [40–42]. Recent machine learning-based approaches to pneumonia classification have demonstrated advancements [43]; however, their feature selection often lacks transparency, hindering clinical applicability. By contrast, this study integrates multidimensional hematological features via a Gradient Boosting model, achieving an outstanding AUC of 0.989, substantially surpassing conventional Logistic Regression models [44]. Notably, SHAP analysis elucidates the pivotal roles of P-LCT and LYM% in pediatric pneumonia classification, offering an intuitive interpretive framework through feature dependency scatter plots and Bee Swarm plots. This addresses a critical deficiency in the interpretability of machine learning models for pediatric diagnostics. Such transparency not only enhances clinician confidence in predictive outcomes but also lays a theoretical foundation for the standardized integration of artificial intelligence in diagnostic applications. Furthermore, the model’s consistently high performance in an independent external validation cohort (AUC: 0.989) underscores its robustness and generalizability, outperforming recent CatBoost-based models for pediatric pneumonia diagnosis (AUC: 0.934) [45]. The Gradient Boosting model’s elevated sensitivity (79.6%) and perfect specificity (100%) underscore its considerable potential for rapid screening of pediatric pneumonia, particularly in resource-limited primary care settings. As routine components of complete blood counts, P-LCT and LYM% are cost-effective and readily accessible, serving as preliminary biomarkers for early clinical support and risk stratification to inform antibiotic therapy or hospitalization decisions. Decision Curve Analysis (DCA) demonstrates that the model delivers substantial net benefits within a 0.2–0.6 risk threshold range, surpassing both “treat all” and “treat none” strategies. This capability mitigates overtreatment risks while accurately identifying patients requiring intervention. Such optimized decision-support functionality carries profound implications for combating antibiotic resistance, optimizing healthcare resource allocation, and improving pediatric outcomes. For example, amidst rising global antibiotic resistance, the model’s diagnostic precision can curtail unnecessary antibiotic prescriptions, aligning with the World Health Organization’s antimicrobial stewardship goals [46]. Additionally, the nomogram-based risk scoring system, which distills multidimensional biomarkers into intuitive scores, holds significant potential for integration into pediatric electronic medical record systems through micro-sampling techniques and mobile applications, thereby markedly enhancing diagnostic efficiency. The clinical deployment of this model faces several practical considerations. Importantly, the model is not intended to replace radiographic evaluation, which remains the clinical gold standard for pneumonia diagnosis and subtyping. Instead, it is designed to serve as a complementary decision-support tool, particularly during early clinical assessment or in settings where imaging is delayed, unavailable, or inconclusive. In pediatric practice, limited blood sampling volumes and variable parental acceptance may restrict the routine assessment of hematological markers such as large platelet count (P-LCT) and lymphocyte percentage (LYM%), especially in primary care settings. In addition, the computational complexity of the Gradient Boosting model may pose implementation barriers in resource-limited environments [47]. These challenges could be mitigated by developing a simplified scoring system based on a minimal set of key markers (e.g., P-LCT and LYM%) or by deploying the model through user-friendly platforms, such as cloud-based or mobile clinical decision-support tools. Several limitations of this study warrant consideration. First, the dataset exhibited class imbalance between bronchopneumonia and lobar pneumonia, which may bias predictions toward the majority class and affect performance in minority subgroups. Second, the near-perfect AUCs observed in some models during external validation raise the possibility of overfitting, underscoring the need for further validation. Although the Gradient Boosting model demonstrated relative robustness, its stability should be confirmed in larger, multicenter pediatric cohorts. Third, we did not comprehensively assess the influence of pediatric-specific biological and clinical factors on model performance. Immune system immaturity may lead to age-dependent hematological patterns, and marker expression may vary across pathogens or disease severity. In addition, potential confounders such as feeding modality, prematurity, vaccination status, and infection stage were not fully accounted for, which may limit generalizability. Future studies should focus on several key directions. First, the model should be validated in large-scale, multicenter cohorts with diverse demographic and clinical characteristics to ensure robustness across age groups and disease spectra. Second, integrating additional biomarkers and multimodal data—such as inflammatory marker dynamics, etiologic testing, or imaging-derived features—may further enhance diagnostic performance while preserving interpretability. Third, clarifying associations between hematological markers and specific pathogens could support more refined clinical stratification. Finally, embedding simplified versions of the model into real-time clinical workflows, such as electronic medical record systems or mobile applications, may facilitate broader adoption and strengthen its role as an adjunctive tool in pediatric pneumonia management. Conclusion This study employs sophisticated machine learning methodologies and SHAP (Shapley Additive Explanations) analysis to delineate critical hematological distinctions between bronchopneumonia and lobar pneumonia, culminating in the development of a high-performance Gradient Boosting diagnostic model. The identification of large platelet count (P-LCT) and lymphocyte percentage (LYM%) as pivotal biomarkers provides novel insights into the pathophysiological mechanisms of pneumonia and highlights the potential of hematological markers to support early clinical decision-making. These findings offer a promising complementary tool for precise clinical diagnosis and risk stratification, particularly in settings where imaging is delayed or unavailable, and serve as a useful adjunct to traditional diagnostic methods. This approach surpasses the limitations of conventional single-marker approaches, illustrating the transformative potential of artificial intelligence in diagnosing complex diseases. Looking forward, the clinical deployment of this model could take several forms, including a user-friendly web-based calculator for rapid point-of-care assessment or, more optimally, integration as a decision-support module within laboratory information systems and electronic health records. This would provide clinicians with real-time, data-driven guidance to inform diagnosis and treatment decisions, directly addressing the need for improved diagnostic precision in pediatric pneumonia, while ensuring that radiographic evaluation remains the gold standard for definitive diagnosis and subtyping. Supplementary Information Supplementary material 1 Acknowledgements Not applicable. Author contributions SPD: Conceptualization, methodology, supervision, writing—review & editing. ZHC: Visualization, writing—original draft. JHG: Resources, software, data curation, validation. All authors have read and approved the manuscript. Funding This work was supported by Natural Science Foundation of Ningde, China(2024J67). Data availability The data supporting the findings of this study are available from the corresponding author upon reasonable request. Declarations Ethics approval and consent to participate This study has been approved by the Ethics Committee of Siyang Hospital with the approval number HY2024005. Competing interests The authors declare no competing interests. Footnotes Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. References Associated Data Supplementary Materials Supplementary material 1 Data Availability Statement The data supporting the findings of this study are available from the corresponding author upon reasonable request.