Comparative Analysis of Random Forest and Convolutional Neural Network (CNN) Algorithms for Pneumonia Detection in Chest X-ray Images: Accuracy, Interpretability, and Computational Efficiency


  • Siffa Zaena Telkom University, Bandung, Indonesia
  • Kemas Muslim Lhaksmana * Mail Telkom University, Bandung, Indonesia
  • (*) Corresponding Author
Keywords: Convolutional Neural Network; Pneumonia; Image Classification; Random Forest; X-ray

Abstract

Pneumonia is a lung infection that can be detected through chest X-ray images. Manual diagnosis requires radiological expertise and time, thus an accurate automated method is needed. This study aims to compare the performance of two image classification algorithms, Convolutional Neural Network (CNN) and Random Forest (RF), in detecting pneumonia. The dataset used was obtained from Kaggle, consisting of 5,863 X-ray images categorized into three classes: bacterial pneumonia, viral pneumonia, and normal. Preprocessing steps include image resizing, normalization, and data augmentation. The CNN model was built using multiple convolutional and pooling layers, while RF utilized numerical features derived from histograms and texture. The CNN model demonstrated superior performance, achieving 92.4% accuracy, 93.1% precision, 91.6% recall, and 92.3% F1-score, compared to 82.7%, 80.3%, 85.1%, and 82.6% for Random Forest, respectively. Although CNN offers better accuracy, RF excels in interpretability. In conclusion, CNN is more effective for image-based pneumonia classification, yet RF remains relevant in applications requiring transparent decision-making. Potential biases, such as class imbalance and limited demographic representation in the dataset, could influence model performance and generalizability across different patient populations.

Downloads

Download data is not yet available.

References

World Health Organization, “Pneumonia in children.,” World Health Organization. Accessed: May 12, 2025. [Online]. Available: https://www.who.int/news-room/fact-sheets/detail/pneumonia

“Laporan Nasional Riskesdas 2018,” 2019.

P. Rajpurkar et al., “CheXNet: Radiologist-Level Pneumonia Detection on Chest X-Rays with Deep Learning,” Dec. 2017.

A. Esteva et al., “Dermatologist-level classification of skin cancer with deep neural networks,” Nature, vol. 542, no. 7639, pp. 115–118, Feb. 2017, doi: 10.1038/nature21056.

L. Breiman, Random Forests. 2001.

I. Md. D. Maysanjaya, “Klasifikasi Pneumonia pada Citra X-rays Paru-paru dengan Convolutional Neural Network,” Jurnal Nasional Teknik Elektro dan Teknologi Informasi, vol. 9, no. 2, pp. 190–195, May 2020, doi: 10.22146/jnteti.v9i2.66.

W. Liu, J. Zhang, and Y. Zhao, “A Comparison of Deep Learning and Traditional Machine Learning Approaches in Detecting Cognitive Impairment Using MRI Scans,” in 2022 IEEE 46th Annual Computers, Software, and Applications Conference (COMPSAC), 2022, pp. 998–1001. doi: 10.1109/COMPSAC54236.2022.00154.

N. Munnurukapu, R. Dillikar, B. Munnuru, and S. Naaz, “Predicting Pneumonia with Precision: A Deep Learning Approach,” Journal of Innovations in Data Science and Big Data Management, vol. 4, no. 1, pp. 10–25, Jul. 2025, doi: 10.46610/JIDSBDM.2025.v04i01.002.

S. L. Oh et al., “Classification of heart sound signals using a novel deep WaveNet model,” Comput Methods Programs Biomed, vol. 196, p. 105604, Nov. 2020, doi: 10.1016/j.cmpb.2020.105604.

J. G. Malaran and N. C. Pañares, “Multiple Intelligences Among Senior High School and Their Academic Performance,” INTERNATIONAL JOURNAL OF MULTIDISCIPLINARY RESEARCH AND ANALYSIS, vol. 08, no. 05, May 2025, doi: 10.47191/ijmra/v8-i05-03.

M. E. H. Chowdhury et al., “Can AI Help in Screening Viral and COVID-19 Pneumonia?,” IEEE Access, vol. 8, pp. 132665–132676, 2020, doi: 10.1109/ACCESS.2020.3010287.

M. T. Ribeiro, S. Singh, and C. Guestrin, “‘Why Should I Trust You?’: Explaining the Predictions of Any Classifier,” Aug. 2016.

D. S. Kermany et al., “Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning,” Cell, vol. 172, no. 5, pp. 1122-1131.e9, Feb. 2018, doi: 10.1016/j.cell.2018.02.010.

R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra, “Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization,” Int J Comput Vis, vol. 128, no. 4, pp. 336–359, Dec. 2019, doi: 10.1007/s11263-019-01228-7.

J. Irvin et al., “CheXpert: A Large Chest Radiograph Dataset with Uncertainty Labels and Expert Comparison,” Proceedings of the AAAI Conference on Artificial Intelligence, vol. 33, no. 01, pp. 590–597, Jul. 2019, doi: 10.1609/aaai.v33i01.3301590.

E. Bisong, Building Machine Learning and Deep Learning Models on Google Cloud Platform. Berkeley, CA: Apress, 2019. doi: 10.1007/978-1-4842-4470-8.

Y. S. Nugroho and P. I. Santosa, “Penerapan Algoritma Random Forest pada Klasifikasi Citra X-ray Pneumonia,” Jurnal Teknologi Informasi dan Ilmu Komputer, vol. 7, no. 3, pp. 213–220, 2020.

A. Esteva et al., “A guide to deep learning in healthcare,” Nat Med, vol. 25, no. 1, pp. 24–29, Jan. 2019, doi: 10.1038/s41591-018-0316-z.

M. Toğaçar, B. Ergen, and Z. Cömert, “COVID-19 detection using deep learning models to exploit Social Mimic Optimization and structured chest X-ray images using fuzzy color and stacking approaches,” Comput Biol Med, vol. 121, p. 103805, Jun. 2020, doi: 10.1016/j.compbiomed.2020.103805.

M. Luqman, S. M. Anwar, and M. Rehman, “A Hybrid Approach Using CNN and Random Forest for Pneumonia Detection from Chest X-ray Images,” J Digit Imaging, vol. 35, pp. 505–514, 2022.


Bila bermanfaat silahkan share artikel ini

Berikan Komentar Anda terhadap artikel Comparative Analysis of Random Forest and Convolutional Neural Network (CNN) Algorithms for Pneumonia Detection in Chest X-ray Images: Accuracy, Interpretability, and Computational Efficiency

Dimensions Badge
Article History
Submitted: 2025-07-01
Published: 2025-09-02
Abstract View: 623 times
PDF Download: 311 times
How to Cite
Zaena, S., & Lhaksmana, K. (2025). Comparative Analysis of Random Forest and Convolutional Neural Network (CNN) Algorithms for Pneumonia Detection in Chest X-ray Images: Accuracy, Interpretability, and Computational Efficiency. Building of Informatics, Technology and Science (BITS), 7(2), 1069-1077. https://doi.org/10.47065/bits.v7i2.7840
Section
Articles