A software defect prediction method and system based on atomic association rule network

By constructing an atomic association rule network and pruning contradictory paths, the problem of inaccurate software defect prediction in traditional methods is solved, achieving more efficient feature selection and accurate software defect prediction.

CN117389879BActive Publication Date: 2026-05-15BEIHANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311341171.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-17
Publication Date
2026-05-15
Estimated Expiration
2043-10-17

AI Technical Summary

Technical Problem

In existing technologies, traditional rule pruning methods fail to fully assess the impact of association rules on classifier performance, resulting in inaccurate software defect prediction results. Furthermore, traditional feature selection methods have poor adaptability and cannot accurately predict software defects.

Method used

A method based on atomic association rule network is adopted. By constructing a weighted association rule network, contradictory node pairs are identified and deleted. The shortest path algorithm is used to prune contradictory paths and extract the set of association rules related to the target item. Combined with the embedded feature selection strategy, different support levels are set to retain frequent minority class patterns.

Benefits of technology

It improves the accuracy of software defect prediction, reduces the problem of excessive number of association rules caused by high-dimensional data, and enhances the effectiveness of rule pruning and the understandability of knowledge mining.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117389879B_ABST
    Figure CN117389879B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of software defect prediction method and system based on atomic association rule network, belong to software defect prediction technical field, solve the problem that existing software defect rule is not pruned from global reasoning angle and leads to inaccurate prediction result.The method includes: after historical software defect data is preprocessed as transaction data, according to association rule algorithm and promotion degree, extract atomic association rule;With defective label and non-defective label as target node respectively, construct two weighted association rule networks according to the correlation coefficient of atomic association rule;Identify the contradictory node pair in weighted association rule network, based on the shortest path algorithm iteration, delete the contradictory path between contradictory node pair, obtain the pruned weighted association rule network, extract two kinds of defect prediction rule set;According to the correlation coefficient of defect prediction rule matched by the software defect data to be predicted, obtain software defect prediction result.Accurate software defect prediction is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software defect prediction technology, and in particular to a software defect prediction method and system based on atomic association rule networks. Background Technology

[0002] Software defect prediction activities are used to efficiently allocate testing resources, enabling software testers to discover potential defects more promptly.

[0003] In data mining techniques, association rule mining is a highly interpretable and high-performance algorithm that can be effectively used as a software defect predictor. However, class imbalance in the data limits the generation of rules for classes with defective tendencies.

[0004] Furthermore, traditional feature selection methods are poorly adapted to association rule mining algorithms. Moreover, current rule pruning methods often only remove rules based on a single metric, such as length, confidence, or lift, making it difficult to comprehensively assess a rule's impact on classifier performance and its rationality in knowledge reasoning. Existing rule pruning methods do not consider specific contextual relationships, resulting in extracted rules that cannot accurately predict software defects. Summary of the Invention

[0005] Based on the above analysis, the embodiments of the present invention aim to provide a software defect prediction method and system based on atomic association rule networks, in order to solve the problem that the existing methods do not prune software defect rules from a global reasoning perspective, resulting in inaccurate prediction results.

[0006] On one hand, embodiments of the present invention provide a software defect prediction method based on atomic association rule networks, comprising the following steps:

[0007] After preprocessing historical software defect data into transaction data, atomic association rules are extracted based on association rule algorithms and lift, resulting in a set of atomic association rules.

[0008] Based on the set of atomic association rules, two weighted association rule networks are constructed with defective labels and non-defective labels as target nodes, respectively, according to the correlation coefficient of the atomic association rules.

[0009] For each weighted association rule network, contradictory node pairs in the weighted association rule network are identified; contradictory paths between contradictory node pairs are iteratively deleted based on the shortest path algorithm to obtain the pruned weighted association rule network, and two types of defect prediction rule sets are extracted.

[0010] Based on two sets of defect prediction rules, the software defect prediction results are obtained by matching the defect prediction rules with the software defect data to be predicted.

[0011] Based on a further improvement of the above method, historical software defect data is preprocessed into transaction data, including:

[0012] The defect labels in each historical software defect data are used as category labels. A hierarchical K-fold cross-validation method is used to construct training and testing sample sets. Each item in each training sample is discretized with equal frequency and placed into a discrete sample set. Transaction data is extracted from the discrete sample set based on Jaccard similarity and similarity threshold.

[0013] Based on further improvements to the above method, transaction data is extracted from the discrete sample set according to Jaccard similarity and a similarity threshold, including:

[0014] The discrete sample set is divided into discrete samples containing defect labels and discrete samples containing no defect labels based on the defect labels. Each discrete sample is taken out in turn, and the Jaccard similarity between the discrete sample and each discrete sample of the other class is calculated. The largest Jaccard similarity is taken as the Jaccard similarity of the discrete sample. Discrete samples with Jaccard similarity less than the similarity threshold are taken out to obtain the transaction data.

[0015] Based on further improvements to the above method, atomic association rules are extracted according to the association rule algorithm and lift, including:

[0016] The association rule algorithm is used to divide the generated candidate itemsets into three categories based on whether they contain defect labels and the category of defect labels. Frequent itemsets for each category are generated based on the support threshold of each candidate itemset. Then, initial association rules with a consequent length of 1 are generated based on the confidence threshold of each category. The initial association rules with a lift greater than 1 are extracted from these and used as atomic association rules.

[0017] Based on further improvements to the above method, using defective and non-defective labels as target nodes respectively, two weighted association rule networks are constructed according to the correlation coefficients of atomic association rules, including:

[0018] Using defective and non-defective labels as target nodes, the consequents are obtained from the atomic association rule set, which contain one or more antecedents of atomic association rules for defective and non-defective labels, respectively. Then, each antecedent is used as a new consequent, and one or more corresponding antecedents are obtained in reverse. This process is repeated layer by layer to construct a reverse hypergraph. The weighted association rule network is obtained by using 1-correlation coefficient as the weight of the hyperedges between nodes.

[0019] Based on the above method, repeated superedges and inverse superedges in the weighted association rule network are pruned. Inverse superedges refer to the relationship where the level of the predecessor of the same association rule from the target node is less than the level of the successor from the target node.

[0020] Based on further improvements to the above method, contradictory node pairs in the weighted association rule network are identified, including: obtaining nodes with the same name but different discretized numerical ranges according to the names of each node in the weighted association rule network, and forming node pairs to be identified in sequence. If there is a reachable path between the node pairs to be identified, they are contradictory node pairs.

[0021] Based on further improvements to the above method, conflicting paths between conflicting node pairs are iteratively removed using the shortest path algorithm, resulting in a pruned weighted association rule network, including:

[0022] For each pair of conflicting nodes, obtain the reachable path between the pair and put it into the conflict path set. Based on the shortest path algorithm, after deleting the edge in the weighted association rule network according to the shortest path in the conflict path set each time, obtain the reachable path between the pair of conflicting nodes again, update the conflict path set, and delete the edge in the weighted association rule network again according to the shortest path until the updated conflict path set is empty, and obtain the pruned weighted association rule network.

[0023] Based on further improvements to the above method, and using two sets of defect prediction rules, the software defect prediction results are obtained according to the correlation coefficients of the defect prediction rules matched with the software defect data to be predicted. These results include:

[0024] Using the correlation coefficient as the prediction index, corresponding defective and non-defective decision-makers are constructed for the two types of defect prediction rule sets respectively. The software defect data to be predicted is matched with the antecedent of each defect prediction rule, and the correlation coefficients of the matched defect prediction rules are accumulated to the corresponding defective or non-defective decision-maker. The software defect prediction result is obtained according to the decision-maker corresponding to the maximum accumulated value.

[0025] On the other hand, embodiments of the present invention provide a software defect prediction system based on atomic association rule networks, comprising:

[0026] The atomic rule acquisition module is used to preprocess historical software defect data into transaction data, and then extract atomic association rules based on the association rule algorithm and lift, to obtain a set of atomic association rules.

[0027] The rule network construction module is used to construct two weighted association rule networks based on the atomic association rule set, with defective labels and non-defective labels as target nodes respectively, according to the correlation coefficient of the atomic association rules.

[0028] The rule network pruning module is used to identify pairs of contradictory nodes in each weighted association rule network; it iteratively deletes contradictory paths between pairs of contradictory nodes based on the shortest path algorithm to obtain the pruned weighted association rule network, and extracts two types of defect prediction rule sets;

[0029] The software defect prediction module is used to obtain software defect prediction results based on two sets of defect prediction rules and the correlation coefficient of the defect prediction rules matched with the software defect data to be predicted.

[0030] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:

[0031] 1. A feature selection strategy based on embedded methods is adopted, which sets different support levels for frequent patterns that include the majority class and the minority class to ensure that frequent patterns of the minority class are not eliminated.

[0032] 2. By constructing an atomic association rule network, only the set of association rules related to the target item is extracted, which greatly reduces the problem of too many association rules caused by high-dimensional data; for the target item, the shortest path is used from a global perspective to eliminate contradictory rules instead of relying on a single indicator, which increases the effectiveness of rule pruning and the understandability of knowledge mining, and improves the prediction accuracy.

[0033] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description

[0034] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.

[0035] Figure 1 This is a flowchart of a software defect prediction method based on atomic association rule network in Embodiment 1 of the present invention;

[0036] Figure 2 This is an example diagram of the hypercyclic structure in the atomic association rule network of Embodiment 1 of the present invention;

[0037] Figure 3 This is an example diagram of inverse and repeated superedges in the atomic association rule network of Embodiment 1 of the present invention;

[0038] Figure 4 This is an example diagram of contradictory paths in the atomic association rule network of Embodiment 1 of the present invention;

[0039] Figure 5 This is a schematic diagram of the structure of a software defect prediction system based on atomic association rule network in Embodiment 2 of the present invention. Detailed Implementation

[0040] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.

[0041] Example 1

[0042] A specific embodiment of the present invention discloses a software defect prediction method based on atomic association rule networks, such as... Figure 1 As shown, it includes the following steps:

[0043] S11. After preprocessing historical software defect data into transaction data, atomic association rules are extracted based on the association rule algorithm and lift, resulting in a set of atomic association rules.

[0044] It should be noted that historical software defect data can be obtained in several ways, including: using existing static code analysis tools to scan each software module based on defined software defect metrics to obtain metric values, and then labeling the actual software module with defects; or directly using public datasets in the open-source software defect domain, such as the software defect dataset of the ANT project in the Promise library. The software defect metrics (i.e., software defect metrics) include: weighted number of methods in a class (wmc), depth of the inheritance tree (dit), number of lines of code (loc), data access metric (dam), number of public methods (npm), class responsiveness (rfc), and number of defects (bug), etc. When the number of defects is greater than 0, the defect label `defects = true` indicates the presence of a defect label; otherwise, the defect label `defects = false` indicates the absence of a defect label. Each piece of software defect data is obtained based on the software metric metadata and defect labels of the same data point.

[0045] Furthermore, the historical software defect data undergoes preprocessing involving data partitioning and discretization to obtain transaction data, including:

[0046] The defect labels in each software defect data point are used as category labels. A hierarchical K-fold cross-validation method is used to construct training and testing sample sets. Each item in each training sample is discretized with equal frequency and placed into a discrete sample set. Transaction data is extracted from the discrete sample set based on Jaccard similarity and similarity threshold.

[0047] It should be noted that, based on defect labels, the software defect data is divided into defective and non-defective subsets, and a stratified sampling strategy is used to reduce the impact of class imbalance on the prediction results. For example, using a stratified 5-fold cross-validation method, each subset is randomly divided into 5 folds, and 4 folds from each subset are used as the training sample set, while 1 fold from each subset is used as the test sample set.

[0048] Data discretization is the process of transforming continuous data into discrete data. Specifically, it involves generating non-overlapping discrete intervals based on the distribution of continuous data, and then mapping these intervals to the discrete data to determine interval labels. Discretizing quantitative features not only reduces the dimensionality of the original features but also positively impacts the performance of the classifier. Since association rule algorithms are based on frequency to generate high-quality rule knowledge, continuous data is not suitable as algorithm input. Therefore, for each software metric in the training sample set, its continuous data is transformed into multiple discrete intervals with equal frequency intervals.

[0049] Preferably, the software metric in each training sample is discretized into five equal-frequency intervals by using the qcut equal-frequency partitioning function in the Python pandas library. This means that the discretized intervals are divided into five equal-frequency intervals and then combined with the defect label to form each discrete sample, which is then placed into the discrete sample set.

[0050] Even after discretizing the original historical software defect data into discrete samples, the association rule algorithm still suffers from inaccurate predictions of defective tendencies due to an excessive amount of data from the non-defective class. Therefore, to enable association rule mining to learn defective and non-defective data more efficiently, similar discrete sample data is eliminated based on Jaccard similarity and a similarity threshold. This results in greater discriminative power between the mined defective and non-defective association rules, thereby further enhancing the model's predictive performance.

[0051] The higher the Jaccard similarity, the more similar two discrete samples from different classes are. Based on the Jaccard similarity and a similarity threshold, transaction data is extracted from the discrete sample set, including:

[0052] The discrete sample set is divided into discrete samples containing defect labels and discrete samples containing no defect labels based on the defect labels. Each discrete sample is taken out in turn, and the Jaccard similarity between the discrete sample and each discrete sample of the other class is calculated. The largest Jaccard similarity is taken as the Jaccard similarity of the discrete sample. Discrete samples with Jaccard similarity less than the similarity threshold are taken out to obtain the transaction data.

[0053] For example, a transaction data is: trans={wmc=(4.0,6.0],dit=(2.0,3.0],noc=(-inf,0.0],cbo={6.2,10.0],…,avg_cc=(0.81,1.0],defects=true}.

[0054] Next, using the software defect metrics and defect labels in the transaction data as items, association rules are extracted based on the association rule algorithm and lift, including:

[0055] The association rule algorithm is used to divide the generated candidate itemsets into three categories based on whether they contain defect labels and the category of defect labels. Frequent itemsets for each category are generated based on the support threshold of each candidate itemset. Then, initial association rules with a consequent length of 1 are generated based on the confidence threshold of each category. The initial association rules with a lift greater than 1 are extracted from these and used as atomic association rules.

[0056] It should be noted that the generated candidate sets are divided into three categories based on whether they contain defect labels and the type of defect labels: candidate sets containing defect labels, candidate sets containing no defect labels, and candidate sets not containing defect labels.

[0057] This embodiment not only focuses on itemsets containing defect labels, but also considers the relationships between software metrics, maintains the distribution of historical software defect data, and adopts a feature selection strategy based on an embedded method. Support thresholds are set for the three types of candidate itemsets respectively, and support is used as the indicator for feature selection and integrated into the rule generation, ensuring the quantity and quality of frequent itemsets of different types.

[0058] For example, the association rule algorithm may employ the Apriori algorithm or the FP-growth algorithm.

[0059] It's important to note that lift indicates the degree of correlation between the antecedent and consequent in an association rule. A lift greater than 1 indicates a positive dependency between the antecedent and consequent, meaning the occurrence of the antecedent is more conducive to the occurrence of the consequent. A lift less than 1 indicates a negative dependency between the antecedent and consequent, meaning the occurrence of the antecedent is less conducive to the occurrence of the consequent. A lift of 1 indicates no dependency between the antecedent and consequent, meaning they are independent. All initial association rules with a lift less than or equal to 1 are removed to ensure that the antecedent and consequent of the remaining initial association rules are positively correlated; that is, positively correlated initial association rules are treated as atomic association rules based on lift.

[0060] Specifically, the lift between the predecessor X and the successor Y is defined as follows:

[0061]

[0062] Where P(XY) represents the probability that the antecedent X and the consequent Y occur simultaneously, P(X) represents the probability that the antecedent X occurs, and P(Y) represents the probability that the consequent Y occurs.

[0063] It is important to note that atomic association rules include association rules without defect labels. These rules establish the association relationships between software metrics and are used for subsequent rule pruning.

[0064] S12. Based on the set of atomic association rules, with defective labels and non-defective labels as target nodes respectively, construct two weighted association rule networks according to the correlation coefficients of the atomic association rules.

[0065] Specifically, with defective labels and non-defective labels as target nodes, one or more antecedents of atomic association rules with defective and non-defective labels are obtained from the atomic association rule set, respectively. Then, each antecedent is used as a new consequent, and one or more corresponding antecedents are obtained in reverse. This process is repeated layer by layer to construct a reverse hypergraph. The weighted association rule network is obtained by using 1-correlation coefficient as the weight of the hyperedges between nodes.

[0066] If the target node's level is set to 0, then starting from the target node and working backwards, the level of each node in each layer increases by 1 from the target node. That is, in each atomic association rule, the level of the consequent is increased by 1 to obtain the level of the antecedent. This embodiment, by constructing an atomic association rule network, extracts only the set of atomic association rules related to the target item, greatly reducing the problem of an excessive number of atomic association rules caused by high-dimensional data.

[0067] Preferably, the two weighted association rule networks are checked for the existence of duplicate hyperedges, inverse hyperedges, and hyperloop structures. An inverse hyperedge is a hyperloop where the level of the antecedent of the same association rule from the target node is less than the level of the consequent from the target node. A hyperloop structure is a closed loop structure in the weighted association rule network. Usually, inverse hyperedges exist in hyperloop structures, but inverse hyperedges do not necessarily lead to hyperloop structures. Therefore, this embodiment prunes duplicate hyperedges and inverse hyperedges to remove these parts that affect inference.

[0068] For example, in Figure 2 In the diagram, G is the target node, and e1e4e5 and e2e4e5 are hypercycle structures. The predecessor node E of e5 has a level of 1, and the successor node B of e5 has a level of 3. e5 is an inverse hyperedge. Removing e5 eliminates the hypercycle structure. Figure 3 In the middle, A is the target node, e6 and e7 are repeated hyperedges, and one of them can be removed randomly; the level of the predecessor node B of e2 is 1, the level of the successor node C of e2 is 2, e2 is an inverse hyperedge, but there is no hyperloop structure at this time, so e2 can be removed.

[0069] It should be noted that the correlation coefficient represents the association relationship between the antecedent and consequent in an association rule, and its value ranges from -1 to 1. For example, the Pearson correlation coefficient between the antecedent and consequent in an association rule is calculated. Since the lift of the atomic association rule obtained in step S11 is greater than 1, the correlation coefficient of each hyperedge in the existing atomic association rule network ranges from [0,1]. The larger the correlation coefficient, the more reliable the atomic association rule. Therefore, 1 minus the correlation coefficient of the atomic association rule is used as the weight of the hyperedge between nodes; the smaller the weight, the more reliable the atomic association rule. The path from each node in the atomic association rule network to the target project node is used as a knowledge reasoning path to represent the reasoning relationship between the two projects. All paths constitute the global reasoning network of the target project.

[0070] S13. For each weighted association rule network, identify the pairs of contradictory nodes in the weighted association rule network; iteratively delete the contradictory paths between the pairs of contradictory nodes based on the shortest path algorithm to obtain the pruned weighted association rule network, and extract two types of defect prediction rule sets.

[0071] It should be noted that weighted association rule networks may contain some erroneous knowledge reasoning paths. For example, a defective node with the label `defects=true` can be reached from a node with the label `defects=false` without defects via a knowledge reasoning path. However, `defects=false` and `defects=true` are clearly mutually exclusive events; a software module cannot be both defective and defect-free simultaneously. The defective node with `defects=true` and the defect-free node with `defects=false` constitute a contradictory node pair.

[0072] Therefore, identifying contradictory node pairs in a weighted association rule network includes: obtaining nodes with the same name but different discretized numerical ranges based on the names of each node in the weighted association rule network, and forming node pairs to be identified in sequence. If there is a reachable path between the node pairs to be identified, then they are contradictory node pairs.

[0073] There may be multiple reachable paths between each pair of conflicting nodes. If a one-size-fits-all approach is adopted to remove all reachable paths between all pairs of conflicting nodes, some valid rules will be lost. Therefore, the key is to delete paths reasonably.

[0074] Since the weight of the hyperedge is set to 1 - the correlation coefficient in step S12, the shorter the path between conflicting node pairs, the easier it is to generate a conflict. At this time, the problem of deleting conflicting paths is cleverly transformed into the shortest path problem.

[0075] Specifically, by iteratively deleting conflicting paths between conflicting node pairs using the shortest path algorithm, a pruned weighted association rule network is obtained, including:

[0076] For each pair of conflicting nodes, obtain the reachable path between the pair and put it into the conflict path set. Based on the shortest path algorithm, after deleting the edge in the weighted association rule network according to the shortest path in the conflict path set each time, obtain the reachable path between the pair of conflicting nodes again, update the conflict path set, and delete the edge in the weighted association rule network again according to the shortest path until the updated conflict path set is empty, and obtain the pruned weighted association rule network.

[0077] It should be noted that, based on the shortest path algorithm, each time edges in the weighted association rule network are deleted according to the shortest path in the set of conflicting paths, the following steps are taken:

[0078] If the number of conflicting paths in the conflicting path set is 1, then it is directly used as the shortest path to be deleted, and the edges on the shortest path are deleted from the weighted association rule network. Otherwise, starting from the starting node, the neighboring node with the smallest super-edge weight is selected from the conflicting path set, and the conflicting paths containing the unselected neighboring nodes are removed from the conflicting path set. When the number of remaining conflicting paths is greater than 1, the selected neighboring node is used as the new starting node, and the neighboring node with the smallest super-edge weight is selected from the remaining conflicting paths, and the conflicting paths containing the unselected neighboring nodes are removed, until only one conflicting path remains. This conflicting path is the shortest path to be deleted, and the edges on the shortest path are deleted from the weighted association rule network.

[0079] For example, in a weighted association rule network with defective labels as target nodes, there exist contradictory node pairs where defective labels have `defects=true` and non-defective labels have `defects=false`, such as... Figure 4 As shown, there are 4 reachable paths between this pair of conflicting nodes, which are added to the set of conflicting paths:

[0080] ①defects=false→loc=(-inf,1.0](edge ​​weight: 0.65);

[0081] loc = (-inf, 1.0] → dam = (0.0, 1.05] (edge ​​weight: 0.40);

[0082] dam = (0.0, 1.05] → defects = true (edge ​​weight: 0.55).

[0083] ②defects=false→loc=(-inf,1.0](edge ​​weight: 0.65);

[0084] loc = (-inf, 1.0] → rfc = (1.0, 2.0] (edge ​​weight: 0.75);

[0085] rfc = (1.0, 2.0] → defects = true (edge ​​weight: 0.27).

[0086] ③defects=false→npm=(-inf,1.0](edge ​​weight: 0.85);

[0087] npm = (-inf, 1.0] → rfc = (1.0, 2.0] (edge ​​weight: 0.48);

[0088] rfc = (1.0, 2.0] → defects = true (edge ​​weight: 0.27).

[0089] ④defects=false→npm=(-inf,1.0](edge ​​weight: 0.85);

[0090] npm = (-inf, 1.0] → dam = (0.0, 1.05] (edge ​​weight: 0.50);

[0091] dam = (0.0, 1.05] → defects = true (edge ​​weight: 0.55).

[0092] In the first pruning process, the node with defects = false is the starting node. Its candidate adjacent nodes (next nodes) include loc = (-inf, 1.0] in paths ① and ② and npm = (-inf, 1.0] in paths ③ and ④, with hyperedge weights of 0.65 and 0.85 respectively. The edge with the smallest hyperedge weight is selected, so paths ③ and ④ are removed from the contradictory path set, leaving paths ① and ②, which are then further identified. loc = (-inf, 1.0] is taken as the new starting node. In paths ① and ②, its candidate adjacent nodes include dam = (0.0, 1.05] in path ① and r in path ②. Given fc = (1.0, 2.0] and hyperedge weights of 0.40 and 0.75 respectively, as mentioned above, dam = (0.0, 1.05] is selected. Therefore, path ② is removed from the conflicting path set, leaving path ① as the shortest path to be deleted. The three hyperedges of path ① are then deleted from the association rule network. After deletion, reachable paths between conflicting node pairs are retrieved again. Path ③ still exists and is added to the conflicting path set. During the second pruning process, the three hyperedges of path ③ are directly deleted. After deletion, reachable paths between conflicting node pairs are retrieved again. The reachable paths are empty, completing the pruning of conflicting paths between these node pairs.

[0093] After pruning, the above four paths still retain loc=(-inf,1.0]→rfc=(1.0,2.0] in path ② and npm=(-inf,1.0]→dam=(0.0,1.05) in path ④. Compared with the prior art, the pruning method of this embodiment avoids unreasonable knowledge reasoning paths and maximizes the retention of effective reasoning rules, thereby improving the accuracy of prediction.

[0094] For example, the shortest path algorithm uses Dijkstra's algorithm.

[0095] Based on the two weighted association rule networks after pruning, the antecedent and consequent of each hyperedge are extracted as a prediction rule according to the defect label category of the target node, resulting in a set of prediction rules for each type of defect: a set of prediction rules for predicting defective tendencies and a set of prediction rules for predicting non-defective tendencies.

[0096] It should be noted that steps S11-S13 in this embodiment involve obtaining two sets of defect prediction rules using a single layered 5-fold cross-validation method. Preferably, a 10-fold layered 5-fold cross-validation method is used to enhance the reliability of the prediction results. That is, the method is repeated 10 times, obtaining a set of prediction rules based on the training sample set constructed each time, obtaining the prediction results based on the constructed test sample set, and calculating classification performance indicators, such as Balance, MCC, and G-means. Finally, the set of two defect prediction rules with the best classification performance indicators from the 10 iterations is used for software defect prediction, and the average of the 10 classification performance indicators is taken as the final classification performance indicator.

[0097] S14. Based on the two sets of defect prediction rules, the software defect prediction result is obtained according to the correlation coefficient of the defect prediction rules matched with the software defect data to be predicted.

[0098] It should be noted that corresponding defective and non-defective decision-makers are constructed for the two types of defect prediction rule sets respectively, resulting in defect predictors. During the prediction phase, software defect data to be predicted is acquired, including software metric metadata of the software modules to be predicted.

[0099] During prediction, the correlation coefficient is used as the prediction indicator. The software defect data to be predicted is matched with the antecedent of each defect prediction rule. The correlation coefficients of the matched defect prediction rules are accumulated and added to the corresponding defective or defect-free decision-maker. The software defect prediction result is obtained based on the decision-maker corresponding to the largest accumulated value. In other words, the final judgment is which decision-maker has the largest accumulated correlation coefficient. If the decision-maker with the largest accumulated correlation coefficient has the largest value, the prediction result is defective; otherwise, the prediction result is defect-free.

[0100] It should be noted that if the metadata of each software metric in the software defect data to be predicted is within the discrete interval of each antecedent of the prediction rule, it is considered a match.

[0101] Compared with existing technologies, this embodiment provides a software defect prediction method based on atomic association rule networks. It employs an embedded feature selection strategy, setting different support levels for frequent patterns involving both majority and minority classes to ensure that frequent minority patterns are not eliminated. By constructing an atomic association rule network, it extracts only the set of association rules related to the target item, significantly reducing the problem of an excessive number of association rules caused by high-dimensional data. Furthermore, it uses the shortest path to eliminate contradictory rules from a global perspective rather than relying on a single indicator, increasing the effectiveness of rule pruning and the understandability of knowledge mining, thereby improving prediction accuracy.

[0102] Example 2

[0103] Another embodiment of the present invention discloses a software defect prediction system based on atomic association rule networks, thereby implementing the software defect prediction method based on atomic association rule networks in Embodiment 1. The specific implementation of each module is described in the corresponding description in Embodiment 1. Figure 5 As shown, the system includes:

[0104] The atomic rule acquisition module 101 is used to preprocess historical software defect data into transaction data, and then extract atomic association rules based on the association rule algorithm and lift degree to obtain a set of atomic association rules.

[0105] The rule network construction module 102 is used to construct two weighted association rule networks based on the atomic association rule set, with defective labels and non-defective labels as target nodes respectively, according to the correlation coefficient of the atomic association rules.

[0106] The rule network pruning module 103 is used to identify contradictory node pairs in each weighted association rule network; iteratively delete contradictory paths between contradictory node pairs based on the shortest path algorithm to obtain the pruned weighted association rule network, and extract two types of defect prediction rule sets.

[0107] The software defect prediction module 104 is used to obtain the software defect prediction result based on the correlation coefficient of the defect prediction rules matched with the software defect data to be predicted, based on two sets of defect prediction rules.

[0108] Since this embodiment and the aforementioned software defect prediction method based on atomic association rule networks are related and can be mutually referenced, and are therefore described repeatedly here, they will not be repeated. Because this system embodiment shares the same principle as the above method embodiment, it also possesses the corresponding technical effects of the above method embodiment.

[0109] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.

[0110] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A software defect prediction method based on atomic association rule networks, characterized in that, Includes the following steps: After preprocessing historical software defect data into transaction data, atomic association rules are extracted based on association rule algorithms and lift, resulting in a set of atomic association rules. The preprocessing of historical software defect data into transaction data includes: using the defect label in each historical software defect data entry as a category label, and employing hierarchical K-fold cross-validation to construct a training sample set and a test sample set; discretizing each item in each training sample using equal frequency and placing it into a discrete sample set; extracting transaction data from the discrete sample set based on Jaccard similarity and a similarity threshold, including: dividing the discrete sample set into discrete samples containing defect labels and discrete samples containing no defect labels based on the defect labels; sequentially extracting each discrete sample and calculating... Calculate the Jaccard similarity between the discrete sample and each discrete sample of another class, and take the largest Jaccard similarity as the Jaccard similarity of the discrete sample; extract the discrete samples with Jaccard similarity less than the similarity threshold to obtain transaction data; the step of extracting atomic association rules according to the association rule algorithm and lift includes: using the association rule algorithm, dividing the generated candidate itemsets into three classes according to whether they contain defect labels and the category of defect labels, generating frequent itemsets for each class according to the support threshold of each class of candidate itemsets, and then generating initial association rules with a consequent length of 1 according to the confidence threshold of each class, and extracting initial association rules with a lift greater than 1 from them as atomic association rules; Based on the set of atomic association rules, two weighted association rule networks are constructed with defective labels and non-defective labels as target nodes, respectively, according to the correlation coefficient of the atomic association rules. For each weighted association rule network, contradictory node pairs in the network are identified; contradictory paths between contradictory node pairs are iteratively deleted based on the shortest path algorithm to obtain the pruned weighted association rule network, and two types of defect prediction rule sets are extracted. Based on two sets of defect prediction rules, the software defect prediction results are obtained by matching the defect prediction rules with the software defect data to be predicted.

2. The software defect prediction method based on atomic association rule network according to claim 1, characterized in that, The process involves constructing two weighted association rule networks, one with defective labels and the other without, as target nodes, based on the correlation coefficients of atomic association rules. The network includes: Using defective and non-defective labels as target nodes, the consequents are obtained from the atomic association rule set, which contain one or more antecedents of atomic association rules for defective and non-defective labels, respectively. Then, each antecedent is used as a new consequent, and one or more corresponding antecedents are obtained in reverse. This process is repeated layer by layer to construct a reverse hypergraph. The weighted association rule network is obtained by using 1-correlation coefficient as the weight of the hyperedges between nodes.

3. The software defect prediction method based on atomic association rule network according to claim 2, characterized in that, Prune duplicate and inverse superedges in the weighted association rule network. An inverse superedge is defined as an association rule whose predecessor is less far from the target node than its successor.

4. The software defect prediction method based on atomic association rule network according to claim 1, characterized in that, The identification of contradictory node pairs in the weighted association rule network includes: obtaining nodes with the same name but different discretized numerical ranges based on the names of each node in the weighted association rule network, and forming node pairs to be identified in sequence. If there is a reachable path between the node pairs to be identified, they are contradictory node pairs.

5. The software defect prediction method based on atomic association rule network according to claim 4, characterized in that, The method of iteratively deleting conflicting paths between conflicting node pairs based on the shortest path algorithm to obtain a pruned weighted association rule network includes: For each pair of conflicting nodes, obtain the reachable path between the pair and put it into the conflict path set. Based on the shortest path algorithm, after deleting the edge in the weighted association rule network according to the shortest path in the conflict path set each time, obtain the reachable path between the pair of conflicting nodes again, update the conflict path set, and delete the edge in the weighted association rule network again according to the shortest path until the updated conflict path set is empty, and obtain the pruned weighted association rule network.

6. The software defect prediction method based on atomic association rule network according to claim 1, characterized in that, The method, based on two sets of defect prediction rules, obtains software defect prediction results according to the correlation coefficients of the defect prediction rules matched with the software defect data to be predicted, including: Using the correlation coefficient as the prediction index, corresponding defective and non-defective decision-makers are constructed for the two types of defect prediction rule sets respectively. The software defect data to be predicted is matched with the antecedent of each defect prediction rule, and the correlation coefficients of the matched defect prediction rules are accumulated to the corresponding defective or non-defective decision-maker. The software defect prediction result is obtained according to the decision-maker corresponding to the maximum accumulated value.

7. A software defect prediction system based on atomic association rule networks, characterized in that, include: The atomic rule acquisition module is used to preprocess historical software defect data into transaction data, and then extract atomic association rules based on association rule algorithms and lift, to obtain a set of atomic association rules. The preprocessing of historical software defect data into transaction data includes: using the defect label in each historical software defect data entry as a category label, and constructing a training sample set and a test sample set using a hierarchical K-fold cross-validation method; discretizing each item in each training sample by equal frequency and placing it into a discrete sample set; extracting transaction data from the discrete sample set based on Jaccard similarity and a similarity threshold, including: dividing the discrete sample set into discrete samples containing defect labels and discrete samples containing no defect labels based on the defect labels; and sequentially extracting each discrete... For each discrete sample, the Jaccard similarity between the discrete sample and each discrete sample of another class is calculated, and the largest Jaccard similarity is taken as the Jaccard similarity of the discrete sample. Discrete samples with Jaccard similarity less than the similarity threshold are extracted to obtain transaction data. The step of extracting atomic association rules based on association rule algorithm and lift includes: using association rule algorithm, dividing the generated candidate itemsets into three classes according to whether they contain defect labels and the category of defect labels, generating frequent itemsets for each class according to the support threshold of each class candidate itemsets, and generating initial association rules with a consequent length of 1 according to the confidence threshold of each class, and extracting initial association rules with a lift greater than 1 from them as atomic association rules. The rule network construction module is used to construct two weighted association rule networks based on the atomic association rule set, with defective labels and non-defective labels as target nodes respectively, according to the correlation coefficient of the atomic association rules. The rule network pruning module is used to identify pairs of contradictory nodes in each weighted association rule network; it iteratively deletes contradictory paths between pairs of contradictory nodes based on the shortest path algorithm to obtain the pruned weighted association rule network, and extracts two types of defect prediction rule sets. The software defect prediction module is used to obtain software defect prediction results based on two sets of defect prediction rules and the correlation coefficient of the defect prediction rules matched with the software defect data to be predicted.