On the costs and profit of software defect prediction

Steffen Herbold · DOI

Introduction

Software defect prediction (SDP) has long been a staple of software engineering research. By identifying error-prone components before release, teams can theoretically allocate limited quality assurance (QA) resources more effectively. However, the field has historically focused on optimizing machine learning metrics—such as precision, recall, and the Area Under the Curve (AUC)—while neglecting the actual economic impact. This paper addresses this gap by introducing a comprehensive mathematical cost model to determine when SDP actually generates a profit.

The Economic Gap in Defect Prediction

Standard classification metrics often fail to translate directly into business value. A model with high precision might still be a financial burden if the cost of inspecting the flagged files exceeds the savings from prevented bugs. Furthermore, most existing research relies on the "1-to-1" assumption: the idea that a single defect is contained within exactly one software artifact (e.g., a file). In reality, defects often span multiple files, and files can contain multiple defects. This paper seeks to provide a mathematically grounded framework to determine the "profit zone" where using a prediction model is cheaper than either doing nothing or performing exhaustive QA on every artifact.

A Comprehensive Cost Model

The author formulates a general cost model that accounts for four primary factors:

  1. Setup and Execution Costs: The overhead of implementing and maintaining the prediction infrastructure.
  2. QA Costs: The expense of inspecting or testing artifacts flagged as "defective."
  3. Post-Release Costs: The high financial burden of defects that escape into the production environment.
  4. QA Imperfection: The reality that even if a "defective" file is inspected, the QA process might still fail to reveal the bug.

The core contribution of the paper is Theorem 1, which defines the boundary conditions for a defect prediction model to be profitable. The model is then initialized using different assumptions regarding the relationship between artifacts and defects, ranging from the simplistic 1-to-1 model to the more realistic n-to-m model (where defects span multiple artifacts and artifacts contain multiple defects).

Methodology and Data

To validate the model, the study utilizes data from 15 Apache projects, including Kafka, Zookeeper, and Storm, collected via the SmartSHARK platform. The author specifically mapped bug-fixing commits to multiple files to capture the $n$-to-$m$ relationship. To ensure data integrity, issues affecting multiple files were manually validated to confirm they were genuine defects rather than mislabeled tasks or refactoring.

Key Insights: The n-to-m Trap

The research highlights that the common 1-to-1 assumption is a significant pitfall. In an $n$-to-$m$ scenario, if a single bug is linked to five files but the model only predicts four of them as defective, the bug remains in the system. Consequently, the organization still pays the full post-release cost for that defect despite the QA effort. Ignoring this relationship leads to inaccurate ROI estimates and overestimates the value of the prediction model.

Furthermore, the study reveals that profitability is highly project-dependent. There is no universal threshold for precision or recall that guarantees success. In some projects, a model with only 20% precision is highly profitable because the cost of a post-release defect is so high compared to the cost of a quick code review. Conversely, if the QA process is only 50% effective at finding predicted bugs, the "profit zone" for the prediction model shrinks significantly.

Results and Project Classification

The author identified two distinct types of projects based on their economic profiles:

  • Low Difficulty: Projects where defect prediction is easily cost-saving even with very low precision (<25%), provided recall is high.
  • Medium Difficulty: Projects requiring at least mediocre precision (25-50%) to achieve profitability.

The results show a significant divergence between the 1-to-1 and $n$-to-$m$ models. The relationship between machine learning metrics and cost is non-linear; for instance, a 10% increase in recall does not necessarily lead to a 10% decrease in costs, as the profitability boundaries often change superlinearly.

Conclusion and Future Work

This research shifts the focus of software defect prediction from algorithmic performance to economic viability. By accounting for the complex relationship between defects and artifacts, it provides a more accurate framework for organizations to evaluate SDP tools. While the current model uses simulated prediction levels and constant defect costs, future work could incorporate specific machine learning algorithms and a distribution of defect costs to account for varying severity levels, such as security vulnerabilities versus minor UI glitches.

Summary updated

BibTeX
@article{herbold2019costs,
  author = {Steffen Herbold},
  title = {{On the costs and profit of software defect prediction}},
  journal = {IEEE Trans. Software eng},
  year = {2019},
  doi = {10.1109/tse.2019.2957794},
}
Figure