Software defect feature selection method, device and system and storage medium

By optimizing the selection of software defect features through the minimum redundancy maximum correlation algorithm and multi-population parallel evolutionary crossover and mutation operations, the feature redundancy problem is solved, and the accuracy and stability of the prediction model are improved.

CN121764799APending Publication Date: 2026-03-31GUANGDONG OCEAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511930551.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing software defect prediction models have limited ability to handle feature redundancy issues and struggle to fully extract sample information, resulting in a need to improve prediction accuracy.

Method used

The minimum redundancy maximum correlation algorithm is used to perform segmented probabilistic initialization of the initial population. The feature selection process of the genetic algorithm is optimized by combining the circular chain structure and the symmetric uncertainty crossover operator through parallel evolution and crossover mutation operations of multiple subpopulations.

Benefits of technology

It effectively addresses the issue of feature redundancy in software defect datasets, improving the accuracy and robustness of software defect prediction models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121764799A_ABST
    Figure CN121764799A_ABST
Patent Text Reader

Abstract

The invention discloses a software defect feature selection method, device and system and a storage medium. The method comprises the following steps: S1, carrying out feature coding on software measurement features of a software defect historical data set; s2, performing sectional probability initialization on the initial population by adopting a minimum redundancy and maximum correlation algorithm according to the coded software measurement characteristics to obtain a plurality of sub-populations; s3, performing parallel chromosome evolution operation and crossover mutation operation on each sub-population; and S4, after parallel evolution and overall crossover variation of each sub-population, putting a parent chromosome and a generated sub-chromosome sum into a chromosome pool, selecting an optimal individual chromosome according to a fitness descending order, then carrying out remodeling of the sub-population, and continuing to repeat genetic manipulation until the maximum number of iterations is reached. By adopting the technical scheme of the invention, a high-quality feature combination which is most effective to predict defects and has the lowest redundancy is quickly and accurately screened out from high-dimensional software features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information processing technology, and specifically relates to a method, apparatus, system, and storage medium for selecting software defect features. Background Technology

[0002] Software defect prediction is a crucial aspect of software testing and quality assurance. It utilizes historical data and defect information from software projects, such as code metrics and commit process data, to build predictive models using machine learning techniques. These models identify modules in the code most likely to develop defects in the future. With these defect identification models, engineering teams can quickly pinpoint components with high security risks, providing software engineers with decision-making support, enabling the development of risk management strategies, and guiding security checks and testing to optimize the priority of software defense efforts.

[0003] However, in real-world software defect datasets, features generally exhibit high levels of interactivity and redundancy. Existing defect prediction models have limited ability to handle this feature redundancy problem, making it difficult to fully extract sample information, thus requiring improvement in prediction accuracy. Summary of the Invention

[0004] To address the problems existing in the prior art, the present invention provides a method, apparatus, system, and storage medium for selecting software defect features.

[0005] To achieve the above objectives, the present invention provides the following solution: A method for selecting software defect features, comprising: Step S1: Encode the software metric features of the historical software defect dataset; Step S2: Based on the encoded software metric features, the minimum redundancy maximum correlation algorithm is used to perform segmented probability initialization on the initial population to obtain multiple subpopulations. Step S3: Parallel chromosome evolution and crossover mutation operations are performed on each subpopulation. In the chromosome evolution operation, a circular chain structure is used as the chromosome arrangement within the subpopulation. In the crossover mutation operation, a crossover operator based on symmetric uncertainty is used to calculate the similarity between each parent scheme and the defect label. Step S3: After parallel evolution and overall crossover mutation in each subpopulation, the parent chromosome and the generated offspring chromosomes are placed in a chromosome pool, and the best chromosome is selected in descending order of fitness. Each chromosome is then used to reshape the subpopulation, and the genetic operation is repeated until the maximum number of iterations is reached.

[0006] The present invention also provides a software defect feature selection device, comprising: The first processing module is used to encode the software metric features of the historical software defect dataset. The second processing module is used to perform segmented probability initialization of the initial population based on the encoded software metric features using the minimum redundancy maximum correlation algorithm, to obtain multiple subpopulations. The third processing module is used for parallel chromosome evolution and crossover mutation operations on each subpopulation. In the chromosome evolution operation, a circular chain structure is used as the chromosome arrangement method within the subpopulation. In the crossover mutation operation, a crossover operator based on symmetric uncertainty is used to calculate the similarity between each parent scheme and the defect label. The fourth processing module is used to place the parent chromosomes and the generated offspring chromosomes into a chromosome pool after parallel evolution and overall crossover mutation of each subpopulation, and select the best chromosomes in descending order of fitness. Each chromosome is then used to reshape the subpopulation, and the genetic operation is repeated until the maximum number of iterations is reached.

[0007] The present invention also provides a software defect feature selection system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a software defect feature selection method when executed by the processor.

[0008] The present invention also provides a storage medium storing a computer program, which executes a software defect feature selection method during runtime.

[0009] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. The minimum redundancy maximum correlation algorithm is used to pre-score the features, and the initial population of the genetic algorithm is initialized in a segmented probability manner based on the scores, so that the algorithm starts searching from high-quality initial feature combinations.

[0010] 2. Distribute the feature selection task across multiple subpopulations in parallel, and increase population diversity through neighbor competition and cooperation mechanisms within the subpopulations to prevent the algorithm from converging prematurely.

[0011] 3. A crossover operator based on symmetric uncertainty was designed, which makes the crossover process tend to retain and combine parent feature information that contributes more to defect prediction.

[0012] This invention effectively addresses the feature redundancy problem in software defect datasets by making targeted improvements to multiple stages of the genetic algorithm, such as initialization, evolution, and crossover. It can search the feature space more efficiently, thereby selecting a subset of features with better prediction performance and improving the accuracy and robustness of the software defect prediction model. Attached Figure Description

[0013] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart of the software defect feature selection method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of chromosome structure; Figure 3 This is a schematic diagram of chromosome evolution operations in multiple populations. Detailed Implementation

[0015] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0016] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0017] Example 1 like Figure 1 As shown, the present invention provides a method for selecting software defect features, comprising: Step S1: Encode the software metric features of the historical software defect dataset; Step S2: Based on the encoded software metric features, the minimum redundancy maximum correlation algorithm is used to perform segmented probability initialization on the initial population to obtain multiple subpopulations. Step S3: Parallel chromosome evolution and crossover mutation operations are performed on each subpopulation. In the chromosome evolution operation, a circular chain structure is used as the chromosome arrangement within the subpopulation. In the crossover mutation operation, a crossover operator based on symmetric uncertainty is used to calculate the similarity between each parent scheme and the defect label. Step S4: After parallel evolution and overall crossover mutation in each subpopulation, the parent chromosomes and the generated offspring chromosomes are placed in a chromosome pool, and the best chromosomes are selected in descending order of fitness. Each chromosome is then used to reshape the subpopulation, and the genetic operation is repeated until the maximum number of iterations is reached.

[0018] In one embodiment of the present invention, step S1 first involves acquiring a historical dataset of software defects. Each software module is considered a sample, and its labels include two categories: defect-free and defective. The dataset contains multiple software metrics, each of which is a feature, such as cyclomatic complexity, lines of code, and inter-class coupling.

[0019] After obtaining the historical dataset of software defects, the features need to be encoded. This invention uses a binary encoding method, one chromosome... It is 3D binary vector ,in This represents the total number of features in the dataset. Each gene... The value can be 0 or 1. Indicates the selection of the first One software feature, Indicates not to select the first option Each chromosome represents a potential combination of features.

[0020] In one embodiment of this invention, in step S2, a project in a software defect prediction task may contain hundreds or thousands of encoded software metric features, such as cyclomatic complexity, lines of code, number of commits, number of developers, and historical defect data. Standard genetic algorithms employ a completely random initialization strategy, meaning each encoded software metric feature has a 50% probability of being set to 1. This strategy suffers from a lack of prior knowledge, treating strong predictive features and irrelevant software metric features equally. This leads to a generally poor initial population quality, containing a large number of redundant or irrelevant software metric features, requiring the algorithm to consume significant computational resources to converge to a high-quality solution. To address this problem, this invention introduces a minimum redundancy maximum correlation algorithm in the initialization phase to pre-screen and score the quality of all encoded software metric features.

[0021] The minimum redundancy maximum correlation algorithm is a filtering feature selection method. Maximum correlation refers to selecting the software metric features most relevant to "whether a defect occurs," while minimum redundancy refers to avoiding selecting features with overlapping information among these relevant features. For example, "lines of code" and "number of methods" are highly correlated; they provide similar information and are considered redundant features. The minimum redundancy maximum correlation algorithm can use mutual information to quantify this correlation and redundancy.

[0022] For two discrete software metrics features and Their mutual information Calculate using the following formula:

[0023] in, Representing software metric features and The joint probability distribution, and Representing software metric features respectively and The probability density function; mutual information is used to measure the similarity between two metric features.

[0024] If it is a continuous software metric, then the following formula is used for calculation:

[0025] In the minimum redundancy maximum correlation algorithm, the correlation between features and categories is calculated using the following formula. :

[0026] in, Indicates mutual information, Represents the combination of software metric features Quantity, Indicates software defect characteristics, This indicates a software defect label.

[0027] Redundancy between software metric features Use the following formula to calculate:

[0028] in, These are characteristics of software defects.

[0029] Ultimately, the decision function of the minimum redundancy maximum correlation algorithm is... Use the following formula to calculate:

[0030] The method uses two simple combinations to link relevance and redundancy, achieving the goal of maximizing the relevance between features and the objective function while minimizing the redundancy between features. The higher the score, the higher the feature importance.

[0031] Based on the calculation results of the minimum redundancy maximum correlation algorithm, this invention adopts a segmented initialization strategy for software defect characteristics. Differentiation is applied. Specifically, first, the calculated scores for each feature are sorted in descending order; then, the software defect features are divided into three levels: if... If the rating is in the top 5%, then There is a probability of 0.8 to 0.9 that it is set to 1; if If the rating ranks between 5% and 10%, then There is a probability of 0.7 to 0.8 that is set to 1; if For the remaining features, then There is a probability of 0 to 0.5 that is set to 1.

[0032] In one embodiment of the present invention, the chromosome evolution operation in step S3 is as follows: In standard genetic algorithms, all chromosomes are mixed in a single population. For software metrics such as the number of historical defects, which contributes significantly to defect prediction, standard genetic algorithms tend to favor feature combinations that include the number of historical defects, leading to premature convergence. In this situation, the algorithm loses its diversity prematurely and eventually gets stuck in a local optimum. To address this problem, this invention first randomly divides the entire population into multiple subpopulations, using a circular chain structure as the chromosome arrangement within each subpopulation. The optimal subset of software defect features is searched in parallel across these subpopulations, and finally, high-quality information is shared, thus resolving the premature convergence issue. Figure 2 The study demonstrates chromosome structures in multi-population genetic algorithms, showing cooperation and competition between chromosomes and their neighboring chromosomes within subpopulations.

[0033] In multi-population chromosome evolution operations assuming the competitive selection order is from left to right, the current chromosome is... The neighbor is , is defined by the following formula:

[0034] in, This represents the total number of features in the historical dataset of software defects. This indicates the number of subpopulations set. Further, The two neighboring chromosomes are defined as:

[0035] in, Indicates the first neighboring chromosome. Indicates the second neighboring chromosome according to The positions of two neighboring chromosomes at different locations within a chromosome ring are represented as follows:

[0036] The chromosome with the lower fitness value is selected as its competitor from the two direct neighbors of the current chromosome. The execution process can be formally described as follows:

[0037] in, This represents a dynamic competition operator that, through an adaptive learning rate, causes genes with different feature selection states to move closer to the winning side in the competition.

[0038] Therefore, through the above-described multi-population chromosome evolution operations, chromosomes based on neighbor update values ​​rather than original values ​​will increase population diversity, thereby reducing the probability of early convergence. A schematic diagram of multi-population chromosome evolution operations is shown below. Figure 3 As shown.

[0039] In one embodiment of the present invention, the crossover mutation operation in step S3 is as follows: After multiple population chromosome evolutions, chromosomes from all subpopulations are placed into a global chromosome pool for crossover and mutation. Traditional crossover operators typically select a random crossover point, combining two parent schemes... and Truncation and interchange. However, in software defect prediction tasks, the feature combinations represented by the two parent chromosomes have significantly different defect prediction capabilities, and a random crossover point can disrupt the feature synergy of the parent chromosomes.

[0040] To address this problem, this invention designs a similarity-based crossover operator, which uses the similarity of combinations of two metric features to guide chromosome crossover operations. The chromosome crossover operation is as follows:

[0041] in, and Representing the parent chromosome, it is a combination of two different metrics used for crossover selection. The weights used to measure the similarity between two parent chromosomes are calculated using the following formula:

[0042] The similarity weight is measured by a symmetric uncertainty index, and is calculated as follows:

[0043] in, It is a subset of software defect measurement features The entropy, representing Uncertainty This represents a subset of features given the defect labels. Conditional entropy is used to measure uncertainty. It is the final similarity score.

[0044] After the crossover operation is completed, a random number between 0 and 1 is generated. If the number is less than the set mutation probability, all genes are flipped; otherwise, they remain unchanged, thus completing the mutation operation.

[0045] In one embodiment of the present invention, in step S4, fitness is used to evaluate the quality of a chromosome; a higher fitness value indicates a higher quality combination of features currently being selected. In this invention, fitness... Simultaneously considering the feature selection ratio and the predictive performance of feature combinations, that is,

[0046] in, Indicates the number of features in the dataset. Indicates the number of features to be selected. The intensity used to control the feature percentage is set within a certain range. Compared to feature compression, the more important objective of this invention is to find the feature combination that achieves the best classification accuracy; therefore, it will set... It is 0.01.

[0047] In summary, in the embodiments of the present invention, the generated offspring chromosomes will be more inclined to adopt the parent chromosomes with stronger genetic prediction capabilities, thereby ensuring the inheritance of a higher-quality software defect feature selection scheme.

[0048] Example 2 The present invention also provides a software defect feature selection device, comprising: The first processing module is used to encode the software metric features of the historical software defect dataset. The second processing module is used to perform segmented probability initialization of the initial population based on the encoded software metric features using the minimum redundancy maximum correlation algorithm, to obtain multiple subpopulations. The third processing module is used for parallel chromosome evolution and crossover mutation operations on each subpopulation. In the chromosome evolution operation, a circular chain structure is used as the chromosome arrangement method within the subpopulation. In the crossover mutation operation, a crossover operator based on symmetric uncertainty is used to calculate the similarity between each parent scheme and the defect label. The fourth processing module is used to place the parent chromosomes and the generated offspring chromosomes into a chromosome pool after parallel evolution and overall crossover mutation of each subpopulation, and select the best chromosomes in descending order of fitness. Each chromosome is then used to reshape the subpopulation, and the genetic operation is repeated until the maximum number of iterations is reached.

[0049] Example 3 The present invention also provides a software defect feature selection system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a software defect feature selection method when executed by the processor.

[0050] Example 4 The present invention also provides a storage medium storing a computer program, which executes a software defect feature selection method during runtime.

[0051] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A software defect feature selection method characterized by, The method comprises the following steps: Step S1, feature coding is performed on software metric features of a software defect history dataset; Step S2, according to the coded software metric features, an initial population is segmented and probabilistically initialized by using a minimum redundancy maximum relevance algorithm to obtain multiple sub-populations; Step S3, parallel chromosome evolution operations and crossover mutation operations are performed on each sub-population; in the chromosome evolution operation, a circular chain structure is used as a chromosome arrangement mode within the sub-population; in the crossover mutation operation, a symmetric uncertainty-based crossover operator is used to calculate the similarity between each parent solution and a defect label. Step S3, after parallel evolution of each sub-population and overall crossover and mutation, the parent chromosomes and the generated child chromosomes are put into a chromosome pool, the best one is selected according to descending order of fitness, then the sub-population is reshaped, and the genetic operation is continued to repeat until the maximum iteration number is reached. Step S3, after parallel evolution of each sub-population and overall crossover and mutation, the parent chromosomes and the generated child chromosomes are put into a chromosome pool, the best one is selected according to descending order of fitness, then the sub-population is reshaped, and the genetic operation is continued to repeat until the maximum iteration number is reached.

2. A software defect feature selection apparatus characterized by comprising: The method comprises the following steps: A first processing module is configured to perform feature coding on software metric features of a software defect history dataset; A second processing module is configured to perform segmented probabilistic initialization on an initial population by using a minimum redundancy maximum relevance algorithm according to the coded software metric features to obtain multiple sub-populations; A third processing module is configured to perform parallel chromosome evolution operations and crossover mutation operations on each sub-population; in the chromosome evolution operation, a circular chain structure is used as a chromosome arrangement mode within the sub-population; in the crossover mutation operation, a symmetric uncertainty-based crossover operator is used to calculate the similarity between each parent solution and a defect label. The fourth processing module is configured to put the parent chromosomes and the generated offspring chromosomes into a chromosome pool after parallel evolution of each sub-population and overall crossover and mutation, select the best chromosomes in descending order of fitness, and then perform sub-population remodeling, and continue to repeat the genetic operation until a maximum iteration number is reached. The fourth processing module is configured to put the parent chromosomes and the generated offspring chromosomes into a chromosome pool after parallel evolution of each sub-population and overall crossover and mutation, select the best chromosomes in descending order of fitness, and then perform sub-population remodeling, and continue to repeat the genetic operation until a maximum iteration number is reached.

3. A software defect feature selection system, comprising: The method comprises the following steps: A memory and a processor, the memory has a computer program stored thereon, the computer program is run by the processor, and the computer program performs the software defect feature selection method of claim 1 when being run by the processor.

4. A storage medium, characterized by The storage medium has a computer program stored thereon, and the computer program performs the software defect feature selection method of claim 1 when being run.