A novel transformer-based software fault prediction using syntactic tree and word embedding
摘要
The increase in size, complexity and capacity requirements poses a significant challenge in keeping the error rate of software systems at a minimum. Predicting potential faulty components plays an important role in software development to help developers prevent programming errors and produce more reliable software systems. Traditional approaches for software fault prediction usually use software metrics as features to build fault prediction models to identify defective modules. However, existing software metrics may not fully capture the semantic and syntactic information of source code which could be utilized in modeling program functionality. In this study, we propose a novel approach that combines the Gensim FastText word embedding and Transformer models for predicting software faults. Specifically, for each source code file, we extract token vectors from the program’s abstract syntax tree which are then encoded to numerical vectors using the Gensim FastText word embedding model. The embedding vectors are then fed to a transformer encoder model for fault prediction. Our proposed method is evaluated using Apache software fault datasets. The experimental results indicate that our proposed model yields better performance in terms of precision, recall and F1-score compared to other state-of-the-art fault prediction models for both within-project defect prediction and cross-project defect prediction. Our Gensim FastText-Transformer model improves within-project defect prediction (WPDP) on average of F1-score by 8.9%, 19,6%, 25.4%, 19.8% and 7% compared to DP-Transformer, DTL-DP, Seml, DBN-CP and FastText-LSTM, respectively. For cross-project defect prediction (CPDP), our approach outperforms DTL-DP, TCA+, DBN-CP and FastText-LSTM by 7.9%, 39.2%, 17.4% and 13.2% in terms of F1-score.