Improving accuracy of code smells detection using machine learning with data balancing techniques
Open Access
- 5 June 2024
- journal article
- research article
- Published by Springer Nature in The Journal of Supercomputing
- Vol. 80 (14) , 21048-21093
Abstract
Code smells indicate potential symptoms or problems in software due to inefficient design or incomplete implementation. These problems can affect software quality in the long-term. Code smell detection is fundamental to improving software quality and maintainability, reducing software failure risk, and helping to refactor the code. Previous works have applied several prediction methods for code smell detection. However, many of them show that machine learning (ML) and deep learning (DL) techniques are not always suitable for code smell detection due to the problem of imbalanced data. So, data imbalance is the main challenge for ML and DL techniques in detecting code smells. To overcome these challenges, this study aims to present a method for detecting code smell based on DL algorithms (Bidirectional Long Short-Term Memory (Bi-LSTM) and Gated Recurrent Unit (GRU)) combined with data balancing techniques (random oversampling and Tomek links) to mitigate data imbalance issue. To establish the effectiveness of the proposed models, the experiments were conducted on four code smells datasets (God class, data Class, feature envy, and long method) extracted from 74 open-source systems. We compare and evaluate the performance of the models according to seven different performance measures accuracy, precision, recall, f-measure, Matthew’s correlation coefficient (MCC), the area under a receiver operating characteristic curve (AUC), the area under the precision–recall curve (AUCPR) and mean square error (MSE). After comparing the results obtained by the proposed models on the original and balanced data sets, we found out that the best accuracy of 98% was obtained for the Long method by using both models (Bi-LSTM and GRU) on the original datasets, the best accuracy of 100% was obtained for the long method by using both models (Bi-LSTM and GRU) on the balanced datasets (using random oversampling), and the best accuracy 99% was obtained for the long method by using Bi-LSTM model and 99% was obtained for the data class and Feature envy by using GRU model on the balanced datasets (using Tomek links). The results indicate that the use of data balancing techniques had a positive effect on the predictive accuracy of the models presented. The results show that the proposed models can detect the code smells more accurately and effectively.Keywords
Funding Information
- University of Miskolc
This publication has 36 references indexed in Scilit:
- Machine learning-based test smell detectionEmpirical Software Engineering, 2024
- On the relative value of imbalanced learning for code smell detectionSoftware: Practice and Experience, 2023
- A comparison of machine learning algorithms on design smell detection using balanced and imbalanced dataset: A study of God classInformation and Software Technology, 2022
- Financial Decisions in Colombian Organisations in the Health Sector2022
- Reusability affecting factors and software metrics for reusability: A systematic literature reviewSoftware: Practice and Experience, 2021
- Rank-based univariate feature selection methods on machine learning classifiers for code smell detectionEvolutionary Intelligence, 2021
- Predicting Code Smells and Analysis of Predictions: Using Machine Learning Techniques and Software MetricsJournal of Computer Science and Technology, 2020
- Using software metrics for predicting vulnerable classes and methods in Java projects: A machine learning approachJournal of Software: Evolution and Process, 2020
- Code smell detection using multi-label classification approachSoftware Quality Journal, 2020
- Comparing and experimenting machine learning techniques for code smell detectionEmpirical Software Engineering, 2015