Abstract
Background: Software Defect Prediction (SDP) is a pivotal quality assurance activity that identifies faultprone modules prior to testing, optimizing resource allocation and reducing maintenance costs. Despite substantial advances, existing methods suffer from three fundamental limitations: severe class imbalance in defect datasets, inadequate joint exploitation of temporal and contextual feature dependencies, and suboptimal generalization across heterogeneous software projects.Objective: This study aims to develop a novel four-phase framework, Proposed-Transformer, that synergistically addresses class imbalance, feature dependency exploitation, and cross-project generalization challenges in software defect prediction.Methods: The proposed framework integrates four core components: an Adaptive Feature Selection module (AFS-SHAP) for dimensionality reduction, a Defect-Conditional Wasserstein GAN (DC-GAN) for minority class augmentation, a Bidirectional LSTM encoder for capturing temporal patterns, and a Multi-head Self-Attention Transformer for modelling global contextual dependencies, culminating in a stacked ensemble meta-learner. The framework was evaluated on five NASA PROMISE benchmark datasets, namely CM1, JM1, KC1, PC1, and MC2. Performance was assessed using F1-Score, AUC-ROC, and Matthews Correlation Coefficient (MCC), and compared against multiple state-of-the-art competing methods. Ablation studies and hyperparameter analyses were also conducted to examine the individual and synergistic contribution of each component.Results: Experimental results demonstrate that the proposed framework achieves a mean F1-Score of 0.918, AUC-ROC of 0.967, and MCC of 0.877 across all benchmark datasets, outperforming the best competing method by statistically significant margins. Ablation studies and visualizations further confirm that each component contributes meaningfully to the overall performance, with synergistic gains observed when all modules are integrated.Conclusion: The proposed transformer framework effectively addresses the key limitations of existing software defect prediction methods by combining adaptive feature selection, generative data augmentation, sequential modelling, and attention-based context learning within a unified ensemble architecture. The results demonstrate superior and consistent predictive performance, offering a robust and practical solution for enhancing software quality assurance across diverse software projects.

This publication has 8 references indexed in Scilit: