Defect prediction model establishing method and defect prediction method and device

Through the annotation and update of transfer learning and machine learning models, the problem of low accuracy due to the difference in data feature distribution in cross-project defect prediction is solved, and the accuracy and accuracy of defect prediction are improved.

CN119690813APending Publication Date: 2025-03-25CHINA PETROLEUM & CHEMICAL CORP +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311228153.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-21
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The existing cross-project defect prediction methods have problems due to the differences in the data characteristics of different projects and the low prediction accuracy.

Method used

By obtaining the defect prediction model of the source project software and the project data set of the target project software, performing defect annotation, determining the machine learning model, annotating unlabeled data, and updating the parameters of the defect prediction model through transfer learning, the defect prediction model of the target project software is obtained.

Benefits of technology

The prediction accuracy of the defect prediction model is improved, the accuracy of defect prediction is enhanced, and it can better adapt to the data feature distribution of different projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690813A_ABST
    Figure CN119690813A_ABST
Patent Text Reader

Abstract

The invention provides a defect prediction model establishing method and a defect prediction method and device. The defect prediction model establishing method comprises the steps of obtaining a defect prediction model of source project software; a project data set of target project software is obtained, defect labeling is conducted on at least part of project data, an initial labeling data set is obtained, and the distance between the target project software and the source project software is smaller than a preset distance; determining a machine learning model based on the initial annotation data set; marking unmarked data based on the machine learning model to obtain a marked data set; and carrying out transfer learning on the basis of the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software, so that the defect prediction model can be better trained, the prediction precision of the established defect prediction model is higher, and the defect prediction accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer program technology, and in particular to a method for establishing a defect prediction model, a defect prediction method and a device. Background Art

[0002] Defect prediction is to predict defects in software systems through certain technical methods, so as to guide developers to find and fix defects and ensure software quality. There are two methods for software defect prediction. One is to predict defects through the software history repository, and the other is to predict software defects by building models through other similar projects, which is also called cross-project defect prediction. The first defect prediction method has certain requirements for the historical version data of the software. For software that does not have many historical versions and insufficient data, researchers will use cross-project defect prediction methods to predict defects in the software. However, the existing cross-project defect prediction has certain limitations and certain requirements for target training data, or there are problems such as low prediction accuracy due to differences in the distribution of data features of different projects. Summary of the invention

[0003] In response to the above problems, the present application provides a method for establishing a defect prediction model, a defect prediction method and a device, which can make the prediction accuracy of the established defect prediction model higher, thereby improving the accuracy of defect prediction.

[0004] The present application provides a method for establishing a defect prediction model, comprising:

[0005] Obtain defect prediction models for source project software;

[0006] Acquire a project data set of target project software, and annotate defects on at least part of the project data to obtain an initial annotated data set, wherein a distance between the target project software and the source project software is less than a preset distance;

[0007] Determine a machine learning model based on the initial labeled data set;

[0008] Annotate the unlabeled data based on the machine learning model to obtain a labeled data set;

[0009] Transfer learning is performed based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0010] In some embodiments, obtaining the defect prediction model of the source project software includes:

[0011] Get the training dataset of the source project software;

[0012] Building an initial model based on the training data set;

[0013] The initial model is trained based on the training data set to obtain a defect prediction model for the source project software.

[0014] In some embodiments, the initial model includes an input layer, a convolutional layer, an attention layer, a pooling layer, a fully connected layer, and an activation function layer connected in sequence.

[0015] In some embodiments, determining a machine learning model based on the initial annotated data set includes:

[0016] Building a neural network model based on the initial labeled data set;

[0017] The neural network model is trained based on the initial labeled data set to obtain the machine learning model.

[0018] In some embodiments, performing transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software includes:

[0019] Filtering the annotated data set based on the filtering condition to obtain a target annotated data set;

[0020] Transfer learning is performed based on the target annotated data set and the defect prediction model of the source project software to update the parameters of the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0021] The present application provides a defect prediction method, which is applied to a defect prediction model established by any of the above methods, and the method includes:

[0022] Obtain project data of target project software;

[0023] The project data is input into a defect prediction model to determine defects in the target project software.

[0024] The present application provides a device for establishing a defect prediction model, including:

[0025] A first acquisition module is used to acquire a defect prediction model of source project software;

[0026] A second acquisition module is used to acquire a project data set of a target project software, and to annotate defects on at least a portion of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance;

[0027] A first training module, configured to determine a machine learning model based on the initial annotated data set;

[0028] A labeling module, used to label the unlabeled data based on the machine learning model to obtain a labeled data set;

[0029] The transfer learning module is used to perform transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0030] The embodiment of the present application provides a defect prediction device, which is applied to a defect prediction model established by any of the methods described above, including:

[0031] The third acquisition module is used to acquire the project data of the target project software;

[0032] The prediction module is used to input the project data into a defect prediction model to determine the defects of the target project software.

[0033] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, any one of the above-mentioned methods for establishing a defect prediction model or the above-mentioned defect prediction method is executed.

[0034] An embodiment of the present application provides a storage medium, which stores a computer program that can be executed by one or more processors and can be used to implement any of the above-mentioned methods for establishing a defect prediction model or the above-mentioned defect prediction methods.

[0035] The present application provides a method for establishing a defect prediction model, a defect prediction method and a device, which obtain the defect prediction model of the source project software; obtain the project data set of the target project software, and perform defect annotation on at least part of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance; determine a machine learning model based on the initial annotated data set; annotate unlabeled data based on the machine learning model to obtain an annotated data set; perform transfer learning based on the annotated data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software, which can make the defect prediction model better trained and the established defect prediction model have higher prediction accuracy, thereby improving the accuracy of defect prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Hereinafter, the present application will be described in more detail based on embodiments and with reference to the accompanying drawings.

[0037] Figure 1 A schematic diagram of an implementation flow of a method for establishing a defect prediction model provided in an embodiment of the present application;

[0038] Figure 2 A schematic diagram of the structure of an initial model provided in an embodiment of the present application;

[0039] Figure 3 A schematic diagram of the implementation process of a defect prediction method provided for an example of this application;

[0040] Figure 4 A schematic diagram of an implementation flow of a method for establishing a defect prediction model provided in an embodiment of the present application;

[0041] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0042] In the drawings, the same reference numerals are used for the same components, and the drawings are not drawn to scale. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0044] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0045] If similar descriptions of "first\second\third" appear in the application documents, the following instructions will be added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0047] Before introducing the embodiments of the present application, a brief introduction to the related technologies is given:

[0048] In recent years, the attention in this field has gradually increased, and there are more and more innovative studies related to it. Turhan et al. used the nearest neighbor filter to calculate the Euclidean distance between the source project data and the target project, and selected high-value data in the source project to solve the problem of cross-project defect prediction, but the prediction performance of this method was not ideal; Ma et al. proposed a defect prediction method TNB based on instance weights, adjusted the conditional probability of each instance in the source project, set the relevant weights, and completed the defect prediction, but the applicability of this method was not high, and it was only effective for naive Bayes classification. In view of the problem that the data distribution between different projects has certain differences, Nam et al. proposed a cross-project defect prediction method based on feature mapping. This method first finds the feature space of the target project and the source project, based on minimizing the data distribution distance, and then maps the target project and the source project to the space, thereby completing the defect prediction. In order to improve the performance of cross-project defect prediction, Panichella et al. proposed a defect prediction method CODEP that mixes multiple machine learning algorithms. The machine learning algorithms used in the method are different and complementary, which has a certain role in improving the defect prediction performance, but it involves many methods and the cost of the entire algorithm is high. Ni Chao et al. divided the prediction into two stages: feature migration and instance migration, and proposed a cross-project defect prediction method FeCTrA. Empirical results show that the prediction performance of this method is better than the prediction method that only considers a single stage. Chen Shu et al. proposed a cross-project software defect prediction method that combines machine learning with instance weighting. Instance weights were added during parameter learning to achieve the reuse of sample data. Fan Guisheng et al. proposed a defect prediction model DE-EACPDP based on differential evolution, which introduced defect density-related indicators in the model optimization objectives to complete the defect prediction of the target software. Although researchers have conducted a lot of research on cross-project defect prediction and proposed a variety of defect prediction methods, these methods have certain limitations, certain requirements for target training data, etc., or there are problems such as low prediction accuracy due to differences in the distribution of data features in different projects.

[0049] Based on the problems existing in the related art, the embodiment of the present application provides a method for establishing a defect prediction model, which is applied to electronic devices, such as computers, mobile terminals, etc. The functions implemented by the method for establishing a defect prediction model provided in the embodiment of the present application can be implemented by calling program codes by a processor of the electronic device, wherein the program codes can be stored in a computer storage medium.

[0050] Embodiment 1

[0051] The present application embodiment provides a method for establishing a defect prediction model. Figure 1 A schematic diagram of the implementation flow of a method for establishing a defect prediction model provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, including:

[0052] Step S1, obtaining a defect prediction model of source project software.

[0053] In the embodiment of the present application, the source project software may have a large amount of source project data, and the defect prediction model is trained by the source project data. The input of the defect prediction model of the source project software is the source project data, and the output is the defect of the source project software.

[0054] In the embodiment of the present application, step S1 can be implemented by the following steps:

[0055] Step S11, obtaining a training data set of the source project software.

[0056] In an embodiment of the present application, the training data in the training data set includes source project data and defect labels.

[0057] In an embodiment of the present application, the electronic device may obtain a training data set of the source project software from a server.

[0058] Step S12: constructing an initial model based on the training data set.

[0059] In the embodiment of the present application, the initial model adds an attention mechanism based on the deep network model. Figure 2 A schematic diagram of the structure of an initial model provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the initial model includes: an input layer, a convolutional layer, an attention layer, a pooling layer, a fully connected layer and an activation function layer which are connected in sequence.

[0060] In an embodiment of the present application, by adding an attention layer, when there are many feature dimensions, weights can be introduced to determine the relevance of each dimension of the input embedding vector, and importance weights are assigned to these different features. These features can determine the most relevant aspects while ignoring noise and redundancy in the input. The final representation is a weighted combination of these multiple representations and their attention weights.

[0061] In the embodiment of the present application, adding an attention layer can reduce the impact of useless features on the initial model.

[0062] Step S13, training the initial model based on the training data set to obtain a defect prediction model for the source project software.

[0063] In the embodiment of the present application, the training data set may include: source project data and defect labels. The initial model may be trained with the source project data as the input of the initial model and the defect labels as the output of the initial model, thereby adjusting the parameters of the initial model to obtain a defect prediction model of the source project software.

[0064] Step S2, obtaining a project data set of the target project software, annotating defects on at least part of the project data, and obtaining an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance.

[0065] In the embodiment of the present application, the electronic device can obtain a project data set from a server of the target project software. The project data in the project data set does not have a defect label. The user can use the electronic device to mark defects for part of the project data, thereby adding defect labels to the project data, and can only mark a small amount of project data to obtain an initial marked data set.

[0066] In the embodiment of the present application, the distance between the target project software and the source project software is less than a preset distance, indicating that the target project software and the source project software are relatively similar.

[0067] Step S3, determining a machine learning model based on the initial annotated data set.

[0068] In an embodiment of the present application, a neural network model can be constructed based on the initial annotated data set; the neural network model is trained based on the initial annotated data set to obtain the machine learning model.

[0069] In an embodiment of the present application, the project data in the initial annotated data set is used as input, and the annotated defect labels are used as output to train the neural network model, thereby obtaining a machine learning model.

[0070] Step S4: label the unlabeled data based on the machine learning model to obtain a labeled data set.

[0071] In the embodiment of the present application, the labeled data can be input into the neural network model for re-training and then labeled again.

[0072] In the embodiment of the present application, the machine learning model is retrained with the updated labeled data. This process can be repeated multiple times until the accuracy of the machine learning model meets the requirements.

[0073] Step S5, performing transfer learning based on the annotated data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0074] In an embodiment of the present application, the annotated data set can be filtered based on the filtering conditions to obtain a target annotated data set; transfer learning can be performed based on the target annotated data set and the defect prediction model of the source project software to update the parameters of the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0075] In the embodiment of the present application, the screening conditions can be set, for example, duplicate data can be removed.

[0076] In the embodiment of the present application, the data of the defect prediction model and the labeled data set come from different projects, and their feature distributions also have certain differences, but they belong to related fields. Transfer learning can be compatible with these two types of data and better integrate them to solve the problems of small amount of label data and data drift in the target project.

[0077] The present application provides a method for establishing a defect prediction model, which comprises the following steps: obtaining a defect prediction model of a source project software; obtaining a project data set of a target project software, and annotating defects of at least part of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance; determining a machine learning model based on the initial annotated data set; annotating unlabeled data based on the machine learning model to obtain an annotated data set; and performing transfer learning based on the annotated data set and the defect prediction model of the source project software to obtain a defect prediction model of the target project software, which can enable the defect prediction model to be better trained and the prediction accuracy of the established defect prediction model to be higher, thereby improving the accuracy of defect prediction.

[0078] Embodiment 2

[0079] Based on the above embodiments, the present application provides a defect prediction method, which is applied to electronic devices, such as computers, mobile terminals, etc. The functions implemented by the defect prediction method provided in the present application embodiment can be implemented by calling program codes by a processor of the electronic device, wherein the program codes can be stored in a computer storage medium.

[0080] The present application embodiment further provides a defect prediction method, which is applied to a defect prediction model established by any of the above methods. Figure 3 A schematic diagram of the implementation process of a defect prediction method provided for the example of this application, such as Figure 3 As shown, the method includes:

[0081] Step S11, obtaining project data of the target project software.

[0082] In the embodiment of the present application, the electronic device can obtain the project data of the target project software from the server of the target project software.

[0083] Step S12: input the project data into a defect prediction model to determine the defects of the target project software.

[0084] A defect prediction method provided in an embodiment of the present application can improve the accuracy of defect prediction by pre-training a defect prediction model and making the prediction accuracy of the established defect prediction model higher.

[0085] Embodiment 3

[0086] Based on the aforementioned embodiments, the embodiments of the present application further provide a method for establishing a defect prediction model, using a cross-project defect prediction model that combines active transfer with an attention mechanism. In view of the problems that the target project lacks labeled data and the time cost of manually labeling data is too high, the embodiments of the present application propose to actively complete the labeling of project data in a semi-supervised manner through active learning; in view of the differences in data feature distribution between the source project and the target project, data imbalance, and other problems, the present invention proposes to construct a defect prediction model for the target project through transfer learning to solve the problem of data feature differences when predicting defects in the target project; in view of the problem of low accuracy in cross-project software defect prediction, the present invention proposes to construct a software defect prediction model based on an attention mechanism, and to improve the accuracy of cross-software defect prediction by deeply learning project defect features through the attention mechanism.

[0087] Figure 4 A schematic diagram of the implementation flow of a method for establishing a defect prediction model provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, including:

[0088] Build the initial model:

[0089] In the embodiment of the present application, the initial model adds an attention mechanism on the basis of the deep network model. When there are many feature dimensions, weights are introduced to determine the relevance of each dimension of the input embedding vector, and importance weights are assigned to these different features. These features can determine the most relevant aspects while ignoring the noise and redundancy in the input. The final representation is a weighted combination of these multiple representations and their attention weights.

[0090] Train the model:

[0091] In an embodiment of the present application, a deep attention network model is constructed by training with source project data (the same as the defect prediction model of the source project software in the above embodiment).

[0092] The target project labels data through active learning:

[0093] In the embodiment of the present application, a small amount of data is first manually labeled, and then a data pool is constructed with the labeled data and the unlabeled data, and a model is constructed for the labeled data using a machine learning algorithm. The unlabeled data is labeled through active learning, and the labeled data set is updated at the same time. The machine learning model is retrained using the updated labeled data set. This process is repeated multiple times until the conditions are met. Then, high-value data is filtered through the filtering strategy of active learning to prepare for subsequent cross-project data transfer learning.

[0094] Using feature map based transfer methods;

[0095] In the embodiment of the present application, transfer learning is performed on the source project data and the high-value data screened by active learning. The two types of data come from different projects, and their feature distributions are also somewhat different, but they belong to related fields. Transfer learning can be compatible with these two types of data, better integrate them, and solve the problem of small amount of labeled data and data drift in the target field.

[0096] Data weights updated, model adjusted;

[0097] In the embodiment of the present application, the adjustment and update of data weights and models are completed by migrating the model.

[0098] Predict software defects in target projects;

[0099] In the embodiment of the present application, the prediction of software defects of the target project is achieved through the completed migration model.

[0100] The method provided in the embodiment of the present application adds an attention mechanism to the defect prediction model, assigns weights to different features, and reduces the impact of useless features on the prediction results. At the same time, the unlabeled data in the target project is marked and updated using the active learning method. High-value data in the labeled data is selected, and transfer learning is performed together with the source project data of the same type to complete the data weight update and model adjustment, so as to achieve software defect prediction for the software target project.

[0101] Embodiment 4

[0102] Based on the foregoing embodiments, the embodiments of the present application provide a device for establishing a defect prediction model. The modules included in the device and the units included in each module can be implemented by a processor in a computer device; of course, they can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU, Central Processing Unit), a microprocessor (MPU, Microprocessor Unit), a digital signal processor (DSP, Digital Signal Processing) or a field programmable gate array (FPGA, Field Programmable Gate Array), etc.

[0103] The embodiment of the present application provides a device for establishing a defect prediction model, and the device for establishing a defect prediction model includes:

[0104] A first acquisition module is used to acquire a defect prediction model of source project software;

[0105] A second acquisition module is used to acquire a project data set of a target project software, and to annotate defects on at least a portion of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance;

[0106] A first training module, configured to determine a machine learning model based on the initial annotated data set;

[0107] A labeling module, used to label the unlabeled data based on the machine learning model to obtain a labeled data set;

[0108] The transfer learning module is used to perform transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0109] In some embodiments, obtaining the defect prediction model of the source project software includes:

[0110] Get the training dataset of the source project software;

[0111] Building an initial model based on the training data set;

[0112] The initial model is trained based on the training data set to obtain a defect prediction model for the source project software.

[0113] In some embodiments, the initial model includes an input layer, a convolutional layer, an attention layer, a pooling layer, a fully connected layer, and an activation function layer connected in sequence.

[0114] In some embodiments, determining a machine learning model based on the initial annotated data set includes:

[0115] Building a neural network model based on the initial labeled data set;

[0116] The neural network model is trained based on the initial labeled data set to obtain the machine learning model.

[0117] In some embodiments, performing transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software includes:

[0118] Filtering the annotated data set based on the filtering condition to obtain a target annotated data set;

[0119] Transfer learning is performed based on the target annotated data set and the defect prediction model of the source project software to update the parameters of the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0120] It should be noted that in the embodiments of the present application, if the above-mentioned method for establishing the defect prediction model is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM, Read Only Memory), a magnetic disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0121] Accordingly, an embodiment of the present application provides a storage medium on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps in the method for establishing a defect prediction model provided in the above embodiment are implemented.

[0122] Embodiment 5

[0123] Based on the foregoing embodiments, the embodiments of the present application provide a defect prediction device, and the modules included in the device, as well as the units included in each module, can be implemented by a processor in a computer device; of course, they can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU, Central Processing Unit), a microprocessor (MPU, Microprocessor Unit), a digital signal processor (DSP, Digital Signal Processing) or a field programmable gate array (FPGA, Field Programmable Gate Array), etc.

[0124] The embodiment of the present application provides a defect prediction device, the defect prediction device comprising:

[0125] The third acquisition module is used to acquire the project data of the target project software;

[0126] The prediction module is used to input the project data into a defect prediction model to determine the defects of the target project software.

[0127] It should be noted that in the embodiments of the present application, if the above-mentioned defect prediction method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM, Read Only Memory), a disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0128] Accordingly, an embodiment of the present application provides a storage medium on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps in the defect prediction method provided in the above embodiment are implemented.

[0129] Embodiment 6

[0130] An embodiment of the present application provides an electronic device; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5As shown, the electronic device 700 includes: a processor 701, at least one communication bus 702, a user interface 703, at least one external communication interface 704, and a memory 705. The communication bus 702 is configured to realize the connection and communication between these components. The user interface 703 may include a display screen, and the external communication interface 704 may include a standard wired interface and a wireless interface. The processor 701 is configured to execute the program of the method for establishing a defect prediction model or the method for predicting a defect stored in the memory to implement the steps in the method for establishing a defect prediction model or the steps in the method for predicting a defect provided in the above embodiment.

[0131] A method for establishing a defect prediction model, comprising:

[0132] Obtain defect prediction models for source project software;

[0133] Acquire a project data set of target project software, and annotate defects on at least part of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance;

[0134] Determine a machine learning model based on the initial labeled data set;

[0135] Annotate the unlabeled data based on the machine learning model to obtain a labeled data set;

[0136] Transfer learning is performed based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0137] In some embodiments, obtaining the defect prediction model of the source project software includes:

[0138] Get the training dataset of the source project software;

[0139] Building an initial model based on the training data set;

[0140] The initial model is trained based on the training data set to obtain a defect prediction model for the source project software.

[0141] In some embodiments, the initial model includes an input layer, a convolutional layer, an attention layer, a pooling layer, a fully connected layer, and an activation function layer connected in sequence.

[0142] In some embodiments, determining a machine learning model based on the initial annotated data set includes:

[0143] Building a neural network model based on the initial labeled data set;

[0144] The neural network model is trained based on the initial labeled data set to obtain the machine learning model.

[0145] In some embodiments, performing transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software includes:

[0146] Filtering the annotated data set based on the filtering condition to obtain a target annotated data set;

[0147] Transfer learning is performed based on the target annotated data set and the defect prediction model of the source project software to update the parameters of the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

[0148] A defect prediction method, applied to a defect prediction model established by any of the above methods, comprising:

[0149] Obtain project data of target project software;

[0150] The project data is input into a defect prediction model to determine defects in the target project software.

[0151] The description of the above electronic device and storage medium embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the computer device and storage medium embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0152] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0153] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0154] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0155] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0156] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0157] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read Only Memory), disks or optical disks, etc. Various media that can store program codes.

[0158] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a controller to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0159] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for establishing a defect prediction model, characterized in that: include: Obtain defect prediction models for source project software; Acquire a project data set of target project software, and annotate defects on at least part of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance; Determine a machine learning model based on the initial labeled data set; Annotate the unlabeled data based on the machine learning model to obtain a labeled data set; Transfer learning is performed based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

2. The method according to claim 1, characterized in that The step of obtaining the defect prediction model of the source project software includes: Get the training dataset of the source project software; Building an initial model based on the training data set; The initial model is trained based on the training data set to obtain a defect prediction model for the source project software.

3. The method according to claim 2, characterized in that The initial model includes an input layer, a convolutional layer, an attention layer, a pooling layer, a fully connected layer and an activation function layer which are connected in sequence.

4. The method according to claim 1, characterized in that: The determining of the machine learning model based on the initial annotated data set includes: Building a neural network model based on the initial labeled data set; The neural network model is trained based on the initial labeled data set to obtain the machine learning model.

5. The method according to claim 1, characterized in that The performing transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software includes: Filtering the annotated data set based on the filtering condition to obtain a target annotated data set; Transfer learning is performed based on the target annotated data set and the defect prediction model of the source project software to update the parameters of the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

6. A defect prediction method, characterized in that: A defect prediction model established by the method according to any one of claims 1 to 5, the method comprising: Obtain project data of target project software; The project data is input into a defect prediction model to determine defects in the target project software.

7. A device for establishing a defect prediction model, characterized in that: include: A first acquisition module is used to acquire a defect prediction model of source project software; A second acquisition module is used to acquire a project data set of a target project software, and to annotate defects on at least a portion of the project data to obtain an initial annotated data set, wherein the distance between the target project software and the source project software is less than a preset distance; A first training module, configured to determine a machine learning model based on the initial annotated data set; A labeling module, used to label the unlabeled data based on the machine learning model to obtain a labeled data set; The transfer learning module is used to perform transfer learning based on the labeled data set and the defect prediction model of the source project software to obtain the defect prediction model of the target project software.

8. A defect prediction device, characterized in that: The defect prediction model established by the method according to any one of claims 1 to 5 comprises: The third acquisition module is used to acquire the project data of the target project software; The prediction module is used to input the project data into a defect prediction model to determine the defects of the target project software.

9. An electronic device, characterized in that: It comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method for establishing a defect prediction model as described in any one of claims 1 to 5 or the method for predicting defects as described in claim 6 is executed.

10. A storage medium, characterized in that: The computer program stored in the storage medium can be executed by one or more processors and can be used to implement the method for establishing a defect prediction model as described in any one of claims 1 to 5 or the defect prediction method as described in claim 6.