CDS: A Cross-Version Software Defect Prediction Model With Data Selection

Jie Zhang, Jiajing Wu, Chun-Lung Philip Chen, Zibin Zheng, Michael R. LyuIEEE Access 2020

Abstract

Software defect prediction (SDP) is essential for optimizing testing resources, yet Cross-Version Defect Prediction (CVDP) remains challenging due to evolving data distributions and class overlapping between releases. This paper presents CDS (Cross-version model with Data Selection), a framework that addresses these issues by categorizing files into existing and new groups. CDS utilizes a Clustering-based Multi-Version Classifier (CMVC) for historical files and a Weighted Sampling Model (WSM) for new files, employing spectral clustering and a novel weighting mechanism to filter noise and prioritize relevant data. Experimental results on the MORPH dataset demonstrate that CDS significantly outperforms traditional baselines and state-of-the-art methods across multiple performance metrics, including F-measure and g-mean.

Introduction

Software defect prediction (SDP) helps developers prioritize testing by identifying modules likely to contain bugs. While researchers have explored "Within-Project" and "Cross-Project" models, the most practical scenario for industry is Cross-Version Defect Prediction (CVDP)—using data from previous versions (e.g., 1.0 and 2.0) to predict bugs in the upcoming release (e.g., 3.0).

However, CVDP faces two major hurdles that standard models often ignore:

  1. Data Distribution Difference: The ratio and nature of defects can change drastically from one release to the next. Simply training on the "latest" version isn't always the best strategy.
  2. Class Overlapping: This is the "silent killer" of CVDP. The authors found that many files retain the same name and identical features across versions, but their status changes (e.g., a file is buggy in v1.0 but fixed in v2.0). This creates contradictory training data that confuses machine learning models.

Methodology: The CDS Framework

The authors propose the CDS framework, which splits the prediction task into two distinct pipelines to handle the unique characteristics of existing and new files.

Clustering-based Multi-Version Classifier (CMVC)

For files that have appeared in previous versions, the authors developed the CMVC. Instead of a standard "black box" classifier, CMVC solves an optimization problem. It uses spectral clustering to group similar files and assigns weights to previous versions based on two factors:

  • Relevance: How similar the version is to the current one in terms of feature distribution.
  • Noise: How many contradictory labels it contains due to class overlapping.

Weighted Sampling Model (WSM)

For brand-new files with no history, the authors created the WSM. WSM uses the version weights calculated by CMVC to build a custom training set. It samples more heavily from historical versions that are deemed most relevant and clean, then trains a standard Random Forest classifier on this curated data.

Experimental Setup

The study utilized the MORPH dataset, a benchmark in software engineering research, covering 28 versions across 8 open-source software projects (including camel, log4j, and xerces). Each file is represented by 20 object-oriented metrics (e.g., "Weighted methods per class" or "Lines of code") extracted using CKJM tools. The model was tested against three baseline classifiers (Random Forest, Logistic Regression, Naive Bayes) and a state-of-the-art approach called HALKP.

Key Insights

  • The Identical Feature Trap: One of the most striking findings was that "same-name" files across versions often have a cosine similarity of 1.0 in their features, yet their defect labels differ. This confirms that standard software metrics often fail to capture the subtle code changes that fix or introduce bugs.
  • Data Selection Over Volume: The authors demonstrated that merging all previous versions into one giant training set often performs worse than selecting specific, high-quality versions. Noise from old, irrelevant versions can "poison" the model.
  • Divide and Conquer: By separating "existing" files from "new" ones, CDS can apply a high-precision optimization approach to the files with history while using a robust sampling approach for the files that are unknown.

Results and Discussion

CDS consistently outperformed both traditional baselines and the state-of-the-art HALKP model across three major metrics: F-measure, g-mean, and Balance. * Significant Gains: Compared to baseline methods, CDS improved the F-measure (a balance of precision and recall) by 36.9% to 58.3%. * Consistency: CDS achieved the best performance on almost every single software project tested. * Efficiency: Unlike some competing models (like HALKP), CDS does not require any manual labeling of the current version to work, making it more "plug-and-play" for DevOps pipelines.

Conclusion

The CDS framework represents a significant advancement in cross-version defect prediction by explicitly addressing data distribution shifts and class overlapping. By intelligently selecting and weighting historical data, CDS provides a more accurate and reliable prediction model for real-world software evolution. Future research will focus on addressing class imbalance and extending the data selection logic to cross-project scenarios.

Summary updated

BibTeX
@article{zhang2020cds,
  author = {Jie Zhang and Jiajing Wu and Chun-Lung Philip Chen and Zibin Zheng and Michael R. Lyu},
  title = {{CDS: A Cross-Version Software Defect Prediction Model With Data Selection}},
  journal = {IEEE Access},
  year = {2020},
  doi = {10.1109/access.2020.3001440},
}
Figure