Project-Aware Validation in Software Defect Prediction: A Controlled Simulation and Real-World Benchmark Study of Evaluation Optimism
This study demonstrates through controlled simulations and a secondary analysis of real-world benchmarks that using pooled random train/test splits in software defect prediction yields systematically optimistic performance estimates compared to project-aware validation methods, highlighting the critical need for evaluation protocols that respect project boundaries.
Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
In the world of software, code is the foundation of everything from banking systems to medical devices. Yet, like any human-made structure, it is prone to cracks and flaws. Software engineers and researchers have long tried to build computer programs that can predict where these flaws, or "defects," are most likely to hide before the software is even released. The goal is to catch errors early, saving time and preventing costly failures. To test if these prediction programs work, researchers typically gather a massive collection of code from many different software projects, mix them all together into one big pile, and then split that pile randomly into a training group and a testing group. If the prediction program does well on the test group, it is assumed to be ready for the real world. This approach is convenient and widely used, but it relies on a hidden assumption: that a piece of code from one project is just as likely to appear in another project as it is to appear in its own. In reality, software projects are distinct ecosystems. They have their own unique histories, coding styles, and teams. A model trained on a mix of these different worlds might be learning the specific quirks of the projects it has seen, rather than learning how to find defects in a brand-new, unseen project.
A recent study by independent researcher Vladimir Tomilov investigates whether this common testing method is giving researchers a false sense of confidence. The study asks a simple but critical question: if we test a prediction model on data it has never seen from a specific project, does it perform as well as the standard tests suggest? To find the answer, the researcher did not rely on a single historical dataset. Instead, he built a controlled simulation where he could create artificial software projects with known rules. In this simulation, he generated data for six different projects, ensuring that each project had its own unique characteristics, much like how real-world software teams operate differently. He then trained prediction models on this data using two different methods. The first method was the standard approach: mixing all the data together and splitting it randomly. The second method was more rigorous: the model was trained on five projects and then tested strictly on the sixth project, which it had never seen before. This "leave-one-project-out" method mimics the real challenge of deploying a tool into a new environment.
The results of the simulation were clear and consistent. When the models were tested using the standard random mix, they appeared to be more accurate than they actually were. For the most complex models tested, the standard method overestimated their ability to find defects by about three percentage points. While three points might sound small, in the world of software prediction, it represents a significant gap between expectation and reality. The study found that the models were essentially memorizing the patterns of the specific projects they were trained on, rather than learning a universal rule for finding bugs. When the researchers forced the models to prove themselves on a completely new project, their performance dropped noticeably. The gap between the optimistic random-split score and the realistic new-project score was not a fluke; it appeared across different types of prediction algorithms and held true even when the researcher adjusted the difficulty of the simulation.
To ensure these findings were not just an artifact of the computer simulation, the researcher also looked at real-world data. He re-examined a published benchmark that covered eleven major open-source software projects. In this real-world check, he compared how well the models performed when tested on the same project they were trained on versus how they performed when tested on a project they had never seen. The pattern was identical to the simulation. In every single one of the eleven projects, the models looked much better when tested on familiar ground than when tested on new ground. The difference was even larger in the real world, with the overestimation ranging from six to sixteen percentage points. This confirmed that the problem is not just a theoretical issue in a simulation, but a genuine phenomenon affecting how we evaluate software tools today.
The study also explored how different types of models reacted to this challenge. It turned out that the more complex models, which are designed to find intricate patterns, were the most susceptible to this overestimation. They were the ones that most eagerly memorized the specific details of their training projects, leading to the biggest drop in performance when faced with new data. Simpler models, which rely on fewer and broader rules, were more stable. They did not perform as spectacularly in the easy tests, but they held up better when the rules of the game changed. This suggests that in the rush to build the most sophisticated prediction tools, researchers might be favoring models that are good at guessing the past but poor at predicting the future.
The implications of these findings are significant for anyone building or using software defect prediction tools. The study does not claim that these tools are useless, but it does argue that the way we measure their success is flawed. If a researcher reports that a new tool is highly accurate based on a random mix of data, they are likely reporting a number that is too high for real-world application. The study suggests that the only fair way to test a tool intended for new projects is to test it on projects it has never seen. This requires a shift in how experiments are designed, moving away from the convenience of mixing all data together and toward a more honest, project-by-project evaluation. By doing so, the software community can avoid the disappointment of deploying tools that look perfect in the lab but struggle in the field, ensuring that the tools we build are truly ready for the complex, diverse world of software development.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.