Static code metrics for software defect prediction capture structural features but lack semantic context. To address this, we propose an approach using Abstract Syntax Tree (AST) joint features and an Attention-based Bidirectional LSTM (ABL) model (AJF-ABL), where the AST joint features (AJF) combine AST-based semantic features with traditional static code metrics. The AST joint features integrate the code structure and semantic relationships derived from the syntax tree, generating a higher-quality defect dataset enriched in feature dimensions. To handle cross-project data, we employ transfer learning based on Transfer Component Analysis, which aligns feature distributions between source and target projects to improve model generalizability. Concurrently, the ABL addresses key limitations of existing architectures: convolutional neural networks (CNNs) tend to struggle with long-range code dependencies, while unidirectional LSTMs ignore future contextual information. Bidirectional LSTM is employed to capture comprehensive contextual information from the AST features, and an attention mechanism is used to focus on critical elements. Experiments on five Java projects from the PROMISE dataset show that the proposed AJF consistently improves the performance of the same prediction algorithms, compared with using AST-only features or static code metrics alone. In cross-version defect prediction, AJF-ABL achieves improvements of 11.2 %, 15.7 %, and 5.6 % in F1-score over the baseline CNN, LSTM, and ACNN, respectively. In cross-project defect prediction, AJF-ABL achieves relative improvements of 32.2 % and 3.2 % in F1-score, and 39 % and 6.3 % in AUC, over the AF-Attention-CNN (AST features + Attention-CNN) and MFA (Multi Features Attention) baselines, respectively.
Li et al. (Sun,) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: