Cross Version Defect Prediction with Class Dependency Embeddings

Moti Cohen, Lior Rokach, Rami PuzisarXiv 2022

TL;DR

Researchers have developed a new framework for Cross Version Defect Prediction (CVDP) that combines traditional code metrics with automated graph embeddings of class dependencies. By using alignment techniques to map these embeddings across different software versions, their meta-model achieved a statistically significant 4.7% improvement in AUC over traditional methods.

What Problem Does This Paper Address?

Finding bugs early saves time and money, but predicting which software modules are likely to fail is tricky. Most models rely on Static Code Metrics (like lines of code or cyclomatic complexity). While useful, these metrics often miss the "big picture"—the structural relationships between different parts of the code.

The authors focus on Cross Version Defect Prediction (CVDP), where a model is trained on an older version of a project to predict bugs in a newer one. This is significantly harder than predicting bugs within the same version because software evolves; the distribution of metrics changes, and the structural "neighborhood" of a class might shift. Previous attempts to use structural data relied on handcrafted network metrics (like centrality), which are labor-intensive and may not capture all relevant information.

Methods

The authors propose a multi-step pipeline that treats software structure as a graph, known as a Class Dependency Network (CDN).

Figure 1: A Flowchart of Our Proposed Solution
  1. CDN Extraction: They parse Java source code to build a directed graph where nodes are classes/interfaces and edges represent 10 types of relationships (e.g., Extends, Implements, Method Call).
  2. Graph Embedding: Instead of manual metrics, they use Node2vec and LINE to automatically translate these graph structures into high-dimensional vectors (embeddings).
  3. The "Secret Sauce" – Embedding Alignment: Because embedding algorithms are stochastic, the same class in Version 1 and Version 2 might end up in completely different parts of the vector space. To fix this, they use Orthogonal Procrustes alignment. They identify "anchor" nodes (classes present in both versions with similar neighborhoods) and learn a transformation to map the new version's embeddings into the old version's coordinate system.
  4. Classification: They concatenate these aligned embeddings with traditional static metrics and feed them into a Random Forest classifier.
  5. Meta-Modeling: Finally, they combine the predictions from both Node2vec and LINE models using a Logistic Regression meta-model to get the best of both worlds.

Datasets

The study utilized a well-known dataset collected by Jureczko et al., focusing on 9 open-source Apache projects written in Java (including Camel, Lucene, and Xerces). In total, they evaluated their approach on 24 unique version pairs (e.g., training on version 1.0 to predict version 1.2).

Key Insights and Ideas

  • Alignment is Mandatory: The paper demonstrates that using embeddings without alignment actually degrades performance. You can't compare "apples to apples" across versions if the coordinate systems don't match.
  • Orthogonality Matters: They found that Orthogonal Transformations outperformed standard Linear Regression for alignment. This is because orthogonal maps preserve the angles and distances between vectors, maintaining the semantic relationships captured by the embedding.
  • Complementary Embeddings: Node2vec (which uses random walks) and LINE (which focuses on immediate neighborhoods) capture different types of structural information (global vs. local). The authors found that projects where one failed, the other often succeeded, making them perfect candidates for a joint meta-model.
  • Automated Feature Engineering: By using embeddings, the researchers bypassed the need for "expert-crafted" network metrics, proving that deep learning-style representation learning can effectively capture software complexity.

Key Results

  • AUC Improvement: The proposed meta-model achieved a 4.7% improvement in Area Under the ROC Curve (AUC) compared to a baseline using only static code metrics.
  • Statistical Significance: The results were robust, with a p-value of < 0.002, indicating the improvement wasn't just due to luck.
  • Stability: While the F1-score remained similar to the baseline, the AUC gains suggest the model is significantly better at ranking which modules are most likely to be defective, which is crucial for prioritizing QA efforts.

Limitations and Future Work

The authors acknowledge a few hurdles:

  • Language Specificity: The current tool is built for Java. Different languages might exhibit different structural patterns.
  • F1-Score Stagnation: While AUC improved, the F1-score did not see a statistically significant boost, suggesting there is still room to refine how the model handles class imbalances.
  • Future Directions: The team plans to explore Multiple Older Versions (MOV)—training on several past releases instead of just one—and incorporating edge weights (e.g., how many times a method is actually called) into the CDN.

Summary updated

BibTeX
@misc{cohen2022cross,
  author = {Moti Cohen and Lior Rokach and Rami Puzis},
  title = {{Cross Version Defect Prediction with Class Dependency Embeddings}},
  year = {2022},
  eprint = {2212.14404},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.14404},
}
Figure