A Comparative Hybrid Approach for Python Bug Detection Using Syntactic Features, Random Forest, and Neural Network

Authors

  • Bahtiar Imran Universitas Teknologi Mataram
  • Erfan Wahyudi Institut Pemerintahan Dalam Negeri (IPDN)
  • Selamet Riadi Universitas Teknologi Mataram
  • Zumratul Muahidin Universitas Teknologi Mataram
  • Surni Erniwati Universitas Teknologi Mataram
  • Wenty Ayu Wahyuni Universitas Teknologi Mataram

DOI:

https://doi.org/10.21512/commit.v19i2.13183

Keywords:

Bug Detection, Syntactic Features, Random Forest, Neural Network

Abstract

As software systems become increasingly complex, detecting bugs in source code has become a critical challenge in software development and maintenance. Manual debugging is time-consuming and errorprone, prompting the need for automated bug detection solutions. The research explores the use of machine learning models, specifically, Random Forest and Neural Network, for identifying bugs in Python source code. Features are extracted using Abstract Syntax Trees (ASTs), which enable the structured parsing of syntactic elements such as functions, classes, variables, conditionals, and exception blocks. These features serve as input to train both models for binary classification: distinguishing between buggy and non-buggy code files. Both buggy and non-buggy code files have 200 Python scripts. The models are evaluated using accuracy, confusion matrices, Receiver Operating Characteristic (ROC) curves, and classification reports across multiple training epochs. Experimental results show that the Random Forest model achieves stable performance with an accuracy of 86.67% and an Area Under the Curve (AUC) score of 0.97 on the test set, without significant improvement across epochs. In contrast, the Neural Network demonstrates gradual accuracy improvement from 68.33% at epoch 5 to 85% at epoch 300, along with higher sensitivity in bug detection, although it requires longer training times. Additionally, both models are used to predict specific lines of code containing potential bugs. Based on these findings, the choice of model depends on the application context. Random Forest offers faster deployment and consistent performance, while Neural Networks provide better adaptability to complex patterns and improved accuracy with sufficient training.

Dimensions

Plum Analytics

Author Biographies

Bahtiar Imran, Universitas Teknologi Mataram

Computer Systems Engineering, Faculty of Information and Communication Technology

Erfan Wahyudi, Institut Pemerintahan Dalam Negeri (IPDN)

Public Safety and Security Management, Faculty of Community Protection

Selamet Riadi, Universitas Teknologi Mataram

Computer Systems Engineering, Faculty of Information and Communication Technology

Zumratul Muahidin, Universitas Teknologi Mataram

Information Systems, Faculty of Information and Communication Technology

Surni Erniwati, Universitas Teknologi Mataram

Information Management, Faculty of Vocational Studies

Wenty Ayu Wahyuni, Universitas Teknologi Mataram

Department of Informatics Engineering, Faculty of Information and Communication Technology

References

[1] S. Mostafa, S. T. Cynthia, B. Roy, and D. Mondal, “Feature transformation for improved software bug detection and commit classification,” Journal of Systems and Software, vol. 219, pp. 1–13, 2025.

[2] G. Giray, K. E. Bennin, O¨ . Ko¨ksal, O¨ . Babur, and B. Tekinerdogan, “On the use of deep learning in software defect prediction,” The Journal of Systems & Software, vol. 195, pp. 1–26, 2023.

[3] J. A. Fadhil, K. T. Wei, and K. S. Na, “Artificial intelligence for software engineering: An initial review on software bug detection and prediction,” Journal of Computer Science, vol. 16, no. 12, pp. 1709–1717, 2020.

[4] K. Krishna, P. Murthy, and S. Sarangi, “Exploring the synergy between generative AI and software engineering: Automating code optimization and bug fixing,” vol. 13, no. 1, pp. 682–691, 2024.

[5] M. Nevendra and P. Singh, “Software defect prediction using deep learning,” Acta Polytechnica Hungarica, vol. 18, no. 10, pp. 173–189, 2021.

[6] A. Khalid, G. Badshah, N. Ayub, M. Shiraz, and M. Ghouse, “Software defect prediction analysis using machine learning techniques,” Sustainability, vol. 15, no. 6, pp. 1–17, 2023.

[7] A. Hammouri, M. Hammad, M. Alnabhan, and F. Alsarayrah, “Software bug prediction using machine learning approach,” International Journal of Advanced Computer Science and Applications, vol. 9, no. 2, pp. 78–83, 2018.

[8] T. Hai, J. Zhou, N. Li, S. K. Jain, S. Agrawal, and I. B. Dhaou, “Cloud-based bug tracking software defects analysis using deep learning,” Journal of Cloud Computing, vol. 11, no. 1, pp. 1–14, 2022.

[9] N. Tabassum, A. Namoun, T. Alyas, A. Tufail, M. Taqi, and K. H. Kim, “Classification of bugs in cloud computing applications using machine learning techniques,” Applied Sciences, vol. 13, no. 5, pp. 1–24, 2023.

[10] S. D. Immaculate, M. F. Begam, and M. Floramary, “Software bug prediction using supervised machine learning algorithms,” in 2019 International conference on data science and communication (IconDSC). Bangalore, India: IEEE, March 1–2, 2019, pp. 1–7.

[11] W. Albattah and M. Alzahrani, “Software defect prediction based on machine learning and deep learning techniques: An empirical approach,” AI, vol. 5, no. 4, pp. 1743–1758, 2024.

[12] H. M. Tran, S. T. Le, S. V. Nguyen, and P. T. Ho, “An analysis of software bug reports using machine learning techniques,” SN Computer Science, vol. 1, 2020.

[13] R. Siva, S. Kaliraj, B. Hariharan, and N. Premkumar, “Automatic software bug prediction using adaptive artificial jelly optimization with Long Short-Term Memory,” Wireless Personal Communications, vol. 132, no. 3, pp. 1975–1998, 2023.

[14] Q. M. Ul Haq, F. Arif, K. Aurangzeb, N. Ul Ain, J. A. Khan, S. Rubab, and M. S. Anwar, “Identification of software bugs by analyzing natural language-based requirements using optimized deep learning features,” Computers, Materials & Continua, vol. 78, no. 3, pp. 4379–4397, 2024.

[15] S. T. Cynthia, B. Roy, and D. Mondal, “Feature transformation for improved software bug detection models,” in Proceedings of the 15th Innovations in Software Engineering Conference. Gandhinagar, India: Association for Computing Machinery, Feb. 24–26, 2022, pp. 1–10.

[16] H. Bani-Salameh, M. Sallam, and B. Al Shboul, “A deep-learning-based bug priority prediction using RNN-LSTM neural networks,” EInformatica Software Engineering Journal, vol. 15, no. 1, pp. 29–45, 2021.

[17] S. A. Alsaedi, A. Y. Noaman, A. A. A. Gad-Elrab, and F. E. Eassa, “Nature-based prediction model of bug reports based on ensemble machine learning model,” IEEE Access, vol. 11, pp. 63 916–63 931, 2023.

[18] A. T. P. Nguyen and V. D. Hoang, “Development of code evaluation system based on abstract syntax tree,” Journal of Technical Education Science, vol. 19, no. Special Issue 01, pp. 15–24, 2024.

[19] P. Batchu, T. R. Gali, and S. Inturi, “Python source code analysis for bug detection using transformers,” Engineering Technology Journal, vol. 09, no. 04, pp. 3772–3777, 2024.

[20] G. Giray, “A software engineering perspective on engineering machine learning systems: State of the art and challenges,” Journal of Systems and Software, vol. 180, 2021.

[21] A. Kukkar, R. Mohana, Y. Kumar, A. Nayyar, M. Bilal, and K. S. Kwak, “Duplicate bug report detection and classification system based on deep learning technique,” IEEE Access, vol. 8, pp. 200 749–200 763, 2020.

[22] L. Gomes, R. da Silva Torres, and M. L. Cˆortes, “BERT-and TF-IDF-based feature extraction for long-lived bug prediction in FLOSS: A comparative study,” Information and Software Technology, vol. 160, 2023.

[23] M. Allamanis, H. Jackson-Flux, and M. Brockschmidt, “Self-supervised bug detection and repair,” Advances in Neural Information Processing Systems, vol. 34, pp. 27 865–27 876, 2021.

[24] F. Jafarinejad, K. Narasimhan, and M. Mezini, “Nerdbug: Automated bug detection in Neural Networks,” in Proceedings of the 1st ACM International Workshop on AI and Software Testing/Analysis. Virtual, Denmark: Association for Computing Machinery, July 12, 2021, pp. 13–16.

[25] R. Manke, M. Wardat, F. Khomh, and H. Rajan, “Leveraging data characteristics for bug localization in deep learning programs,” ACM Transactions on Software Engineering and Methodology, vol. 34, no. 6, pp. 1–29, 2025.

[26] I. Yegorov, E. Kobrin, D. Parygina, A. Vishnyakov, and A. Fedotov, “Python fuzzing for trustworthy machine learning frameworks,” Journal of Mathematical Sciences, vol. 285, no. 2, pp. 180–188, 2024.

Downloads

Published

2025-09-04

How to Cite

[1]
B. Imran, E. Wahyudi, S. Riadi, Z. Muahidin, S. Erniwati, and W. A. Wahyuni, “A Comparative Hybrid Approach for Python Bug Detection Using Syntactic Features, Random Forest, and Neural Network”, CommIT (Communication and Information Technology) Journal, vol. 19, no. 2, Sep. 2025.
Abstract 108  .
PDF downloaded 63  .