Multi-Source Transfer Weighted Learning with Random Forest for Cross-Project Software Defect Prediction
Abstract
Accurate software defect prediction is essential for identifying fault-prone modules early and reducing software testing and maintenance costs. However, Within-Project Defect Prediction (WPDP) models may perform poorly when the target project has limited labeled defect data. Cross-Project Defect Prediction (CPDP) addresses this limitation by transferring knowledge from other projects, but heterogeneous feature distributions, source–target mismatch, and negative transfer remain significant challenges. This study proposes a Multi-Source Transfer Weighted Learning with Random Forest (MS-TWL+RF) framework for software defect prediction across heterogeneous projects. The proposed framework combines transferability estimation at the dataset, feature, and instance levels. Linear Maximum Mean Discrepancy (MMD) assigns weights to source projects based on their distributional similarity to the target project. In contrast, feature weights jointly consider distribution similarity and mutual information-based predictive relevance. A domain classifier is used to assign instance-level weights according to their representativeness of the target domain. Correlation Alignment (CORAL) subsequently reduces covariance discrepancies between the source and target feature spaces before classification using a weighted Random Forest model. The proposed framework is evaluated on the JM1, KC1, CM1, KC2, and PC1 projects and compared with AlexNet+RF, ResNet50+RF, TransTab+RF, and XTab+RF. For the JM1 target project, the proposed method achieves 98.7% target-domain accuracy, 98.9% precision, 98.7% recall, and 98.8% F1-score, with an AUC of 0.992. It also obtains Kappa, MCC, and Jaccard scores of 0.980, 0.981, and 0.990, respectively. The results indicate that combining multi-level transfer weighting with covariance alignment can help address the effects of heterogeneous source projects in cross-project software defect prediction.