Defect prediction method and system based on hypergraph neural network

CN117667730BActive Publication Date: 2026-08-21HUBEI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311709450.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-13
Publication Date
2026-08-21
Estimated Expiration
2043-12-13

AI Technical Summary

Technical Problem

然而,在另一些研究工作中表明,网络度量并不比代码度量更有优势,不具有普遍性

Benefits of technology

[0036]1.综合考虑结构特征和语义特征:该方法不仅考虑了软件系统的结构特征,还结合了语义特征,能够更全面地描述软件系统的特性,提高了缺陷预测的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117667730B_ABST
    Figure CN117667730B_ABST
Patent Text Reader

Abstract

The application discloses a defect prediction method and system based on a hypergraph neural network, and comprises the following steps: network modeling is performed on a software system, a network embedding model is used to obtain structural features of the software system, and a hypergraph is generated from the structural features by using a network-based method; an abstract syntax tree is constructed for a software system source code file, a convolutional neural network is used for modeling to obtain semantic features of the software system, and a hypergraph is constructed from the semantic features by using a nearest neighbor-based method; a hypergraph convolution model is applied to model the hypergraph constructed based on the network and the hypergraph constructed based on the nearest neighbor respectively, the obtained features are combined, and finally, the mixed features are used for defect prediction. The application has the advantages that the accuracy and robustness of defect prediction are improved, hypergraph data can be better processed, and the comprehensive description and modeling capability of software system features are improved.
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 in software engineering, and in particular to a defect prediction method and system based on hypergraph neural networks. Background Technology

[0002] As software scales and complexity increases, software quality has become a major concern. Software defects, the antithesis of software quality, threaten it. Therefore, identifying defective modules early in software development is a crucial problem. Software defect prediction technology utilizes the metric metadata of software modules to proactively identify and pinpoint defective modules during development, enabling the rational allocation of limited resources and ensuring software quality.

[0003] In earlier work, some researchers summarized relevant research on defect prediction from different perspectives, focusing on static defect prediction methods. Traditional defect prediction involves manually defining a series of source code metrics as code features, and then training a prediction model using typical machine learning algorithms, such as SVM, Logistic Regression, or Decision Trees. However, traditional hand-designed features can only capture a portion of the information in the source code. To more comprehensively mine the semantic and syntactic information in the source code, researchers have begun to treat software source code as a sequence of text similar to those in natural language processing. For example, they introduced neural network models based on abstract syntax trees, which can effectively model the source code while preserving the structural information of the program.

[0004] However, the semantic features extracted by abstract syntax trees can only capture the semantic information within the program, rarely considering the interaction information of other elements. To comprehensively consider the influence of other elements, distance in the feature space is used to obtain information about nearby elements. For example, nearest neighbors and clustering. Furthermore, the captured information about nearby elements and the information about the element itself are connected by a hyperedge, forming a hypergraph neural network.

[0005] The drawback of relying on distances in feature space to obtain information about nearby elements is that without an actual edge, the information about other elements obtainable is incomplete. In recent years, network-based analysis has treated modules as nodes and extracted the dependencies between modules as edges, constructing a software source code network. To consider information from higher-order nodes in the network, a hyperedge connects the first-order neighbors and higher-order neighbors of the target node, forming a hypergraph neural network. The edges in the software source code network are constructed based on the dependencies between modules, and the information contained therein cannot be captured in the feature space.

[0006] In software engineering, embedding learning models used to process network structure data include Deepwalk, Node2Vec, and Struc2Vec. Their principle is to transform the network structure into a series of node sequences and then use word vector models to learn node representations. Hypergraph convolutional models in deep learning can also capture network structure features. The idea is to utilize node-edge-node transformations, where hyperedges aggregate initial node features to obtain hyperedge features. Then, the association matrix is ​​multiplied by the hyperedge features to obtain new node features. This process is iterated to achieve multi-layer networks. Compared to traditional embedding learning methods, hypergraph convolution can not only learn the structural relationships between each node and its higher-order neighbors but also incorporate its own features, making node information richer and enabling more comprehensive learning. However, other research shows that network metrics are not more advantageous than code metrics and lack universality. Summary of the Invention

[0007] This invention addresses the shortcomings of existing technologies by providing a defect prediction method and system based on hypergraph neural networks. It combines two different types of metrics, constructs hypergraph neural networks for these metrics using various methods, models them using a hypergraph convolution model, combines the resulting two types of features, and uses the final hybrid features for defect prediction.

[0008] To achieve the above-mentioned objectives, the technical solution adopted by the present invention is as follows:

[0009] A defect prediction method based on a hypergraph neural network includes the following steps:

[0010] S1: Perform network modeling on the software system, use network embedding models to obtain the structural features of the software system, and generate a hypergraph from the structural features using network-based methods;

[0011] S2: Construct an abstract syntax tree for the source code file of the software system, use a convolutional neural network to model it, obtain the semantic features of the software system, and construct a hypergraph based on the semantic features using the nearest neighbor method;

[0012] S3: Apply the hypergraph convolution model to model the hypergraph constructed based on the network in S1 and the hypergraph constructed based on the nearest neighbor in S2 respectively, combine the obtained features, and finally use the hybrid features for defect prediction.

[0013] Furthermore, S1 includes the following sub-steps:

[0014] A. Parse and extract the dependencies between various types of files, including inheritance, aggregation, and parameters, and model them to construct a Software Dependency Network (SDN). Using the Node2vec method, the network is transformed into a sequence of nodes through a random walk strategy. The obtained node sequence is then trained using the word vector model word2vec to obtain a low-dimensional vector representation of the nodes.

[0015] B. Define the hypergraph as a weighted network G = (V, E, W), where a hyperedge e i (e i ∈E) contains multiple nodes V={e1,e2,e3,e4…e i In a software-dependent network, an arbitrary node is selected as the base node. Its first-order and higher-order neighbors are connected to the base node via a hyperedge. The same operation is performed on all nodes to construct a hypergraph. The weights of each neighbor node of the base node are calculated according to a Gaussian distribution. The weight formula is as follows:

[0016]

[0017] Where d(X(u),X(v)) represents the distance from node u to base point v, and avg_list represents the average distance from the base point to each neighbor.

[0018] Furthermore, S2 includes the following sub-steps:

[0019] C. Use open-source tools to parse the source code files into an abstract syntax tree, traverse the abstract syntax tree, and parse each source file into a set of code tags [w1, w2, ..., w n The tokens are normalized to form a fixed-size vocabulary V. The vocabulary is trained using word2vec, and each code token is converted into a low-dimensional vector representation, resulting in a token embedding matrix M. The code token sequence of each class file is then input into a CNN, with convolution kernels w∈R. h×d The application generates new features on the token sequence; max-pooling is applied to the feature map to maximize the value. As the final feature, that is, the semantic feature vector of the file.

[0020] D. The nearest neighbor-based hypergraph generation method uses the distance d(X(u),X(v)) in the feature space to handle the relationship between vertices, finds adjacent vertices in the semantic feature space, and constructs a hyperedge to connect the adjacent vertices.

[0021] Specifically, in the semantic feature space, given a vertex (i.e., its centroid), a hyperedge is used to connect itself to its nearest neighbor in the feature space. The number of selected neighbors is determined by a predefined parameter k, and this type of hyperedge can connect to a group of similar vertices with the same centroid. The similarity is expressed by formula (1), where a larger W value indicates greater similarity between the two nodes.

[0022] Furthermore, S3 includes the following steps:

[0023] E. Construct the hypergraph convolutional model, including the following sub-steps:

[0024] Step E1: Input the structural features and hypergraph from S1 and the semantic features and hypergraph from S2 into the hypergraph convolution model respectively, and let... This represents the latent embedding vector of the target node v in the k-th layer of the model;

[0025] Step E2: The hypergraph convolutional layer performs node-edge-node transformation;

[0026] First, the initial node features By learning the filter matrix Θ (1) Extract the matrix, and then cluster the node features based on the hyperedges to form hyperedge features. Finally, the relevant hyperedge features are aggregated by multiplying with the correlation matrix to obtain the output node features. The hypergraph convolution formula is as follows:

[0027]

[0028] Where D v and D e W represents the degree of a vertex and a hyperedge. H H is the diagonal matrix of hyperedge weights, H is the incidence matrix, and X is the diagonal matrix of hyperedge weights. (l-1) It is the input layer, X (l) It is the output layer, Θ (l-1) σ is a learnable parameter, and σ represents a nonlinear activation function.

[0029] F. In the software system, each .java file is marked as either defective or non-defective. The features obtained from modeling structural and semantic features in step E are combined to train a machine learning classifier. Finally, the trained model is used to predict whether new instances are defective.

[0030] This invention discloses a defect prediction system based on a hypergraph neural network. This system can be used to implement the aforementioned defect prediction method based on a hypergraph neural network, including:

[0031] The network modeling and hypergraph generation module performs network modeling on the software system, using a network embedding model to obtain the structural features of the software system, and then generates a hypergraph from these structural features using a network-based method. Simultaneously, it constructs an abstract syntax tree from the software system's source code files, uses a convolutional neural network for modeling, obtains the semantic features of the software system, and then constructs a hypergraph from these semantic features using a nearest neighbor-based method.

[0032] Hypergraph Convolution Model: The hypergraph convolution model is applied to model hypergraphs constructed based on networks and hypergraphs constructed based on nearest neighbors, and the resulting features are combined.

[0033] Defect prediction module: Ultimately, hybrid features are used for defect prediction. By comprehensively considering the structural and semantic features of the software system, more accurate defect prediction is achieved.

[0034] The present invention also discloses a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned defect prediction method based on a hypergraph neural network.

[0035] Compared with the prior art, the advantages of the present invention are as follows:

[0036] 1. Comprehensive consideration of structural and semantic features: This method not only considers the structural features of the software system, but also combines semantic features, which can more comprehensively describe the characteristics of the software system and improve the accuracy of defect prediction.

[0037] 2. Deep Learning Model: This method uses a hypergraph convolution model, which can better handle hypergraph data, overcome the limitations of traditional methods in processing graph data, and improve the expressive power of the model.

[0038] 3. Better capture of software features: By using hypergraph neural networks, the complex features of software systems can be captured better, including structure, semantics and the relationships between them, thus improving the ability to predict defects.

[0039] 4. Improve prediction accuracy: By comprehensively considering various characteristics of the software system and using deep learning models for modeling, the accuracy and robustness of defect prediction can be improved.

[0040] 5. Combining different types of metrics: This method can comprehensively consider different types of metrics, including structural metrics and semantic metrics, which improves the ability to comprehensively describe and model the characteristics of software systems. Attached Figure Description

[0041] Figure 1 This is a framework diagram of a defect prediction method based on a hypergraph neural network according to an embodiment of the present invention;

[0042] Figure 2This is a flowchart of the hypergraph convolution model according to an embodiment of the present invention. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and examples.

[0044] like Figure 1 As shown, this invention provides a defect prediction method based on a hypergraph neural network, which specifically includes the following three main steps:

[0045] S1: Perform network modeling on the software system, using a network embedding model to obtain the structural features of the software system, and generate a hypergraph from the structural features using a network-based method, including the following steps:

[0046] A. Parse and extract the dependencies between various types of files (such as inheritance, aggregation, parameters, etc.) and model them to construct a Software Dependency Network (SDN); use the Node2vec method to transform the network into a sequence of nodes through a random walk strategy, and train the obtained node sequence using the word vector model word2vec to obtain a low-dimensional vector representation of the nodes.

[0047] B. In this invention, a hypergraph is defined as a weighted network G = (V, E, W), where a hyperedge e i (e i ∈E) contains multiple nodes V={e1,e2,e3,e4…e i In a software dependency network, an arbitrary node is selected as the base node. Its first-order and higher-order neighbors are connected to the base node via a hyperedge. The same operation is performed on all nodes to construct a hypergraph. The weights of each neighbor node of the base node are calculated according to a Gaussian distribution. The weight formula is as follows:

[0048]

[0049] Where d(X(u),X(v)) represents the distance from node u to base point v, and avg_list represents the average distance from the base point to each neighbor.

[0050] S2: Construct an abstract syntax tree for the software system's source code files, model it using a convolutional neural network to obtain the semantic features of the software system, and construct a hypergraph from the semantic features using a nearest neighbor-based method, including the following steps:

[0051] C. Use open-source tools to parse the source code files into an abstract syntax tree, traverse the abstract syntax tree, and parse each source file into a set of code tags [w1, w2, ..., w nThe tokens are normalized to form a fixed-size vocabulary V. The vocabulary is trained using word2vec, and each code token is converted into a low-dimensional vector representation, resulting in a token embedding matrix M. The code token sequence of each class file is then input into a CNN, with convolution kernels w∈R. h×f New features are generated by applying the method to the token sequence; finally, max-pooling is applied to the feature map to maximize the value. As the final feature, that is, the semantic feature vector of the file.

[0052] D. The nearest neighbor-based hypergraph generation method uses the distance f(X(u), X(v)) in the feature space to handle the relationships between vertices. The main goal is to find adjacent vertices in the feature space and construct a hyperedge to connect them. Specifically, in the semantic feature space, given a vertex (i.e., its centroid), a hyperedge can connect itself to its nearest neighbor in the feature space. The number of selected neighbors is determined by a predefined parameter k. This type of hyperedge can connect to a group of similar vertices with the same centroid. The similarity is expressed by formula (1), where a larger W value indicates greater similarity between two nodes.

[0053] S3: Apply hypergraph convolution models to model the hypergraph constructed based on the network in S1 and the hypergraph constructed based on nearest neighbors in S2, respectively. Combine the obtained features and finally use the hybrid features for defect prediction, including the following steps:

[0054] E. such as Figure 2 As shown, constructing a hypergraph convolutional model includes the following sub-steps:

[0055] Step E1: Input the structural features and hypergraph from S1 and the semantic features and hypergraph from S2 into the hypergraph convolution model respectively, and let... This represents the latent embedding vector of the target node v in the k-th layer of the model;

[0056] Step E2: The hypergraph convolutional layer can perform node-edge-node transformation. Specifically, it first initializes the node features. By learning the filter matrix Θ (1) Extract the matrix, and then cluster the node features based on the hyperedges to form hyperedge features. Finally, the relevant hyperedge features are aggregated by multiplying with the correlation matrix to obtain the output node features. The hypergraph convolution formula is as follows:

[0057]

[0058] Where D v and D e W represents the degree of a vertex and a hyperedge. H H is the diagonal matrix of hyperedge weights, H is the incidence matrix, and X is the diagonal matrix of hyperedge weights.(l-1) It is the input layer, X (l) It is the output layer, Θ (l-1) σ is a learnable parameter, and σ represents a nonlinear activation function.

[0059] F. In the software system, each .java file is marked as either defective or non-defective. The features obtained from modeling structural and semantic features in step E are combined to train a machine learning classifier. Finally, the trained model is used to predict whether new instances are defective.

[0060] experiment

[0061] 1. Dataset

[0062] This embodiment selected seven defective projects from the PROMISE library: Ant, Camel, jEdit, Lucene, Poi, Velocity, and Xalan. Ant is a cross-platform build tool that automates project building and deployment; Camel is a software workload integration solution; jEdit is a Java-based text editor; Lucene is an open-source library for full-text search; Poi processes Microsoft documents within a Java class library; Velocity is a Java-based template engine; and Xalan is a specification for converting documents to Hypertext Markup Language (HTML) or other types of XML. Table 1 shows the statistics for the seven software projects, where the number of nodes represents the number of class files in the class dependency graph, the number of edges represents the number of dependencies between class files, and the defect rate represents the proportion of defective files in the project.

[0063] Table 1. Information on the text dataset

[0064]

[0065] 2. Experimental Setup

[0066] The experiment in this embodiment was completed in a Python environment (Python 3.7) under Windows 11 system, using the Adam optimizer on the TensorFlow framework, with the training set and test set divided in an 8:2 ratio. The model parameter settings are shown in Table 2.

[0067] Table 2 shows the model parameter settings.

[0068]

[0069] Benchmark Method

[0070] To verify the effectiveness of the proposed method, this invention selected five methods based on complex network theory as the benchmark models of this invention.

[0071] (1) BiLSTM: Bidirectional LSTM is an AST-based method that takes an AST as input to capture the semantic information of the source code.

[0072] (2) CNN: CNN is also an AST-based method that takes AST as input to capture the semantic information of the source code.

[0073] (3) Node2defect: Node2defect is an improved depth-first traversal method that combines breadth-first traversal and depth-first traversal, using node2vec to extract structural information from CDN.

[0074] (4) GCN2defect: GCN2defect uses GCN to learn the node attribute characteristics and network structure information of the source code.

[0075] (6) GAT: GAT is an improved method of GCN, which takes into account the attention mechanism to learn the node attribute features and network structure information of the source code.

[0076] Node2vec is an unsupervised learning model that does not require labels during pre-training. BiLSTM, CNN, GCN, and GAT are all end-to-end trained supervised models that use the softmax function in the prediction layer. For a more rigorous experimental structure, we do not directly use softmax for prediction results; instead, we save the node representations of the last hidden layer of the model as the pre-training result.

[0077] 3. Evaluation Indicators

[0078] To evaluate the classification performance of the model, the F1 (harmonic mean F1) of precision (P) and recall (R) is used. Precision (P) refers to the proportion of correctly predicted samples out of all predicted positive samples; recall (R) refers to the proportion of correctly predicted samples out of all true positive samples. Since precision and recall can sometimes contradict each other, their harmonic mean F1 is used for a comprehensive evaluation.

[0079] The calculation formula is as follows:

[0080]

[0081]

[0082]

[0083] In this context, TP, FP, and FN represent the number of true positives, false positives, and false negatives, respectively. The area under the ROC curve (AUC) is also widely used for SDP assessment, especially in cases of imbalanced data. The AUC value ranges from 0 to 1, with 0.5 representing random prediction. Higher values ​​for the three assessment metrics indicate better predictive performance.

[0084] 4. Experimental Results

[0085] Since the model in this embodiment combines semantic and structural information, to ensure the accuracy of the experimental results, this invention combines baseline models that extract semantic and structural information in pairs as experimental control models. Furthermore, the resampling method and classifier in the baseline models are consistent with the method proposed in this invention, and all baseline models use SMOTE and MLP in defect prediction. Tables 3 and 4 show the experimental results of the proposed model and the control models.

[0086] Table 3 Comparison of F1 scores between HGCN2defect and existing methods

[0087]

[0088] Table 4 Comparison of AUC values ​​between HGCN2defect and existing methods

[0089]

[0090] The results in Tables 3 and 4 show that, overall, the HGCN2defect method is the best across the seven projects. The average improvement in F1 score and AUC value is 1.1%–10% and 0.9%–6.7%, respectively. Notably, the method of this invention shows significant improvements in the camel and poi projects, with a maximum improvement of 2.6% in F1 score and 4% in AUC value. These results reflect the excellent performance of the HGCN2defect method in handling projects of different sizes. However, the method of this invention is not dominant in all projects; in the Ant project, HGCN2defect lags behind CGCN and CGAT. Nevertheless, the HGCN2defect method still outperforms other methods in all metrics, reflecting the feasibility and practicality of the method of this invention.

[0091] In another embodiment of the present invention, a defect prediction system based on a hypergraph neural network is provided. This system can be used to implement the above-described defect prediction method based on a hypergraph neural network, specifically including: a module.

[0092] The network modeling and hypergraph generation module performs network modeling on the software system, using a network embedding model to obtain the structural features of the software system, and then generates a hypergraph from these structural features using a network-based method. Simultaneously, it constructs an abstract syntax tree from the software system's source code files, uses a convolutional neural network for modeling, obtains the semantic features of the software system, and then constructs a hypergraph from these semantic features using a nearest neighbor-based method.

[0093] Hypergraph Convolution Model: The hypergraph convolution model is applied to model hypergraphs constructed based on networks and hypergraphs constructed based on nearest neighbors, and the resulting features are combined.

[0094] Defect prediction module: Ultimately, hybrid features are used for defect prediction. By comprehensively considering the structural and semantic features of the software system, more accurate defect prediction is achieved.

[0095] In another embodiment of the present invention, a storage medium is provided, specifically a computer-readable storage medium (Memory). This computer-readable storage medium is a memory device in a terminal device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and extended storage media supported by the terminal device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, this storage space also stores one or more instructions suitable for loading and execution by a processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device.

[0096] One or more instructions stored in a computer-readable storage medium can be loaded and executed by a processor to implement the corresponding steps of the defect prediction method based on a hypergraph neural network in the above embodiments; one or more instructions in the computer-readable storage medium are loaded and executed by the processor to perform the following steps:

[0097] S1: Perform network modeling on the software system, use network embedding models to obtain the structural features of the software system, and generate a hypergraph from the structural features using network-based methods;

[0098] S2: Construct an abstract syntax tree for the source code file of the software system, use a convolutional neural network to model it, obtain the semantic features of the software system, and construct a hypergraph based on the semantic features using the nearest neighbor method;

[0099] S3: Apply the hypergraph convolution model to model the hypergraph constructed based on the network in S1 and the hypergraph constructed based on the nearest neighbor in S2 respectively, combine the obtained features, and finally use the hybrid features for defect prediction.

[0100] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0101] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0102] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0103] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0104] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the implementation methods of the present invention, and should be understood that the scope of protection of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of the present invention.

Claims

1. A defect prediction method based on a hypergraph neural network, characterized in that, Includes the following steps: S1: Perform network modeling on the software system, use network embedding models to obtain the structural features of the software system, and generate a hypergraph from the structural features using network-based methods; S2: Construct an abstract syntax tree for the source code file of the software system, use a convolutional neural network to model it, obtain the semantic features of the software system, and construct a hypergraph based on the semantic features using the nearest neighbor method; S2 includes the following sub-steps: S21: Use open-source tools to parse source code files into an abstract syntax tree, traverse the abstract syntax tree, and parse each source file into a set of code tags. Then, normalization is performed to form a fixed-size vocabulary. The word2vec vocabulary is trained, and each code token is converted into a low-dimensional vector representation to obtain a token embedding matrix M. The code token sequence of each class file is input into the CNN, and the convolution kernel... New features are generated by applying them to token sequences; Max pooling is applied to the feature map to maximize the maximum value. As the final feature, that is, the semantic feature vector of the file; S22: Nearest neighbor-based hypergraph generation methods use distances in feature space. To handle the relationships between vertices, find adjacent vertices in the semantic feature space and construct a hyperedge to connect the adjacent vertices; Specifically, in the semantic feature space, given a vertex, a hyperedge is used to connect itself to its nearest neighbor in the feature space; the number of neighbors selected is determined by a predefined parameter k, and this type of hyperedge can connect to a group of similar vertices with the same centroid. S3: Apply the hypergraph convolution model to model the hypergraph constructed based on the network in S1 and the hypergraph constructed based on the nearest neighbor in S2 respectively, combine the obtained features, and finally use the mixed features for defect prediction. S3 includes the following steps: S31: Construct the hypergraph convolutional model, including the following sub-steps: S311: Input the structural features and hypergraph from S1 and the semantic features and hypergraph from S2 into the hypergraph convolution model respectively, and let... Represents the target node In the model The hidden embedding vector of the layer; S312: Hypergraph convolutional layers perform node-edge-node transformations; First, the initial node features By learning the filter matrix Extract the matrix, and then cluster the node features based on the hyperedges to form hyperedge features. Finally, the relevant hyperedge features are aggregated by multiplying with the correlation matrix to obtain the output node features. The hypergraph convolution formula is as follows: , in and Represents the degree of the vertex and the hyperedge. It is a diagonal matrix of hyperedge weights. It is an incidence matrix. It is the input layer. It is the output layer. These are learnable parameters. Represents a non-linear activation function; S32: In the software system, each .java file is marked as defective or not defective; the features obtained by modeling structural and semantic features in step E are combined to train a machine learning classifier; finally, the trained model is used to predict whether new instances are defective.

2. The defect prediction method based on a hypergraph neural network according to claim 1, characterized in that: S1 includes the following sub-steps: A. Parse and extract the dependencies between various types of files, including inheritance, aggregation, and parameters, and model them to construct a Software Dependency Network (SDN); use the Node2vec method to transform the network into a sequence of nodes through a random walk strategy, and train the obtained node sequence using the word2vec model to obtain a low-dimensional vector representation of the nodes; B. Define the hypergraph as a weighted network. One of the super-edges Contains multiple nodes In a software-dependent network, an arbitrary node is selected as the base node, and its first-order and higher-order neighbors are connected to the base node through a hyperedge. The same operation is performed on all nodes to construct a hypergraph. The weights of each neighbor node of the base node are calculated according to a Gaussian distribution; the weight formula is as follows: (1), in Represents a node to base point distance, This represents the average distance from the base point to each of its neighbors; The similarity is calculated using formula (1). The larger the W value, the more similar the two nodes are.

3. A defect prediction system based on a hypergraph neural network, characterized in that: This system can be used to implement a defect prediction method based on a hypergraph neural network as described in claim 1 or 2, comprising: Network Modeling and Hypergraph Generation Module: Performs network modeling on the software system, uses network embedding models to obtain the structural features of the software system, and generates a hypergraph from the structural features using network-based methods; simultaneously, constructs an abstract syntax tree from the source code files of the software system, uses convolutional neural networks for modeling, obtains the semantic features of the software system, and constructs a hypergraph from the semantic features using a nearest neighbor-based method. Hypergraph Convolution Model: The hypergraph convolution model is applied to model hypergraphs constructed based on networks and hypergraphs constructed based on nearest neighbors, and the resulting features are combined. Defect prediction module: Ultimately, hybrid features are used for defect prediction. By comprehensively considering the structural and semantic features of the software system, more accurate defect prediction is achieved.

4. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the defect prediction method based on a hypergraph neural network as described in claim 1 or 2.