A software defect locating method based on feature intersection and KAN network
By combining feature crossover and KAN networks, the curse of dimensionality problem in high-dimensional space is solved, enabling fast and accurate software defect localization, which is suitable for critical business applications.
Patent Information
- Application Number
- CN202411694537.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-11-25
AI Technical Summary
Existing feature cross-network methods suffer from the curse of dimensionality in high-dimensional spaces, making it difficult to accurately capture and adapt to changes in complex functions. Furthermore, some methods are insufficient in terms of computational resources and time costs to meet the needs of critical business applications.
We employ a method based on feature crossover and KAN networks. By mining feature relationships through crossover layers and using the parameterized nonlinear activation function of the KAN network for learning, we overcome the curse of dimensionality. We also combine L1 regularization and pruning techniques to optimize the model and improve defect localization performance.
It can accurately capture complex high-order feature interaction information for defect localization in high-dimensional space, and achieve fast and efficient defect localization, which is suitable for time-critical business application scenarios.
Smart Images

Figure CN119576742B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data analysis, relates to software defect location, and specifically relates to a software defect location method based on feature intersection and KAN network. Background Art
[0002] Defects are inevitable during software development. As software scale and complexity increase, their frequency and impact also increase. Software defects can lead to a range of issues, including system crashes, data loss, and security vulnerabilities. These issues not only impact user experience but can also cause serious security issues in critical business scenarios. Therefore, timely and accurate identification and repair of software defects are crucial for ensuring software quality and system stability.
[0003] To address this challenge, researchers have proposed various defect localization methods. Among them, information retrieval-based defect localization techniques have achieved some success. The core idea of this technique is to quantify the similarity between defect reports and source code, sorting them based on similarity metrics to identify the files most likely to contain defects. Furthermore, some researchers have also explored structural semantic features in defect reports and source code to assist in defect localization. By combining data features with structural semantic features to calculate similarity, they improve localization effectiveness.
[0004] To better capture the interactions and complex relationships between different features, feature crossover networks are applied to defect localization. These models capture nonlinear relationships by constructing combinations of multiple features. Their core concept is to cross multidimensional features to generate higher-order features and thus obtain more contextual information. Multilayer perceptron (MLP)-based feature crossover networks have demonstrated excellent results in practical applications because they can automatically learn nonlinear interactions between features, eliminating the need for manual design of complex feature crossovers. This approach leverages the powerful learning capabilities of neural networks to establish high-order nonlinear relationships between different features, thereby improving model performance.
[0005] However, existing feature cross-network methods still have some significant problems. First, using multi-layer perceptrons as feature cross-networks suffers from the curse of dimensionality problem, that is, in high-dimensional space, the sparsity of data and the processing complexity increase dramatically. This makes it impossible to accurately capture and adapt to the changes of complex functions in high-dimensional space, and it is difficult to capture the complex high-order feature interaction information used in defect localization. In addition, some advanced methods rely on mining the structural semantics of defect reports and source code, code graph structure, etc., which requires a lot of computing resources and time costs. It is difficult to apply to software systems that require high reliability and fast response, such as financial systems and online servers. Therefore, how to quickly and accurately locate defects with a small amount of information is also one of the key issues that need to be solved urgently. Summary of the Invention
[0006] In response to the shortcomings of the existing technology, the present invention proposes a software defect localization method based on feature cross-correlation and KAN network. Different features are cross-correlated through the cross layer to explore the hidden relationships between features. The nonlinear activation function parameterized by the KAN network is further used for learning to overcome the dimensionality curse problem and improve the performance of defect localization.
[0007] A software defect localization method based on feature intersection and KAN network specifically includes the following steps:
[0008] Step 1: Obtain the original defect report b and source code file s, perform preprocessing, and obtain the training dataset.
[0009] Step 2: Extract the features of each sample in the training dataset, including VSM similarity rVSM(b,s), collaborative filtering score cf(b,s), stack trace score tr(b,s), cyclomatic complexity cc(s), repair frequency ff(b,s), and repair time interval fr(b,s), perform vectorization processing and splicing to obtain the feature vector of the source code file s. .
[0010] Step 3: Based on feature intersection and KAN network, calculate the similarity score between the bug report b and the source code file s:
[0011] s3.1、The feature vector of the sample Input into the continuous N-layer cross layer, perform feature cross-pollination on different features in the vector, and explore the hidden relationship between features. The output of the n+1th cross layer is for:
[0012]
[0013] in, , = , Represents the output of the nth cross layer. 、 are the weight matrix and bias vector of the n+1th cross layer, represents the Hadamard product.
[0014] s3.2, the output of the last cross layer As the input of the KAN network , the objective function is fitted by learning the parameterized nonlinear activation function, and L1 regularization is used to sparsify the weights of the KAN network, and pruning is performed according to the sparsification results.
[0015] s3.3、The output of KAN network Input into the fully connected layer to obtain the final similarity score between the defect report b and the source code file s :
[0016]
[0017] in is the weight matrix of the fully connected layer, is the bias term.
[0018] Step 4: The final similarity score calculated according to step 3 Sort the source code files from large to small. The higher the ranking, the greater the possibility that the source code file contains defects.
[0019] Compared with the prior art, the present invention has the following beneficial effects:
[0020] 1. Use the KAN network to obtain high-order feature interaction information. Based on the Kolmogorov-Arnold representation theorem, the process of fitting polynomial functions in the feature cross network is converted into the process of fitting multiple one-dimensional functions. By changing the fixed nonlinear activation function and linear parameter learning to the direct learning of the parameterized nonlinear activation function, the dimensionality curse problem is overcome. It can more accurately capture and adapt to the changes of complex functions, better capture the complex high-order feature interaction information in defect localization, and thus improve the performance of defect localization.
[0021] 2. Using only data features can achieve results similar to or better than existing technologies. This means that this method can accurately and quickly locate defects with a small amount of information, which is especially suitable for critical business application scenarios with strict time requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 Schematic diagram of software defect localization method based on feature intersection and KAN;
[0023] Figure 2 Schematic diagram of the cross-layer structure;
[0024] Figure 3 This is a schematic diagram of the KAN network structure;
[0025] Figure 4 Schematic diagram of the KAN network structure after sparsification and pruning. DETAILED DESCRIPTION
[0026] The present invention will be further explained below with reference to the accompanying drawings;
[0027] like Figure 1 As shown in FIG, a software defect localization method based on feature intersection and KAN specifically includes the following steps:
[0028] Step 1: This example uses the tomcat dataset as the original defect report b and source code file s. First, preprocessing is performed, including text normalization, stop word removal, and stemming, to obtain a training dataset:
[0029] s1.1. Text standardization: Process all characters in the text to make it uniform in format and simplified in content, including converting all uppercase letters in the text to lowercase, removing punctuation marks in the text, removing or replacing non-alphabetic characters, and expanding abbreviations.
[0030] s1.2. Remove stop words: Remove common words that are considered useless for analysis in text processing, such as "the", "is", and "in", to reduce redundant information and retain words that have a greater impact on semantics.
[0031] s1.3, Stemming: Reduce words to their basic stem form, removing affixes such as "-ing" and "-ed", so that words with the same root are considered the same word.
[0032] Step 2: Extract the features of each sample in the training dataset, including VSM similarity rVSM(b,s), collaborative filtering score cf(b,s), stack trace score tr(b,s), cyclomatic complexity cc(s), repair frequency ff(b,s), and repair time interval fr(b,s), perform vectorization processing and splicing to obtain the feature vector of the sample. :
[0033] s2.1. VSM similarity rVSM(b,s): used to measure the text similarity between the bug report b and the source code file s. Term Frequency-Inverse Document Frequency (TF-IDF) is used to convert the text into vectors, and then the cosine similarity in the vector space is calculated:
[0034]
[0035] in and are the vector representations of bug reports and source code files, respectively.
[0036] s2.2, collaborative filtering score cf(b,s): used to measure the text of the bug report b and all report summaries related to the source code file s before the bug report b Similarity:
[0037]
[0038] s2.3. Stack trace score tr(b,s): This score is used to assess the correlation between the stack trace information in defect report b and the source code file s. The stack trace records the chain of functions and methods called when the program crashed. Stack frames are typically recorded in a specific format, such as: at package_name.class_name.method_name (file_name.java:line_number | Native Method | Unknown Source), where file_name.java represents the file name and line number where the defect occurred. These file names are checked against the project's file name, and stack frames that do not belong to the project code base are deleted. This can filter out incorrect file names and stack frames from external third-party libraries. Native Method represents methods implemented by the JVM. Such methods do not belong to the source files that need to be located and can therefore be directly filtered out. Unknown Source represents source files that lack debugging information. Since public class names and source file names in Java are the same, the class name can be checked from the left side of the stack frame to see if it matches the project file name. If a match is found, the class name is used as the file name for the Unknown Source stack frame. After extracting and processing the stack frame information through regular expressions, the ranking of each source code file in the stack trace is scored. The ranking of the source code file s in the stack trace The closer it is to the front, the more likely it is to contain a defect and the higher the score should be:
[0039]
[0040] s2.4. Cyclomatic complexity cc(s): This indicates the number of different execution paths caused by control flow statements in the source code file s. It is an indicator of code complexity and quality. The higher the cyclomatic complexity cc(s), the greater the logical complexity of the code and the higher the potential defect risk.
[0041]
[0042] Where E is the number of edges in the code, representing the connections between different code blocks in the control flow graph, and N is the number of nodes, representing independent code blocks or branch points in the code.
[0043] s2.5, Repair frequency ff(b,s): indicates the number of times the source code file s was repaired before the current defect report b was processed , the more times it is repaired, the more likely the file is to have problems. Therefore, the repair frequency can be used as a reference to measure whether the source file is likely to contain defects again:
[0044]
[0045] s2.6, Repair interval fr(b,s): This represents the reciprocal of the time between the current defect report b and the last repair of the source code file s. A shorter time interval means that the source file has been repaired recently and may still contain defects. Therefore, a longer reciprocal of the repair interval indicates a greater likelihood that the source file will have problems again.
[0046]
[0047] in Indicates the submission time of defect report b, Indicates the time when the source code file s was last repaired.
[0048] s2.7. Concatenate the features calculated from s2.1 to s2.6 to obtain the feature vector of the source code file s. :
[0049]
[0050] Step 3: Based on feature intersection and KAN network, calculate the similarity score between the bug report b and the source code file s:
[0051] s3.1、such as Figure 2 As shown, the feature vector of the sample Input into the continuous N-layer cross layer, perform feature cross-pollination on different features in the vector, and explore the hidden relationship between features. The output of the n+1th cross layer is for:
[0052]
[0053] in, , = , Represents the output of the nth cross layer Represents the Hadamard product, which is the multiplication of elements in corresponding positions in two matrices. 、 are the weight matrix and bias vector of the n+1th cross layer, Initially set to zero, Use Xavier normal initialization:
[0054]
[0055] in, is the number of input units, that is, the dimension of the input received by the current layer, is the number of output units, that is, the dimension of the output of the current layer.
[0056] s3.2, such as Figure 3 As shown, the output of the last cross layer is As the input of the KAN network, the target function is fitted by learning the parameterized nonlinear activation function to capture high-order feature interaction information.
[0057] The KAN network includes M KAN layers, each of which is defined as a set of one-dimensional function matrices. The input dimension is , the output dimension is , , , . Each They are all trainable one-dimensional functions, parameterized by using B-spline curves, and each B-spline curve has learnable parameters. In the m+1th layer, the activation value of the i-th neuron is is the activation value of all neurons in the previous layer The sum calculated by the activation function:
[0058]
[0059] Then the output of the m+1th KAN layer is for:
[0060]
[0061] Finally, the outputs of all KAN layers are combined as the final output of the KAN network :
[0062]
[0063] By constructing a multi-layer B-spline function network to approximate complex functions, although it will increase the depth and complexity of the network, the KAN network can approximate high-dimensional functions through meticulous grid division without being affected by the curse of dimensionality.
[0064] In order to reduce the storage requirements and computational burden of the model, L1 regularization is used to promote the sparsity of the weights of the KAN network, push the weight values to shrink towards zero, improve the generalization ability of the model, and reduce the risk of overfitting. After sparsification, pruning technology is further used to remove unnecessary connections and neurons, that is, positions with zero weights, such as Figure 4 As shown in the figure, the KAN network can overcome the dimensionality curse problem in high-dimensional space, more accurately capture and adapt to the changes of complex functions, and better capture the complex high-order feature interaction information in defect localization.
[0065] s3.3、The output of KAN network Input into the fully connected layer to obtain the final similarity score between the defect report b and the source code file s :
[0066]
[0067] in is the weight matrix of the fully connected layer, is the bias term.
[0068] Step 4: The final similarity score calculated according to step 3 Sort the source code files from large to small. The higher the ranking, the greater the possibility that the source code file contains defects.
[0069] In order to verify the effectiveness of this method, we selected convolutional neural networks (CNN) and feature cross networks (DCN and ResNet) that have excellent performance in the field of feature cross-pollination to conduct comparative experiments with this method on the tomcat dataset. Top-N, MAP, and MRR were selected as evaluation indicators for the experimental results. Top-N represents the proportion of defective files that the model can correctly predict to be ranked in the top N in the defect localization task. The higher the proportion, the better the model effect. MAP represents the average accuracy of the model in prediction, reflecting the accuracy of the model in the entire ranking list. MRR represents the reciprocal average ranking of the first related file predicted by the model on the test set, reflecting the accuracy of the model in locating the most likely defective file. The results are shown in Table 1:
[0070] Table 1
[0071]
[0072] The results show that DCN and ResNet perform significantly better than CNN in terms of Top-N, MAP, and MRR, demonstrating that feature-crossing networks can significantly improve defect localization. Compared to DCN and ResNet, two typical feature-crossing defect localization methods, this method further improves on all metrics, demonstrating that it can more accurately capture and adapt to the changing nature of complex functions in high-dimensional space, thereby finding relevant defect files more accurately and quickly.
[0073] We also compared this method with methods that use different features for defect localization on the Tomcat dataset. The results are shown in Table 2. LR and BRTracer only use data features, while LR+WR, DeepLoc, DreamLoc, and BugRadar additionally use structural semantic features.
[0074] Table 2
[0075]
[0076] Experiments show that this method performs well in defect localization, outperforming most existing methods. Furthermore, compared with the best-performing DreamLoc, the iterative training time for both methods is shown in Table 3:
[0077] Table 3
[0078] method Training time per iteration (min) DreamLoc 21 Methods 1.7
[0079] Because this method uses only data features, while DreamLoc also calculates the structural semantic relevance between the defect report and the source code, its localization time is significantly increased. Therefore, compared with DreamLoc, this method has similar localization performance, but has a significant advantage in computational efficiency. It can accurately and quickly locate defects with a small amount of information, making it particularly suitable for time-sensitive critical business applications.
Claims
1. A software defect localization method based on feature intersection and KAN, characterized by: The specific steps include: Step 1: Obtain the original defect report b and source code file s, perform preprocessing, and obtain the training dataset; Step 2: Extract multiple data features of each sample in the training dataset, perform vectorization processing and splicing to obtain the feature vector feature(b,s) of the source code file s; the data features of the sample include VSM similarity rVSM(b,s), collaborative filtering score cf(b,s), stack trace score tr(b,s), cyclomatic complexity cc(s), repair frequency ff(b,s), and repair time interval fr(b,s); s2.1, VSM similarity in and are the vector representations of bug reports and source code files, respectively; s2.2, collaborative filtering score cf(b,s) = rVSM(b,before(b,s)), where before(b,s) represents the summaries of all reports related to source code file s before the bug report b; s2.3, stack trace score Where stack trace represents stack trace information, rank s Indicates the rank of source code file s in the stack trace; s2.4, cyclomatic complexity cc(s) = E - N + 2, where E is the number of edges in the code and N is the number of nodes; s2.5, repair frequency ff(b,s) = |before(b,s)|, |before(b,s)| represents the number of times the source code file s was repaired before the current defect report b was processed; s2.6, Repair time interval Where b.month represents the submission time of the defect report b, and last(b,s) represents the time when the source code file s was last fixed; Step 3: Input the sample’s feature vector feature(b,s) into N consecutive cross layers, and then input the output x of the last cross layer into N As the input of the KAN network, crossScore(b,s) is used. Finally, the output of the KAN network is input into the fully connected layer to obtain the final similarity score fc between the defect report b and the source code file s. The cross layer includes N layers, which are used to perform feature cross-pollination on different features in the feature vector feature(b,s) to explore the hidden relationship between the features. The output x of the n+1th cross layer is n+1 for: x n+1 =x0⊙(W n x n +b n )+x n Where n = 0, 1, ..., N-1, x0 = feature (b, s), x n Represents the output of the nth cross layer; W n 、b n are the weight matrix and bias vector of the n+1th cross layer, and ⊙ represents the Hadamard product; The KAN network includes M KAN layers, each of which is defined as a set of one-dimensional function matrices. The input dimension is d in , the output dimension is d out , m=1,2...,M, j=1,2,...,d in , i=1,2,…,d out ; each are all trainable one-dimensional functions; in the m+1th layer, the activation value y of the i-th neuron m+1,i is the activation value y of all neurons in the previous layer m,j The sum calculated by the activation function: The output y of the m+1th KAN layer m+1 for: The outputs of all KAN layers are combined as the final output of the KAN network KAN(b,s): in is the weight matrix of the fully connected layer, bias fc is the bias term; Step 4: Sort the source code files from large to small according to the final similarity scores fc calculated in step 3. The higher the ranking, the greater the possibility that the source code file contains defects.
2. The software defect localization method based on feature intersection and KAN as claimed in claim 1, characterized in that: The preprocessing in step 1 includes text normalization, stop word removal, and stemming.
3. The software defect localization method based on feature intersection and KAN as claimed in claim 1, characterized in that: The feature vector of source code file s is feature(b,s)=[rVSM(b,s),cf(b,s),tr(b,s),cc(s),ff(b,s),fr(b,s)].
4. The software defect localization method based on feature intersection and KAN as claimed in claim 1, characterized in that: b n Initially set to zero, W n Use Xavier normal initialization: Among them, dense in is the number of input units, that is, the dimension of the input received by the current layer, dense out is the number of output units, that is, the dimension of the output of the current layer.
5. The software defect localization method based on feature intersection and KAN according to claim 1, characterized in that: L1 regularization is used to sparse the weights of the KAN network, pushing the weight values to shrink towards zero, and then pruning techniques are used to remove connections or neurons with zero weight.
Citation Information
Patent Citations
Software defect positioning method based on deep neural network
CN110109835A
Software defect positioning method combining sentence embedding and particle swarm optimization algorithm
CN112286799A