Multi-stage Dynamic Selection for Cross-Project Defect Prediction

A novel two-stage multi-classifier system for cross-project defect prediction that adapts to distribution shifts and outperforms state-of-the-art methods.

viernes, 24 de julio de 2026 • 4 min read • Q2BSTUDIO Team

Cómo mejorar la predicción de fallos con selección dinámica de clasificadores

Software defect prediction is a critical area within quality assurance. When we talk about predicting errors in a project that lacks its own historical data, we turn to Cross-Project Defect Prediction (CPDP). The main challenge lies in the fact that training data comes from external projects with statistical distributions different from the target project. This distribution shift degrades the performance of traditional models that assume training and test data come from the same distribution. To address this, the research community has proposed domain adaptation, instance selection, and multiple classifier systems. However, most approaches apply the same set of classifiers to the entire target project, without considering that different modules may require specialized models.

In this article, we present an original technical and business perspective, analyzing a multi-stage dynamic selection framework that operates at two levels: first at the project level to choose a multiple classifier system (MCS) configuration that generalizes well across training projects, and second at the module level to select, at test time, the most competent classifiers for each new module of the target project. This approach is more robust to distribution shifts because the selection adapts to the individual characteristics of each module.

From a business perspective, implementing such systems in real software development environments requires robust infrastructure, integration with CI/CD pipelines, and Cloud AWS/Azure capabilities to process large volumes of project data and run models at scale. At Q2BSTUDIO, we offer cloud solutions that enable deploying machine learning models with high availability and optimized costs.

The proposal we analyze uses a multiple classifier system with two selection stages. In the first stage, multiple MCS configurations are evaluated (e.g., different combinations of base classifiers such as decision trees, SVM, neural networks, etc.) to find the one that maximizes coverage and generalization over training projects. This involves measuring metrics like diversity among classifiers and average performance in cross-validation. The result is a set of expert classifiers, each specialized in certain defect patterns.

In the second stage, when a new module from the target project needs evaluation, a dynamic selection mechanism is activated. For each module, the competence of each classifier in the set is calculated using local similarity metrics (e.g., based on nearest neighbors in the feature space). Only the most competent classifiers participate in the final prediction, which can be a weighted voting or stacking. This module-level adaptation significantly improves precision, as a classifier that performs well for modules with high cyclomatic complexity may not be suitable for modules with many external dependencies.

In the context of custom software, where each project has unique requirements and code patterns, this technique is particularly valuable. Q2BSTUDIO develops custom software for businesses, integrating AI models that predict defects throughout the development lifecycle. Our teams use adaptive CPDP frameworks to improve final product quality without relying on internal historical data.

Experiments conducted with 82 projects from four benchmark datasets (such as PROMISE, AEEEM, and others) show that the multi-stage dynamic selection approach outperforms state-of-the-art CPDP methods in most scenarios. Metrics include AUC, F1-score, and balanced accuracy. The results demonstrate that module-level selection reduces the impact of distribution shift, especially when training and target projects come from very different domains (e.g., a banking management system vs. an e-commerce application).

From a cybersecurity standpoint, predicting defects not only improves software stability but also helps identify vulnerabilities before they are exploited. Many security flaws originate from code errors that could have been detected with CPDP models. At Q2BSTUDIO, we integrate code audits with defect prediction systems to offer comprehensive cybersecurity services.

Furthermore, the incorporation of AI and intelligent agents in the CPDP process allows automating model selection and continuous adaptation. Our AI agents can monitor classifier performance in real time and reconfigure the MCS without human intervention. This is especially useful in DevOps environments where models need frequent updates with new project data.

Another relevant aspect is the use of BI/Power BI to visualize defect predictions and code quality metrics. Interactive dashboards enable development teams to quickly identify high-risk modules and prioritize code reviews. Q2BSTUDIO implements Business Intelligence solutions that integrate data from repositories, CI systems, and CPDP models to provide a global view of project health.

Technical implementation of this framework requires handling large volumes of code feature data (static and dynamic metrics, complexity, coupling, etc.). For this, Cloud AWS/Azure capabilities are essential. We use services like AWS SageMaker or Azure Machine Learning to train and deploy classifiers, and scalable databases like Amazon Redshift or Azure Synapse to store metrics. At Q2BSTUDIO, we offer consulting to migrate and optimize these cloud infrastructures, ensuring CPDP models run with low latency and high availability.

In conclusion, multi-stage dynamic selection for CPDP represents a significant advance over traditional methods. By adapting classifier selection to each module, greater robustness against distribution shifts is achieved. Companies adopting such techniques can reduce defect detection time, lower maintenance costs, and improve delivered software quality. At Q2BSTUDIO, we combine expertise in custom software, artificial intelligence, cloud computing, and cybersecurity to offer complete solutions that integrate these advanced capabilities.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.