Imbalanced data learning in defect prediction: a weighted loss function approach for neural networks
摘要
Software defect prediction (SDP) aims to identify software components that are susceptible to defects at an early stage in the development process, facilitating thorough testing and the timely delivery of reliable software within budget constraints. Neural network based techniques have gained popularity for building prediction models due to advancements in computing power and storage. However, the presence of imbalanced data poses a common challenge in machine learning classification, affecting the performance of SDP models. This study proposes a Weighted Loss Function for Neural Networks (WL-NN) as a solution to tackle the problem of imbalanced data in the software defect datasets. Four types of defect prediction models were constructed: NN over imbalanced data, WL-NN over imbalanced data, NN over balanced data and WL-NN over balanced data. Experiments were conducted twenty-two open source data sets from AEEEM, JIRA and PROMISE repositories. The results demonstrate that the proposed Weighted Loss Function for Neural Networks improves the performance of SDP models. This function when combined with data resampling technique outperformed the other approaches, achieving the highest predictive performance. Based on the findings of this study, we strongly recommend the adoption of the weighted loss function for artificial neural networks to effectively handle the challenge of data imbalance in software defect prediction. Furthermore, we provide insights into potential future research directions to advance the field. The proposed approach is particularly relevant for modern software development scenarios including safety-critical domains (e.g., healthcare, automotive, finance), cloud-native and microservices-based architectures, and large-scale AI-driven systems. Given the increasing prevalence of LLM-based applications and distributed infrastructures in 2025 and beyond, this approach ensures that defect-prone components are effectively identified despite class imbalance, thereby enhancing software reliability in emerging technological ecosystems.