Software Defect Prediction (SDP) suffers from severe class imbalance, as defective samples typically account for less than 20% of the data, which often leads to biased model training and degraded prediction performance. Undersampling has been widely used to address class imbalance and improve prediction performance. However, existing undersampling methods may alter the original data distribution by removing majority-class samples, potentially displacing the learned decision boundary in real-world SDP scenarios. Therefore, this paper proposes a risk-aware undersampling method for Software Defect Prediction (RASU), which aims to alleviate class imbalance while reducing discrepancies between the retained and original majority-class distributions. The proposed method quantifies feature importance using SHAP values, incorporates defect distribution patterns to calculate a risk score for each majority-class sample, and performs proportional random sampling within decile-based risk strata. Experiments on 19 public datasets evaluate the proposed method. The results show that RASU achieves the highest average F1-score, MCC, and AUC under the decision-tree classifier and remains competitive under SVM and Random Forest. Ablation and controlled synthetic experiments indicate that the stratification mechanism can mitigate decision-boundary displacement under the evaluated settings.
No takes yet. Share an insight, caveat, or question.
Wei et al. (2026) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: