Answers are grounded in this paper and cite their sources.
However, not all the modules can be tested in the same way effectively and therefore defect prediction models are used to focus the testing efforts on the modules that are most likely to be defective. There are two major problems related to the use of defect prediction models. First, there are few defective modules, and, consequently, even a very accurate model may find no defects at all. Second, an unspecific model, i.e. the one that gives no justification for its prediction, is difficult to be trusted by developers. In this paper, Logistic Regression and Random Forest models are trained on a NASA-like dataset containing around 2,100 modules and 21 code metrics, of which only around 15 percent are defective. Then each of the two models is used in three versions: with all the features (as a baseline), with feature selection and SMOTE oversampling. Next, SHAP approach is used to explain the influence of different metrics on defect prediction. The three models without SMOTE showed an accuracy ranging from 0.84 to 0.86, which is equal to the accuracy that could be reached by the model predicting non-defective status for all the modules and recall ranging from 0.19 to 0.31. SMOTE improved the recall of Logistic Regression from 0.21 to 0.71 and of Random Forest from 0.31 to 0.47, at the expense of lower precision and, in case of Logistic Regression, also accuracy of 0.73. SMOTE resulted in the highest F1 scores (0.45 and 0.44). Feature selection did not improve anything. According to SHAP analysis, total operators, Halstead difficulty, cyclomatic complexity and lines of code were the most significant metrics. Several size and volume metrics had contradictory effect on prediction because of their high correlation. The obtained results allow the comparison of the approaches on the basis of one dataset but are not indicative of the software projects.
No takes yet. Share an insight, caveat, or question.
A Krishna Sathwika (2026) studied this question.
Synapse has enriched 8 closely related papers on similar clinical questions. Consider them for comparative context: