A cross-project software defect prediction method based on domain adaptation

By employing a domain-adaptive approach and optimizing the model using neural networks and MMD functions, the problem of domain distribution differences in cross-project software defect prediction was solved, achieving low-cost, high-efficiency knowledge transfer and prediction results.

CN115658504BActive Publication Date: 2026-06-02SOUTH CHINA UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2022-10-25
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In cross-project software defect prediction, the domain distribution of the source project and the target project differs greatly, making it difficult to effectively transfer the knowledge learned from the source project to the target project. Existing technical methods have unsatisfactory prediction results and high training costs.

Method used

A domain-adaptive approach is adopted, using a neural network as a feature extractor to divide the high-dimensional features of the code file into feature domains for source and target items. The defect prediction model is trained using the MMD function, and the model is optimized using the information entropy function and gradient descent method to construct a feature domain decision boundary with good discriminative power.

Benefits of technology

It reduces the training cost of software defect prediction, improves the scalability and accuracy of prediction models, effectively transfers knowledge to target projects, and reduces the burden of labeling work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115658504B_ABST
    Figure CN115658504B_ABST
Patent Text Reader

Abstract

The present application relates to the field of software engineering data analysis and prediction, and discloses a cross-project software defect prediction method based on domain adaptation, which comprises the following steps: taking a neural network as a feature extractor, extracting high-dimensional code features of code files according to the representation of a software project; training a defect prediction model through an MMD function according to the feature domain of a source project and the feature domain of a target project; performing weighted optimization on the MMD function, training the neural network by using a gradient descent method to obtain an optimized defect prediction model; and inputting software code files into the optimized prediction model to output the probability of defects existing in the code files. The present application can solve the problem that the domain distribution of a source project and a target project is quite different in a cross-project software defect prediction method, and the knowledge learned from the source domain is difficult to migrate to the target domain, and can reduce the training cost of software defect prediction and increase the expansibility of the prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing, and in particular to a cross-project software defect prediction method based on domain adaptation. Background Technology

[0002] Software testing, as a crucial part of software quality assurance, has a vital impact on software quality. However, traditional software testing relies on manual methods, which, given the increasingly large scale and functional complexity of current software, requires a large amount of repetitive operations. This reduces development efficiency and significantly increases maintenance costs.

[0003] With the continuous development and improvement of artificial intelligence theory and computer hardware, software defect prediction, as a promising software testing method, has begun to be combined with artificial intelligence, becoming an active research area in software engineering. In the development and maintenance of large-scale software, software testing resources are often limited, and the allocation of testing resources often requires specialized software testing engineers.

[0004] Software defect prediction uses defect predictors to identify modules or instances with a high defect predisposition, determining the focus of software testing and prioritizing defect-prone modules for intensive testing, thus reducing the burden on code testing. Cross-project software defect prediction (CPDP) is a typical scenario for software defect prediction. CPDP requires building a predictive model that can transfer knowledge from the source project to the target project, given that the source project data and labels are known, while the target project data is known but the labels are unknown. Because knowledge is not shared between the source and target domains, it is difficult to transfer knowledge from the source domain to the target domain. Without supplementary measures for in-project software defect prediction, the prediction results are likely to be unsatisfactory. In real-world production environments, due to differences in software scale, functionality, and programmer coding habits, different projects often have different data distributions. Summary of the Invention

[0005] To address the technical problems existing in the prior art, this invention provides a cross-project software defect prediction method based on domain adaptation. This method solves the problem that the domain distribution of the source project and the target project differs greatly in cross-project scenarios, making it difficult to transfer knowledge learned from the feature domain of the source project to the feature domain of the target project. This method can reduce the training cost of software defect prediction and increase the scalability of the prediction model.

[0006] This invention can be achieved by adopting the following technical solutions:

[0007] A domain-adaptive cross-project software defect prediction method, the method comprising the following steps:

[0008] Using neural networks as feature extractors, high-dimensional code features of code files are extracted based on the representation of software projects. The high-dimensional code features of code files are then divided into the feature domains of the source project and the target project.

[0009] The MMD function is constructed as the loss function, and the defect prediction model is trained by the MMD function based on the feature domains of the source project and the target project. The defective instances in the feature domain of the source project are aligned with the defective instances in the feature domain of the target project, and the non-defective instances in the feature domain of the source project are aligned with the defective and non-defective instances in the feature domain of the target project.

[0010] By allocating prediction weights according to their importance during the neural network training process using the information entropy function, the MMD function is weighted and optimized, and the neural network is trained using the gradient descent method to obtain an optimized defect prediction model.

[0011] The software code file is input into the optimized prediction model, and the output is the probability that the code file has defects.

[0012] In the preferred embodiment, the neural network is a convolutional neural network, and the representation of the software project adopts an abstract syntax.

[0013] In a preferred embodiment, the method for predicting cross-project software defects based on domain adaptation is characterized in that the step of extracting high-dimensional code features from code files according to the representation of the software project includes: processing the code file into an abstract syntax tree using a code tool; performing a pre-order traversal of each semantic node in the abstract syntax tree and numbering them in ascending order; embedding all semantic node execution words into the corpus of the constructed nodes to form a mapping relationship between each node and a numerical vector; converting the traversed semantic nodes into numerical vectors and inputting them into a convolutional neural network; and outputting high-dimensional feature vectors after convolution operations of the convolutional layer and pooling operations of the pooling layer.

[0014] In a preferred embodiment, the construction of the MMD function as a loss function, and the training of the neural network using the MMD function based on the feature domains of the source and target items, includes the following steps:

[0015] A category-aware strategy is adopted to distinguish between defective and non-defective instances in the feature domain of the source item and the target item. The feature domains of the source and target items are mapped to a measurable high-dimensional space using a Gaussian kernel function. The distance between instances is calculated using the high-dimensional coordinate difference between instances. The sum of the pairwise distances between all instances in the defective and non-defective categories is used as the loss value of the MMD function.

[0016] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0017] This invention provides a cross-project software defect prediction method based on domain adaptation. Combining deep learning domain adaptation technology, it constructs an MMD function as a loss function and trains the defect prediction model based on the feature domains of the source project and the target project. It aligns the software distribution of different projects from the perspectives of features and instances, solving the problem that the domain distribution of the source and target projects differs greatly in cross-project software defect prediction methods, making it difficult to transfer knowledge learned from the source domain to the target domain. This can reduce the training cost of software defect prediction and increase the scalability of the prediction model. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0019] Figure 1 This is a flowchart of a cross-project software defect prediction method based on domain adaptation in an embodiment of the present invention.

[0020] Figure 2 This is a schematic diagram of neural network training in an embodiment of the present invention. Detailed Implementation

[0021] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments, and the implementation of the present invention is not limited thereto. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] Example 1:

[0023] To address the issue that defect prediction models built from source projects as training data cannot be directly and effectively applied to software defect prediction tasks in target projects, a domain adaptation approach is introduced. This approach transfers knowledge from a richly labeled but heterogeneous domain to a sparsely labeled domain, reducing the burden of labeling work. In cross-project scenarios, this approach does not have special requirements for the training set of the source projects, making it more realistic. Furthermore, domain adaptation offers greater scalability; for a new target project, only the software's feature vector extractor needs transfer training to be applied, significantly reducing training costs compared to traditional software defect prediction methods.

[0024] like Figure 1 As shown, the cross-project software defect prediction method based on domain adaptation of the present invention includes the following steps:

[0025] Step 1: Use the neural network as a feature extractor to extract high-dimensional code features from the code file based on the representation of the software project. Divide the high-dimensional code features of the code file into the feature domain of the source project and the feature domain of the target project.

[0026] The representation of software projects is unrestricted in this method. It includes code metrics, code text, abstract syntax trees (ASTs), control flow graphs, etc. Similarly, the neural network used as the feature extractor is unrestricted and can be a convolutional neural network (CNN), a long short-term memory network (LSTM), etc. Preferably, this embodiment uses an abstract syntax tree (AST) to represent the software project and a convolutional neural network (CNN) as the feature extractor. An abstract syntax tree (AST) is independent of specific grammars and language details; it is a tree-like representation of the abstract syntactic structure of the source code, where each node represents a structure within the source code. A convolutional neural network (CNN) is a widely used neural network in deep learning. It can reduce a large number of parameters to a smaller number through convolution operations, achieving excellent results in computer vision. It can also be applied to extract features from code text.

[0027] Specifically, extracting high-dimensional code features from the representation of a software project includes the following steps: 1. Processing the code file into an abstract syntax tree (AST) using code tools, serving as the code representation. 2. Numbering each semantic node in the AST in ascending order through a pre-order traversal. 3. Performing word embeddings on all semantic nodes to construct a corpus of nodes, forming a mapping relationship between each node and a numeric vector. 4. Converting the traversed semantic nodes into numeric vectors and inputting them into a convolutional neural network. After convolutional operations in the convolutional layers and pooling operations in the pooling layers, the output is a high-dimensional feature vector representing the code file.

[0028] Furthermore, let the feature extractor be G(.), and the software project be represented by x. Then, after the extraction process in step 1, the high-dimensional feature vector f = G(x) of the code file is obtained. Specifically, for both the source and target software projects, the feature extractor extracts high-dimensional feature vectors of all code files. The extracted high-dimensional feature vectors of all code files are then used to partition the feature space according to whether the code file belongs to the source or target project, thus obtaining the feature domain of the source project and the feature domain of the target project.

[0029] Step 2: Construct the MMD (Maximum Mean Discrepancy) function as the loss function. Train the neural network using the MMD function based on the feature domains of the source item and the target item respectively. Align defective instances in the feature domains of the source item with defective instances in the feature domains of the target item, and align non-defective instances in the feature domains of the source item with both defective and non-defective instances in the feature domains of the target item. Automatically assign prediction weights according to importance during neural network training using the information entropy function, perform weighted optimization of the MMD function, and use gradient descent to train the neural network to obtain an optimized defect prediction model.

[0030] Specifically, the process of training a neural network is as follows: the representation vector of the abstract syntax tree is input into the convolutional neural network, and through forward propagation and convolution, high-dimensional feature vectors of the feature domains of the source item and the target item are calculated and output. and The MMD function loss value is calculated using a formula. The training objective of the neural network is to minimize the MMD maximum mean difference function loss, making the distributions of the feature domains of the source and target items closer, and gradually aligning the feature distributions of instances of the same category in the feature domains of the source and target items. This aligns defective and non-defective instances in the feature domains of the source and target items, thereby achieving knowledge transfer from the feature domains of the source and target items. The training algorithm is the backpropagation algorithm, which optimizes the loss function and adjusts the model parameters based on the gradients accumulated by the computational units during forward propagation. After dozens of training rounds, the finally trained feature extractor is obtained. Figure 2 The diagram shows a schematic of neural network training.

[0031] Specifically, the MMD function is constructed as the loss function, and the neural network is trained using the maximum mean difference function based on the feature domains of the source item and the target item, respectively. The steps include:

[0032] A category-aware strategy is adopted to distinguish between defective and non-defective instances in the feature domain of the source item and the target item. The feature domains of the source and target items are mapped to a measurable high-dimensional space using a Gaussian kernel function. The distance between instances is calculated using the high-dimensional coordinate difference between instances. The sum of the pairwise distances between all instances in the defective and non-defective categories is used as the loss value of the MMD function.

[0033] Specifically, the category-aware strategy includes four types of instances: SD (defective feature domains of the source item), SN (undefective feature domains of the source item), TD (defective feature domains of the target item), and TN (undefective feature domains of the target item). The distance between instances is measured using the MMD distance function. The strategy aims to reduce the distance between SD and TD, and between SN and TN, while increasing the distance between SD and TN, SN and SN, and between TD and SN, and between TD and TN, making the instances of the source and target item feature domains more similar in a high-dimensional space. This allows the knowledge of the source item's feature domain to be used to predict the target item's feature domain.

[0034] Furthermore, by using MMD to measure the distance between the feature domains of the source and target items, the loss value MMD of the MMD function is expressed as:

[0035]

[0036] Where s represents the feature domain of the source project, t represents the feature domain of the target project, X represents the domain distribution, and n s n t Let be the number of feature domain instances in the source project and the number of feature domain instances in the target project, respectively, and φ(.) represent the mapping function from the feature space to the regenerated Hilbert space. For the high-dimensional feature vectors of the feature domain of the source project, This refers to the high-dimensional feature vector of the feature domain of the target project.

[0037] The Maximum Mean Difference (MMD) function is calculated based on the respective categories of defective and non-defective instances in the feature domains of the source and target projects, where each category includes defective and non-defective. Typical MMD methods align the overall distribution of the feature domains of the source and target projects, without distinguishing between data distributions of different categories. However, in cross-project software defects, the data distributions of defective and non-defective instances may differ significantly and should not be aligned in the same direction, otherwise it will cause overlap and confusion in the distributions of defective and non-defective instances. Therefore, this embodiment introduces a category-aware maximum mean difference (MMD) function, calculating the MMD separately for defective and non-defective categories, and summing the pairwise distances between all instances in the defective and non-defective categories respectively.

[0038]

[0039] Where represents the category of the instance, k=0 indicates no defects, k=1 indicates defects, represents whether the source project's feature domain has defects or no defects, tk represents whether the target project's feature domain has defects or no defects, X sk X represents the distribution of defective or non-defective instances in the feature domain of the source project. tk This represents the distribution of defective or non-defective instances in the feature domain of the target project, n. sk n represents the number of defective or non-defective instances in the feature domain of the source project. tk G(.) represents the number of defective or defect-free instances in the feature domain of the target project, and G(.) represents the high-dimensional feature vector extracted by the feature extractor.

[0040] Expanding the above equation and substituting it into the kernel function κ(.,.), we get:

[0041]

[0042] The source project, used as training data, has known defects in its code files, allowing for direct differentiation. However, the target project, used as prediction data, has unknown class labels for its feature domain instances. The distinction between defective target project instances (TD) and non-defective target project instances (TN) is achieved through pseudo-labels, which are applied after each training iteration and network parameter update. These pseudo-labels are dynamic; after each training iteration, the predicted labels, feature vectors, and target project feature domain instances are obtained from the updated feature extractor and logistic classifier. The logistic classifier performs a simple binary classification on the features obtained by the feature extractor.

[0043] Preferably, during the training process, the KNN (k-nearest neighbor classification) clustering algorithm is used to assign pseudo-labels to instances of unknown feature domain categories of the target project based on the feature vectors of the feature domain instances of the source project. This reduces the distance between instances within the same category and increases the distance between instances of different categories, progressively aligning the feature domains of the source project and the target project.

[0044] From the perspective of instance distribution, for instances whose feature domain categories of the target item are unknown, pseudo-labeling is used to progressively reduce intra-class distance and increase inter-class distance. Pseudo-labels are applied to instances in the feature domain of the target item and dynamically updated during training to improve the prediction accuracy of the target item's feature domain. For a training batch, the feature domain of the source item can directly obtain the true class label, while the label of the target item's feature domain is unknown.

[0045] The pseudo-labels for the feature domain instances of the target project include defective and non-defective pseudo-labels, which are pre-annotated manually. These pseudo-labels are assigned to the feature domain instances of the target project after each round of training when the network parameters are updated. The pseudo-labels for the target project's feature domain are dynamic. After each round of training, the predicted results of the feature domain instances of the source projects, the feature vectors of the source project's feature domain instances, and the feature vectors of the target project's feature domain instances are obtained based on the updated parameters of the feature extractor and logistic classifier. Using the KNN clustering algorithm, the K source project feature domain instances most similar to the feature vectors of the target project's feature domain instances are calculated. Then, the class labels that constitute the majority of these K source project feature domain instances are selected as the pseudo-labels for the target project's feature domain instances.

[0046] Specifically, through the feature extractor G(.), the features G(x) of the feature domain instance of the target item can be obtained. t During training, the feature extractor will gradually learn to extract domain-invariant features. Therefore, based on the features of the source item's feature domain instances, the category of the target item's feature domain instances can be determined based on the similarity between the source item's feature domain instances and the target item's feature domain instances. Initially, since the data distributions of the source item's feature domain and the target item's feature domain are likely to be very dissimilar, the obtained pseudo-labels will contain a lot of noise. However, as the training process progresses, the domain gap continuously decreases, and the obtained pseudo-labels will become more and more accurate, forming a feedback loop.

[0047] Specifically, the feature domain instances of source projects that are the nearest neighbors to the feature domain instance of the target project are obtained using the distance metric function d(.). The distance metric function d(.) is expressed as:

[0048]

[0049] in This represents the i-th instance in the feature domain of the source project. G(.) represents the j-th instance in the feature domain of the target project, and G(.) represents the high-dimensional feature vector extracted by the feature extractor.

[0050] The K source project feature domain instances that are most similar to the feature vectors of the target project feature domain instances are calculated using the KNN clustering algorithm. The majority category labels among the K source project feature domain instances are then identified, and these majority category labels are used as pseudo labels for the target project feature domain instances.

[0051] Preferably, for code instances with different transferability, prediction weights are assigned according to their importance during network training using the information entropy function, the MMD function is weighted and optimized, and the neural network is trained using gradient descent to obtain an optimized defect prediction model.

[0052] The information entropy function is defined as follows:

[0053]

[0054] Where x represents the event, and p(.) represents the probability of the event occurring.

[0055] Information entropy is often used as a quantitative indicator of the information content of a system, and can be further used as an objective for system equation optimization or a criterion for parameter selection. For classification problems, the information entropy function can, to some extent, quantify the degree of certainty by which a classifier identifies a particular class.

[0056] From an instance perspective, MMD is optimized by assigning weights to different instances based on their transferability. Transferability is a difficult concept to define; this embodiment quantitatively represents the transferability of feature domain instances of source items through the determinism of classifier predictions. Transferability refers to the varying difficulty of transferring feature domain instances of different source items to the public domain for cross-domain classification problems.

[0057] Preferably, the transferability of the feature domain instances of the source item is quantified using an information entropy function, and described by the certainty of the prediction results by a logistic classifier. The logistic classifier outputs the probability that the predicted instance contains a defect. The higher the defect probability (approaching 1) or the lower the probability (approaching 0), the higher the classifier's certainty of the prediction, meaning that the instance has obvious defect features and good feature transferability. Therefore, no additional attention is needed, and the weight ratio of the instance is reduced.

[0058] Software defect prediction is a binary classification task, therefore the classifier will output a classification prediction vector p:

[0059] p = (p0, p1), p0 + p1 = 1

[0060] p0 represents the probability of being defect-free, and p1 represents the probability of being defective. If one of the values ​​of p in the classification prediction result of a feature domain instance of a target item approaches 1, it indicates that this instance is easy to classify, the classifier has high certainty, and therefore this instance is considered to have good transferability and requires less attention. Thus, it is assigned a lower weight in the maximum mean difference loss. Conversely, it is assigned a higher weight.

[0061] To quantify portability and assign weights to instances, a portability expression is introduced:

[0062] q = -(p0 log2 p0 + p1 log2 p1)

[0063] Here, p0 represents the probability of no defect, and p1 represents the probability of a defect. When p0 or p1 is 1, q = 0. At this point, the classifier has a high degree of confidence in predicting the instance, exhibits good transferability, and requires no additional weight. When both p0 and p1 are 0.5, q reaches its maximum value, indicating poor transferability and requiring an additional 0.5 times the weight.

[0064] By incorporating the transfer expression into the MMD function and simplifying, we obtain the optimized MMD function:

[0065]

[0066] By applying this loss function to the training process of the feature extractor and classifier, the neural network is trained using gradient descent to obtain an optimized prediction model. The optimized prediction model forms a feature domain decision boundary with good discriminative power.

[0067] Step 3: Input the software code file into the optimized prediction model and output the probability that the code file has defects.

[0068] The above two steps form a feature domain decision boundary with good discriminative power, and the probability of defects in the code file is output by the logical classifier.

[0069] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A cross-project software defect prediction method based on domain adaptation, characterized in that, Includes the following steps: Using neural networks as feature extractors, high-dimensional code features of code files are extracted based on the representation of software projects. The high-dimensional code features of code files are then divided into the feature domains of the source project and the target project. The MMD function is constructed as the loss function. The defect prediction model is trained using the MMD function based on the feature domains of the source and target items. The steps include: A category-aware strategy is adopted to distinguish between defective and non-defective instances in the feature domain of the source project and the target project. The feature domains of the source and target projects are mapped to a measurable high-dimensional space using a Gaussian kernel function. The distance between instances is calculated using the high-dimensional coordinate difference between instances. The sum of the pairwise distances between all instances in the defective and non-defective categories is used as the loss value of the MMD function. Align defective instances in the feature domains of the source project with defective instances in the feature domains of the target project; align non-defective instances in the feature domains of the source project with both defective and non-defective instances in the feature domains of the target project; including: During training, based on the feature vectors of the feature domain instances of the source project, the KNN classification algorithm is used to assign pseudo-labels to instances of the target project whose feature domain category is unknown, thereby reducing the distance between instances of the same category and increasing the distance between instances of different categories. The pseudo-labels of the feature domain instances of the target project include defective pseudo-labels and non-defective pseudo-labels. After each round of training and updating of network parameters, pseudo-labels are added to the feature domain instances of the target project. The MMD function is weighted and optimized by allocating prediction weights according to importance during neural network training using the information entropy function. The optimized defect prediction model is then trained using gradient descent. This includes: The transferability of feature domain instances of the source item is quantified using the information entropy function, and the degree of certainty of the prediction results is described by the logistic classifier. The optimized MMD function is obtained by incorporating the transferability expression into the MMD function. The transferability expression is: ; in, This represents the probability of being defect-free. Indicates the probability of a defect; Input the software code file into the optimized defect prediction model, and output the probability that the code file contains defects.

2. The cross-project software defect prediction method based on domain adaptation according to claim 1, characterized in that, The neural network is a convolutional neural network, and the software project is represented using an abstract syntax.

3. The cross-project software defect prediction method based on domain adaptation according to claim 2, characterized in that, The step of extracting high-dimensional code features from code files based on the representation of the software project includes: processing the code file into an abstract syntax tree using a code tool; performing a pre-order traversal of each semantic node in the abstract syntax tree and numbering them in ascending order; embedding all semantic node execution words into the corpus of the constructed nodes to form a mapping relationship between each node and a numerical vector; converting the traversed semantic nodes into numerical vectors and inputting them into a convolutional neural network; and outputting high-dimensional feature vectors after convolution operations of the convolutional layer and pooling operations of the pooling layer.

4. The cross-project software defect prediction method based on domain adaptation according to claim 3, characterized in that, The step of dividing the high-dimensional code features of the code file into the feature domain of the source project and the feature domain of the target project includes: dividing the feature space of all extracted high-dimensional feature vectors of the code file according to whether the code file belongs to the source project or the target project, thereby obtaining the feature domain of the source project and the feature domain of the target project.

5. The cross-project software defect prediction method based on domain adaptation according to claim 1, characterized in that, The sum of the pairwise distances between all instances of the defective and defect-free categories is used as the loss value of the MMD function, calculated using the following formula: ; in, Indicates the category of the instance. =0 indicates no defects. =1 indicates a defect. This indicates whether the feature domain of the source project contains defects or not. This indicates whether the feature domain of the target project contains defects or not. This represents the distribution of defective or non-defective instances in the feature domain of the source project. This represents the distribution of defective or non-defective instances within the feature domain of the target project. This indicates the number of defective or non-defective instances in the feature domain of the source project. This indicates the number of defective or non-defective instances in the feature domain of the target project. This represents the high-dimensional feature vector extracted by the feature extractor.

6. The cross-project software defect prediction method based on domain adaptation according to claim 1, characterized in that, The step of assigning pseudo-labels to instances of the target item whose feature domain category is unknown during training, based on the feature vectors of the source item's feature domain instances and using the KNN classification algorithm, includes: The feature domain instance of the source project that is the nearest neighbor to the feature domain instance of the target project is obtained based on the distance metric function. The K source project feature domain instances that are most similar to the feature vectors of the target project feature domain instances are calculated using the KNN classification algorithm. The majority category labels among the K source project feature domain instances are then identified and used as pseudo labels for the target project feature domain instances.

7. The cross-project software defect prediction method based on domain adaptation according to claim 6, characterized in that, The distance metric function is expressed as: ; in, This represents the i-th instance in the feature domain of the source project. This represents the j-th instance in the feature domain of the target project. This represents the high-dimensional feature vector extracted by the feature extractor.