Skip to main content
QUICK REVIEW

[Paper Review] Defect Category Prediction Based on Multi-Source Domain Adaptation

Ying Xing, Mengci Zhao|arXiv (Cornell University)|May 16, 2024
Industrial Vision Systems and Defect DetectionEngineering1 citations
TL;DR

This paper proposes COPILOT, a multi-source domain adaptation framework that enhances defect category prediction by integrating adversarial training and a weighted maximum mean discrepancy (WMMD) attention mechanism. By modeling multiple source projects as distinct domains and aligning their feature distributions with a target project, COPILOT achieves state-of-the-art performance on an 8-project open-source dataset, significantly outperforming existing methods in F1, MCC, and Kappa scores across diverse defect types and data sparsity scenarios.

ABSTRACT

In recent years, defect prediction techniques based on deep learning have become a prominent research topic in the field of software engineering. These techniques can identify potential defects without executing the code. However, existing approaches mostly concentrate on determining the presence of defects at the method-level code, lacking the ability to precisely classify specific defect categories. Consequently, this undermines the efficiency of developers in locating and rectifying defects. Furthermore, in practical software development, new projects often lack sufficient defect data to train high-accuracy deep learning models. Models trained on historical data from existing projects frequently struggle to achieve satisfactory generalization performance on new projects. Hence, this paper initially reformulates the traditional binary defect prediction task into a multi-label classification problem, employing defect categories described in the Common Weakness Enumeration (CWE) as fine-grained predictive labels. To enhance the model performance in cross-project scenarios, this paper proposes a multi-source domain adaptation framework that integrates adversarial training and attention mechanisms. Specifically, the proposed framework employs adversarial training to mitigate domain (i.e., software projects) discrepancies, and further utilizes domain-invariant features to capture feature correlations between each source domain and the target domain. Simultaneously, the proposed framework employs a weighted maximum mean discrepancy as an attention mechanism to minimize the representation distance between source and target domain features, facilitating model in learning more domain-independent features. The experiments on 8 real-world open-source projects show that the proposed approach achieves significant performance improvements compared to state-of-the-art baselines.

Motivation & Objective

  • To address the limitation of traditional binary defect prediction by reformulating it as a fine-grained multi-label classification task using CWE defect categories.
  • To improve cross-project defect category prediction in scenarios where target projects lack sufficient labeled defect data.
  • To mitigate domain shift between source and target projects by leveraging knowledge from multiple heterogeneous software projects.
  • To enhance model generalization and reduce negative transfer through domain-invariant feature learning and adaptive attention weighting.

Proposed method

  • Reformulates traditional binary defect prediction into a multi-label classification problem using CWE categories as fine-grained labels.
  • Proposes a multi-source domain adaptation framework that uses adversarial training to reduce domain discrepancy between source and target projects.
  • Introduces a weighted maximum mean discrepancy (WMMD) mechanism as an attention module to minimize the representation distance between source and target domain features.
  • Leverages domain-relatedness scores from adversarial training to weight contributions of different source domains, enabling adaptive feature alignment.
  • Trains a deep neural network with shared encoder and task-specific classifier heads to jointly optimize domain alignment and defect category prediction.
  • Employs a two-stage training process: first adversarial domain adaptation, then end-to-end fine-tuning with attention-based feature refinement.

Experimental results

Research questions

  • RQ1Can the proposed COPILOT framework significantly improve defect category prediction performance compared to state-of-the-art baselines in cross-project settings?
  • RQ2How effective is COPILOT in handling diverse defect types, including rare or complex categories like input validation and buffer overflows?
  • RQ3What is the impact of data scarcity on COPILOT’s performance, and how does it compare to baselines under low-data regimes?
  • RQ4To what extent does the integration of adversarial training and WMMD attention contribute to model robustness and generalization?

Key findings

  • COPILOT achieves an average F1 score of 0.932 across six CWE defect type categories, outperforming the best baseline (ABMSDA) by 36.4%.
  • On the w_F1 metric for severe defects, COPILOT achieves an average of 0.877, a 44.9% improvement over ABMSDA and a 23.2% improvement over μVulDeePecker.
  • In the RQ2 ablation study, removing either adversarial training or WMMD attention led to a drop in average Kappa from 0.945 to 0.935 and 0.927, respectively, confirming both components' critical role.
  • COPILOT maintains superior performance across all defect data volume levels, with the highest stability when defect category samples exceed 36 instances.
  • Scott-Knott ESD tests confirm that COPILOT ranks first in all evaluation metrics (Acc, MCC, Kappa, F1, w_F1), with large effect sizes (Cohen’s d > 1.0) in most comparisons.
  • The model demonstrates strong generalization, achieving the best performance on all eight target projects in the dataset, including Apache JMeter, Elasticsearch, and JTree.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.