Capsule Neural Networks with Bayesian Optimization for Pediatric Pneumonia Detection from Chest X-Ray Images
Abstract
1. Introduction
2. Literature Review
3. Materials and Methods
3.1. Dataset
3.2. Preprocessing
3.3. Capsule Neural Networks
3.4. Optuna
3.5. Proposed Model
3.6. Software and Hardware Configuration
3.7. Metrics
- Accuracy measures the proportion of correctly classified samples among all samples:
- Recall (Sensitivity, True Positive Rate) quantifies the proportion of correctly identified positive cases:
- Specificity (True Negative Rate) quantifies the proportion of correctly identified negative cases:
- Precision (Positive Predictive Value, PPV) measures the proportion of correctly predicted positive cases among all predicted positives:
- Negative Predictive Value (NPV) measures the proportion of correctly predicted negative cases among all predicted negatives:
- False Positive Rate (FPR) measures the proportion of negative cases incorrectly classified as positive:
- F1-score is the harmonic mean of precision and recall:
- Area Under the Curve (AUC) refers to the area under the Receiver Operating Characteristic (ROC) curve, which illustrates the trade-off between the True Positive Rate and the False Positive Rate. AUC values range from 0 to 1, with higher values indicating better discrimination performance.
- Matthews Correlation Coefficient (MCC) provides a balanced measure that can be used even if the classes are of very different sizes:
3.8. Explainability Analysis
4. Results
4.1. Capsule Neural Network Model
4.2. Capsule Neural Network Tuned with Bayesian Optimization
5. Discussion
5.1. Comparison with State-of-the-Art Approaches
5.2. Strengths of the Approach
5.3. Limitations and Challenges
5.4. Future Research Directions
- Federated learning—Training capsule networks across multiple institutions in a privacy-preserving manner would enable larger and more diverse datasets, reducing bias and improving generalization without compromising patient confidentiality.
- Multimodal clinical data integration—Incorporating patient metadata (e.g., age, sex, laboratory test results) alongside imaging data could improve diagnostic accuracy and allow the model to predict disease severity or comorbidities.
- Clinical validation and standardization—Multicenter prospective trials comparing CapsNet with radiologists are essential to assess its impact on clinical workflows. Regulatory certification will also require comprehensive documentation and monitoring systems capable of detecting model drift over time.
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Khan, M.A.; Bajwa, A.; Hussain, S.T. Pneumonia: Recent Updates on Diagnosis and Treatment. Microorganisms 2025, 13, 522. [Google Scholar] [CrossRef]
- Yanar, E.; Hardalaç, F.; Ayturan, K. PELM: A Deep Learning Model for Early Detection of Pneumonia in Chest Radiography. Appl. Sci. 2025, 15, 6487. [Google Scholar] [CrossRef]
- Kudagammana, S.T.; Premathilaka, S.; Vidanapathirana, G.; Kudagammana, W. Childhood mortality due to pneumonia; evidence from a tertiary paediatric referral center in Sri Lanka. BMC Public Health 2024, 24, 3351. [Google Scholar] [CrossRef]
- Campbell, H.; el Arifeen, S.; Hazir, T.; O’Kelly, J.; Bryce, J.; Rudan, I.; Qazi, S.A. Measuring Coverage in MNCH: Challenges in Monitoring the Proportion of Young Children with Pneumonia Who Receive Antibiotic Treatment. PLoS Med. 2013, 10, e1001421. [Google Scholar] [CrossRef]
- Hu, T.; Podmore, B.; Barnett, R.; Beier, D.; Galetzka, W.; Qizilbash, N.; Heckl, D.; Boellinger, T.; Weaver, J. Healthcare resource utilization and cost of pneumococcal disease in children in Germany, 2014–2019: A retrospective cohort study. Pneumonia 2023, 15, 7. [Google Scholar] [CrossRef] [PubMed]
- Zhang, S.; Sammon, P.M.; King, I.; Andrade, A.L.; Toscano, C.M.; Araujo, S.N.; Sinha, A.; Madhi, S.A.; Khandaker, G.; Yin, J.K.; et al. Cost of management of severe pneumonia in young children: Systematic analysis. J. Glob. Health 2016, 6, 010408. [Google Scholar] [CrossRef]
- Hu, H.; Zhou, T.; Gao, J.; Ou, Y.; Ma, A.; Wang, P. Economic burden and influence factors among hospitalized children with bronchiolitis or pneumonia: A multiregional study in China. Front. Public Health 2024, 12, 1364854. [Google Scholar] [CrossRef] [PubMed]
- Liang, G.; Zheng, L. A transfer learning method with deep residual network for pediatric pneumonia diagnosis. Comput. Methods Programs Biomed. 2020, 187, 104964. [Google Scholar] [CrossRef] [PubMed]
- Bhatt, H.; Shah, M. A Convolutional Neural Network ensemble model for Pneumonia Detection using chest X-ray images. Healthc. Anal. 2023, 3, 100176. [Google Scholar] [CrossRef]
- Książek, W. Explainable Thyroid Cancer Diagnosis Through Two-Level Machine Learning Optimization with an Improved Naked Mole-Rat Algorithm. Cancers 2024, 16, 4128. [Google Scholar] [CrossRef]
- Alom, M.R.; Farid, F.A.; Rahaman, M.A.; Rahman, A.; Debnath, T.; Miah, A.S.M.; Mansor, S. An explainable AI-driven deep neural network for accurate breast cancer detection from histopathological and ultrasound images. Sci. Rep. 2025, 15, 17531. [Google Scholar] [CrossRef]
- Mousavi, S.M.; Moulaei, K.; Ahmadian, L. Classifying and diagnosing Alzheimer’s disease with deep learning using 6735 brain MRI images. Sci. Rep. 2025, 15, 22721. [Google Scholar] [CrossRef] [PubMed]
- Menashe, S.J.; Iyer, R.S.; Parisi, M.T.; Otto, R.K.; Stanescu, A.L. Pediatric Chest Radiographs: Common and Less Common Errors. Am. J. Roentgenol. 2016, 207, 903–911. [Google Scholar] [CrossRef] [PubMed]
- Stollfuss, J.; Schneider, K.; Krüger-Stollfuss, I. A comparative study of collimation in bedside chest radiography for preterm infants in two teaching hospitals. Eur. J. Radiol. Open 2015, 2, 118–122. [Google Scholar] [CrossRef] [PubMed]
- Thukral, B.B. Problems and preferences in pediatric imaging. Indian J. Radiol. Imaging 2015, 25, 359–364. [Google Scholar] [CrossRef]
- Toraman, S.; Alakus, T.B.; Turkoglu, I. Convolutional capsnet: A novel artificial neural network approach to detect COVID-19 disease from X-ray images using capsule networks. Chaos Solitons Fractals 2020, 140, 110122. [Google Scholar] [CrossRef]
- Haq, M.U.; Sethi, M.A.J.; Rehman, A.U. Capsule Network with Its Limitation, Modification, and Applications—A Survey. Mach. Learn. Knowl. Extr. 2023, 5, 891–921. [Google Scholar] [CrossRef]
- Warmiński, G.; Sadowski, K.A.; Kalinczuk, L.; Orczykowski, M.; Urbanek, P.; Bodalski, R.; Hasiec, A.; Gandor, M.; Pałka, F.; Sajnok, K.; et al. Artificial intelligence analysis of ECG signals to predict arrhythmia recurrence after ablation of atrial fibrillation. Pol. Heart J. 2025, 83, 496–498. [Google Scholar] [CrossRef]
- Ranjan, R.; Sahana, B.C.; Bhandari, A.K. Deep Learning Models for Diagnosis of Schizophrenia Using EEG Signals: Emerging Trends, Challenges, and Prospects. Arch. Comput. Methods Eng. 2024, 31, 2345–2384. [Google Scholar] [CrossRef]
- Woźniacki, A.; Książek, W.; Mrowczyk, P. A Novel Approach for Predicting the Survival of Colorectal Cancer Patients Using Machine Learning Techniques and Advanced Parameter Optimization Methods. Cancers 2024, 16, 3205. [Google Scholar] [CrossRef]
- Maçin, G.; Genç, F.; Taşcı, B.; Dogan, S.; Tuncer, T. KidneyNeXt: A Lightweight Convolutional Neural Network for Multi-Class Renal Tumor Classification in Computed Tomography Imaging. J. Clin. Med. 2025, 14, 4929. [Google Scholar] [CrossRef]
- Thakur, S.; Goplani, Y.; Arora, S.; Upadhyay, R.; Sharma, G. Chest X-ray Images Based Automated Detection of Pneumonia Using Transfer Learning and CNN. In Proceedings of the International Conference on Artificial Intelligence and Applications, Xiamen, China, 8–11 May 2020; Springer: Singapore, 2020; pp. 329–335. [Google Scholar] [CrossRef]
- Jain, R.; Nagrath, P.; Kataria, G.; Sirish Kaushik, V.; Jude Hemanth, D. Pneumonia detection in chest X-ray images using convolutional neural networks and transfer learning. Measurement 2020, 165, 108046. [Google Scholar] [CrossRef]
- Sirazitdinov, I.; Kholiavchenko, M.; Mustafaev, T.; Yixuan, Y.; Kuleev, R.; Ibragimov, B. Deep neural network ensemble for pneumonia localization from a large-scale chest x-ray database. Comput. Electr. Eng. 2019, 78, 388–399. [Google Scholar] [CrossRef]
- Mabrouk, A.; Díaz Redondo, R.P.; Dahou, A.; Abd Elaziz, M.; Kayed, M. Pneumonia Detection on Chest X-ray Images Using Ensemble of Deep Convolutional Neural Networks. Appl. Sci. 2022, 12, 6448. [Google Scholar] [CrossRef]
- Wang, K.; Jiang, P.; Meng, J.; Jiang, X. Attention-Based DenseNet for Pneumonia Classification. IRBM 2022, 43, 479–485. [Google Scholar] [CrossRef]
- Hedhoud, Y.; Mekhaznia, T.; Amroune, M. An improvement of the CNN-XGboost model for pneumonia disease classification. Pol. J. Radiol. 2023, 88, 483–493. [Google Scholar] [CrossRef]
- El Houby, E.M.F. COVID-19 detection from chest X-ray images using transfer learning. Sci. Rep. 2024, 14, 11639. [Google Scholar] [CrossRef] [PubMed]
- Showkatian, E.; Salehi, M.; Ghaffari, H.; Reiazi, R.; Sadighi, N. Deep learning-based automatic detection of tuberculosis disease in chest X-ray images. Pol. J. Radiol. 2022, 87, 118–124. [Google Scholar] [CrossRef]
- Ait Nasser, A.; Akhloufi, M.A. A Review of Recent Advances in Deep Learning Models for Chest Disease Detection Using Radiography. Diagnostics 2023, 13, 159. [Google Scholar] [CrossRef]
- Kermany, D.S.; Goldbaum, M.; Mooney, P.T. Chest X-Ray Images (Pneumonia). 2018. Available online: https://www.kaggle.com/datasets/paultimothymooney/chest-xray-pneumonia (accessed on 3 September 2025).
- Hayati, M.; Muchtar, K.; Roslidar; Maulina, N.; Syamsuddin, I.; Elwirehardja, G.N.; Pardamean, B. Impact of CLAHE-based image enhancement for diabetic retinopathy classification through deep learning. Procedia Comput. Sci. 2023, 216, 57–66. [Google Scholar] [CrossRef]
- Sabour, S.; Frosst, N.; Hinton, G.E. Dynamic Routing Between Capsules. arXiv 2017, arXiv:1710.09829. [Google Scholar] [CrossRef]
- Kwabena Patrick, M.; Felix Adekoya, A.; Abra Mighty, A.; Edward, B.Y. Capsule Networks—A survey. J. King Saud Univ.-Comput. Inf. Sci. 2022, 34, 1295–1310. [Google Scholar] [CrossRef]
- LaLonde, R.; Xu, Z.; Irmakci, I.; Jain, S.; Bagci, U. Capsules for biomedical image segmentation. Med. Image Anal. 2021, 68, 101889. [Google Scholar] [CrossRef] [PubMed]
- Srinivasan, M.N.; Sikkandar, M.Y.; Alhashim, M.; Chinnadurai, M. Capsule network approach for monkeypox (CAPSMON) detection and subclassification in medical imaging system. Sci. Rep. 2025, 15, 3296. [Google Scholar] [CrossRef]
- Avesta, A.; Hui, Y.; Aboian, M.; Duncan, J.; Krumholz, H.; Aneja, S. 3D Capsule Networks for Brain Image Segmentation. Am. J. Neuroradiol. 2023, 44, 562–568. [Google Scholar] [CrossRef]
- Quan, H.; Xu, X.; Zheng, T.; Li, Z.; Zhao, M.; Cui, X. DenseCapsNet: Detection of COVID-19 from X-ray images using a capsule neural network. Comput. Biol. Med. 2021, 133, 104399. [Google Scholar] [CrossRef]
- Akiba, T.; Sano, S.; Yanase, T.; Ohta, T.; Koyama, M. Optuna: A Next-generation Hyperparameter Optimization Framework. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, ACM, 2019, KDD’19, Anchorage, AK, USA,, 4–8 August 2019; pp. 2623–2631. [Google Scholar] [CrossRef]
- Arikan, F.B.; Cetintas, D.; Aksoy, A.; Yildirim, M. A Deep Learning Approach to Alzheimer’s Diagnosis Using EEG Data: Dual-Attention and Optuna-Optimized SVM. Biomedicines 2025, 13, 2017. [Google Scholar] [CrossRef]
- Lai, L.H.; Lin, Y.L.; Liu, Y.H.; Lai, J.P.; Yang, W.C.; Hou, H.P.; Pai, P.F. The Use of Machine Learning Models with Optuna in Disease Prediction. Electronics 2024, 13, 4775. [Google Scholar] [CrossRef]
- Harris, C.R.; Millman, K.J.; van der Walt, S.J.; Gommers, R.; Virtanen, P.; Cournapeau, D.; Wieser, E.; Taylor, J.; Berg, S.; Smith, N.J.; et al. Array programming with NumPy. Nature 2020, 585, 357–362. [Google Scholar] [CrossRef]
- Bradski, G. The OpenCV Library. Dr. Dobb’s J. Softw. Tools 2000, 25, 120–123. [Google Scholar]
- Abadi, M.; Agarwal, A.; Barham, P.; Brevdo, E.; Chen, Z.; Citro, C.; Corrado, G.S.; Davis, A.; Dean, J.; Devin, M.; et al. TensorFlow: Large-Scale Machine Learning on Heterogeneous Systems. 2015. Available online: https://www.tensorflow.org/ (accessed on 1 September 2025).
- Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Prettenhofer, P.; Weiss, R.; Dubourg, V.; et al. Scikit-learn: Machine Learning in Python. J. Mach. Learn. Res. 2011, 12, 2825–2830. [Google Scholar]
- Hunter, J.D. Matplotlib: A 2D graphics environment. Comput. Sci. Eng. 2007, 9, 90–95. [Google Scholar] [CrossRef]
- Anaconda Software Distribution. 2020. Available online: https://www.anaconda.com (accessed on 10 October 2025).
- Hildt, E. What Is the Role of Explainability in Medical Artificial Intelligence? A Case-Based Approach. Bioengineering 2025, 12, 375. [Google Scholar] [CrossRef]
- Ponce-Bobadilla, A.V.; Schmitt, V.; Maier, C.S.; Mensing, S.; Stodtmann, S. Practical guide to SHAP analysis: Explaining supervised machine learning model predictions in drug development. Clin. Transl. Sci. 2024, 17, e70056. [Google Scholar] [CrossRef] [PubMed]
- Hassan, S.U.; Abdulkadir, S.J.; Zahid, M.S.M.; Al-Selwi, S.M. Local interpretable model-agnostic explanation approach for medical imaging analysis: A systematic literature review. Comput. Biol. Med. 2025, 185, 109569. [Google Scholar] [CrossRef] [PubMed]
- Fu, Q.; Wu, Y.; Zhu, M.; Xia, Y.; Yu, Q.; Liu, Z.; Ma, X.; Yang, R. Identifying cardiovascular disease risk in the U.S. population using environmental volatile organic compounds exposure: A machine learning predictive model based on the SHAP methodology. Ecotoxicol. Environ. Saf. 2024, 286, 117210. [Google Scholar] [CrossRef] [PubMed]
- Selvaraju, R.R.; Cogswell, M.; Das, A.; Vedantam, R.; Parikh, D.; Batra, D. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. In Proceedings of the 2017 IEEE International Conference on Computer Vision (ICCV), Venice, Italy, 22–29 October 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 618–626. [Google Scholar] [CrossRef]
- Rajpurkar, P.; Irvin, J.; Ball, R.L.; Zhu, K.; Yang, B.; Mehta, H.; Duan, T.; Ding, D.; Bagul, A.; Langlotz, C.P.; et al. Deep Learning for Chest Radiograph Diagnosis: A Retrospective Comparison of the CheXNeXt Algorithm to Practicing Radiologists. Plos Med. 2018, 15, e1002686. [Google Scholar] [CrossRef]
- Afshar, P.; Heidarian, S.; Naderkhani, F.; Oikonomou, A.; Plataniotis, K.N.; Mohammadi, A. COVID-CAPS: A Capsule Network-Based Framework for Identification of COVID-19 Cases from X-ray Images. Pattern Recognit. Lett. 2020, 138, 638–643. [Google Scholar] [CrossRef]
- Roy, A.; Bhattacharjee, A.; Oliva, D.; Ramos-Soto, O.; Alvarez-Padilla, F.J.; Sarkar, R. FA-Net: A Fuzzy Attention-Aided Deep Neural Network for Pneumonia Detection in Chest X-Rays. arXiv 2024. [Google Scholar] [CrossRef]
Hyperparameter | Search Space |
---|---|
lr | from to (log scale) |
n_filters | |
drop_rate | from to (continuous) |
cap_dim | |
batch_size |
Layer (Type) | Output Shape | Param # |
---|---|---|
Input_10 (InputLayer) | (None, 224, 224, 3) | 0 |
Conv2D_18 (Conv2D) | (None, 224, 224, 64) | 1792 |
MaxPooling2D_9 (MaxPooling2D) | (None, 112, 112, 64) | 0 |
PrimaryCaps_9 (PrimaryCaps) | (None, 100, 352, 8) | 147,712 |
DigitCaps_9 (DigitCaps) | (None, 2, 16) | 25,690,112 |
Lambda_9 (Lambda) | (None, 2) | 0 |
Total params: | 25,839,616 (98.57 MB) | |
Trainable params: | 25,839,616 (98.57 MB) | |
Nontrainable params: | 0 (0.00 Byte) |
Metric | Value |
---|---|
Accuracy | 0.951136 |
Sensitivity (Recall) | 0.987539 |
Specificity | 0.852941 |
Precision (PPV) | 0.947683 |
Negative Predictive Value (NPV) | 0.962085 |
False Positive Rate (FPR) | 0.147059 |
False Negative Rate (FNR) | 0.012461 |
F1 Score | 0.967201 |
Matthews Correlation Coefficient (MCC) | 0.874438 |
ROC AUC | 0.955797 |
PR AUC | 0.981815 |
Works | Methods | Accuracy | F1-Score | Recall |
---|---|---|---|---|
[22] | VGG16 | 90.54 | 92.9 | 98.7 |
[23] | VGG16 | 87.18 | 90 | 96 |
VGG19 | 88.46 | 91 | 95 | |
ResNet50 | 77.56 | 84 | 97 | |
Inception-v3 | 70.99 | 78 | 84 | |
[8] | CNN (51 layers) | 90.5 | 92.7 | 96.7 |
[24] | RetinaNet with Mask RCNN | - | 77.5 | 79.3 |
[25] | EL | 93.91 | 93.43 | 92.99 |
[9] | Ensemble CNN | 84.12 | 88.56 | 99.23 |
[26] | Attention-Based DenseNet | 92.8 | 94.3 | 96.2 |
[27] | CNN-XGboost | 87 | 87 | 85 |
Our model | CapsNet+ Baysian Optimization | 95 | 96.8 | 98.9 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Salamon, S.; Książek, W. Capsule Neural Networks with Bayesian Optimization for Pediatric Pneumonia Detection from Chest X-Ray Images. J. Clin. Med. 2025, 14, 7212. https://doi.org/10.3390/jcm14207212
Salamon S, Książek W. Capsule Neural Networks with Bayesian Optimization for Pediatric Pneumonia Detection from Chest X-Ray Images. Journal of Clinical Medicine. 2025; 14(20):7212. https://doi.org/10.3390/jcm14207212
Chicago/Turabian StyleSalamon, Szymon, and Wojciech Książek. 2025. "Capsule Neural Networks with Bayesian Optimization for Pediatric Pneumonia Detection from Chest X-Ray Images" Journal of Clinical Medicine 14, no. 20: 7212. https://doi.org/10.3390/jcm14207212
APA StyleSalamon, S., & Książek, W. (2025). Capsule Neural Networks with Bayesian Optimization for Pediatric Pneumonia Detection from Chest X-Ray Images. Journal of Clinical Medicine, 14(20), 7212. https://doi.org/10.3390/jcm14207212