Beyond Predictive Performance: SHAP-Based Explanations and Alignment with Literature-Based Indicators in Code Smell Detection
Marcela Mosquera, Rodolfo Bojorque
Key points
From the paper's conclusion- These findings indicate that explanatory relevance depends on the experimental context and that model contributions, statistical associations, and literature-based indicators provide complementary evidence for interpreting code smell predictions.
Abstract
Machine learning-based code smell detection relies on structural metrics, but predictive performance alone does not establish whether the information used by classifiers corresponds to the characteristics reported in the literature. This study examines the SHapley Additive exPlanations (SHAP)-based attribution behavior of Support Vector Machine (SVM) models by integrating SHAP-based feature importance, point-biserial associations, and 40 literature-based code smell operationalizations. The analysis reconstructs 120 SVM models across three open-source Java systems and four code smells, using ten folds per system–smell combination. Feature importance, persistence across folds, and consistency across software systems are examined alongside SHAP–correlation concordance, indicator coverage, and directional compatibility. The results show that influential metrics vary across code smells and software systems, while high average importance does not necessarily imply persistence across folds. For example, NOD achieved the highest mean normalized importance for Azureus–God Class (0.211) but appeared in the fold-level Top-5 in only 30% of the folds. Agreement between SHAP-based rankings and statistical associations is partial, with a median Top-5 overlap of 0.30. Indicator coverage and directional compatibility provide distinct forms of evidence; for God Class, mean Top-5 coverage was 0.05 whereas mean directional compatibility was 0.92, and some literature-based operationalizations cannot be evaluated using the available metrics. Additional sensitivity and robustness analyses showed that the main findings were generally stable across alternative Top-k cutoffs, association partitions, metric-mapping scenarios, and SHAP configurations; repeated SHAP realizations showed particularly high agreement for background sizes of 50 or more instances. These findings indicate that explanatory relevance depends on the experimental context and that model contributions, statistical associations, and literature-based indicators provide complementary evidence for interpreting code smell predictions. The results are relevant to researchers developing explainable code smell detectors and to tool developers and practitioners assessing whether predictive models rely on structural evidence consistent with established smell definitions.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Test Case Selection for Deep Neural Networks: A Replication Study on LLMs for Code (Replicability Study)Proceedings of the ACM on Software Engineering · 2026
- Beyond Accuracy: A Cross-Benchmark Investigation of Label Consistency and Reliability in AI-Based Software Vulnerability DetectionSymmetry · 2026
- Evaluating line-level localization ability of learning-based code vulnerability detection modelsMachine Learning · 2026
- Beyond Confidence: Rethinking Uncertainty Calibration in Deep Code ModelsarXiv · 2026
- Enhancing LLM‐Based Code Smell Prediction Using Empirical Detection StrategiesConcurrency and Computation: Practice and Experience · 2026
- X‐GNN for Interpretable Class‐Level Software Defect Prediction: An Empirical Study on Defects4JJournal of Software: Evolution and Process · 2026