DeMuVGN: Effective Software Defect Prediction Model by Learning Multi-view Software Dependency via Graph Neural Networks

Yu Qiao, Lina Gong, Yu Zhao, Yongwei Wang, Mingqiang Wei · OpenReview

TL;DR

This paper introduces DeMuVGN, a novel approach to software defect prediction that leverages a "multi-view" dependency graph combining code and developer information. By using Graph Neural Networks (GNNs) and an oversampling technique, DeMuVGN significantly outperforms existing methods, especially in later stages of software development and across different projects.

What Problem Does This Paper Address?

Identifying high-risk software modules early in development is crucial for efficient resource allocation. While dependency information from code (like data and call dependencies) has been used to predict defects, these methods often ignore the significant role developers play. Developers have varying coding styles, experience levels, and can introduce similar defects due to shared habits. Existing approaches also rely on handcrafted metrics that may not fully capture the complex relationships leading to defects. This paper aims to bridge this gap by incorporating both code and developer dependencies into a unified model for more accurate defect prediction.

Methods

The core of DeMuVGN lies in its Multi-view Software Dependency Graph (MSDG). This graph combines:

  • Code Dependency Graph (CDG): Built using data and call dependencies between modules, measured by a tool called Understand.
  • Developer Dependency Graph (DDG): Captures developer consistency by looking at shared committers for modules.

These two graphs are merged into the MSDG, where edge weights represent the combined strength of code and developer dependencies.

To process this MSDG, the authors employ an Enhanced Bidirectional Gated Graph Neural Network (BiGGNN). BiGGNN is designed to learn node embeddings by considering both incoming and outgoing edges in a directed graph, allowing for a more comprehensive understanding of relationships. To tackle the common issue of imbalanced datasets in defect prediction (where defective modules are rare), they integrate the Synthetic Minority Over-sampling Technique (SMOTE). SMOTE generates synthetic samples for the minority class (defective modules) to help the model learn better.

Finally, the learned node embeddings are fed into a simple Multi-layer Perceptron (MLP) classifier to predict defect probabilities.

Datasets

The study evaluates DeMuVGN on eight open-source Apache software projects, spanning 20 different versions. These projects include ActiveMQ, Camel, Groovy, HBase, Hive, JRuby, Lucene, and Wicket. The datasets are diverse in terms of size, functionality, and defect rates. No new benchmark datasets were introduced; instead, existing projects with available source code, commit, and defect reports were used.

Key Insights and Ideas

  • Developer Insight is Crucial: The paper strongly suggests that developer information is as important as code structure for accurate defect prediction. A motivation example highlights how modules with no direct code dependency can be linked through shared developers, indicating a potential common source of defects.
  • Multi-view is Better than Single-view: Combining different types of dependencies (code and developer) in a single graph (MSDG) significantly improves defect prediction performance compared to using only code dependencies (CDG) or only developer dependencies (DDG).
  • Software Evolution Matters: DeMuVGN shows a greater improvement in later versions of software projects compared to earlier ones. This implies that as projects grow and evolve, the multi-view approach becomes even more effective at capturing complex, emergent defect patterns.
  • Generalizability is Key: The model demonstrates strong performance not only within a single project (within-project context) but also when trained on one project and applied to another (cross-project context), highlighting its ability to generalize.

Key Results

  • RQ1 (Multi-view Superiority): MSDG-based models improved F1 scores by 11.1% to 12.1% over single-view (CDG or DDG) models.
  • RQ2 (Outperforming State-of-the-Art): DeMuVGN achieved significant improvements in F1 scores:
  • 17.4% to 45.8% in within-project contexts compared to other advanced models.
  • 17.9% to 41.0% in cross-project contexts compared to other advanced models.
  • RQ3 (BiGGNN & SMOTE Contribution): BiGGNN alone showed good performance, but adding SMOTE further boosted performance, especially in Recall (16.0% improvement) and F1 (16.9% improvement), indicating SMOTE's effectiveness in handling data imbalance.
  • RQ4 (Cross-Project Transferability): DeMuVGN achieved the best performance across various cross-project prediction approaches, demonstrating its generalizability.

Limitations and Future Work

  • Developer Quality Ignored: The current DDG considers developer consistency but not the quality of a developer's work. Future work could explore incorporating developer quality metrics.
  • Simple Aggregation: The integration of CDG and DDG uses a simple weight aggregation. More sophisticated methods, like dynamic weighting, could be explored.
  • Java-centric: The study primarily uses Java projects. While the model shows generalizability, its effectiveness on other programming languages is not explicitly tested. Future work could expand to a broader range of languages.
  • Other Code Dependencies: The CDG currently includes data and call dependencies. Incorporating control dependencies could further enhance defect prediction.
  • Evaluation Metrics: While AUC and Brier score are good, the authors suggest exploring more unbiased metrics like geometric mean of recall and specificity for a more robust evaluation.

Summary updated

Abstract

Software defect prediction (SDP) aims to identify high-risk defect modules in software development, optimizing resource allocation. While previous studies show that dependency network metrics improve defect prediction, most methods focus on code-based dependency graphs, overlooking developer factors. Current metrics, based on handcrafted features like ego and global network metrics, fail to fully capture defect-related information. To address this, we propose DeMuVGN, a defect prediction model that learns multi-view software dependency via graph neural networks. We introduce a Multi-view Software Dependency Graph (MSDG) that integrates data, call, and developer dependencies. DeMuVGN also leverages the Synthetic Minority Oversampling Technique (SMOTE) to address class imbalance and enhance defect module identification. In a case study of eight open-source projects across 20 versions, DeMuVGN demonstrates significant improvements: i) models based on multi-view graphs improve F1 scores by 11.1% to 12.1% over single-view models; ii) DeMuVGN improves F1 scores by 17.4% to 45.8% in within-project contexts and by 17.9% to 41.0% in cross-project contexts. Additionally, DeMuVGN excels in software evolution, showing more improvement in later-stage software versions. Its strong performance across different projects highlights its generalizability. We recommend future research focus on multi-view dependency graphs for defect prediction in both mature and newly developed projects.
BibTeX
@misc{qiao2024demuvgn,
  author = {Yu Qiao and Lina Gong and Yu Zhao and Yongwei Wang and Mingqiang Wei},
  title = {{DeMuVGN: Effective Software Defect Prediction Model by Learning Multi-view Software Dependency via Graph Neural Networks}},
  year = {2024},
  eprint = {2410.19550},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.19550},
}
Figure