Heterogeneous software defect tendency prediction method based on deep learning

Through a heterogeneous software defect tendency prediction method based on deep learning, a common subspace transformation model is constructed and a total loss function is designed, which solves the problem of defect information loss after transforming the feature subspace in cross-project software defect prediction, and improves prediction performance and classification. performance, simplifying the implementation process.

CN118690243APending Publication Date: 2024-09-24BEIHANG UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410742100.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing cross-project software defect prediction methods suffer serious loss of defect information after transforming the feature subspace, resulting in low prediction accuracy and reduced classification performance, and cannot effectively handle this situation.

Method used

A heterogeneous software defect tendency prediction method based on deep learning is used to construct a common subspace transformation model to transform the defect data of the source project and the target project into the same common subspace. Combined with the multi-layer perceptron and the deep residual network, the overall design is Loss function, including distribution difference, classification effect and discriminative loss function, optimizes the training process to improve prediction performance.

Benefits of technology

It effectively improves the prediction performance of cross-project software defect prediction, solves the problem of defect information loss after transforming the feature subspace, improves the performance and classification performance of the defect prediction model, and simplifies the implementation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690243A
    Figure CN118690243A
Patent Text Reader

Abstract

The invention discloses a heterogeneous software defect tendency prediction method based on deep learning. The method comprises the following steps: preprocessing software defect measurement metadata in source project defect data; constructing a common subspace transformation model; transforming the source project defect data and the target project defect data into the same common subspace based on a common subspace transformation model; constructing a defect prediction classification model, and training the defect prediction classification model and the common subspace transformation model; and inputting the defect data of the target project into the trained defect prediction classification model to predict the software defect tendency of the target project. According to the method, the problem of defect information loss after feature subspace transformation is effectively solved, and the performance of a software defect prediction model is improved; and the method is simple and easy to implement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software defect prediction, and more specifically to a heterogeneous software defect tendency prediction method based on deep learning. Background Art

[0002] Software testing refers to the process of operating a program under specified conditions to discover program errors, measure software quality, and evaluate whether it meets design requirements. It involves the execution of software components or system components to evaluate one or more related attributes. It is one of the most important means of ensuring software quality (Software Quality Assurance, SQA). There is an 80 / 20 rule in the field of software testing, that is, 80% of the defects in the software exist in 20% of the modules. Testing the modules in the software one by one according to the software functions will lead to a waste of testing resources and a consumption of software development time.

[0003] The research on Software Defect Prediction (SDP) originated in the 1970s and is one of the most active research areas in software engineering. Today, software systems are becoming more and more complex, the number of software project source codes is increasing, and the frameworks used are more complex and diverse, so there are more possible defects. Accurately predicting and identifying software defects and making corrections in time can help improve the quality of software systems and avoid problems caused by errors after software release. Software defect prediction can analyze potential defective program modules in the project in the early stages of project development, assist in the allocation of test resources, ensure the completeness and rationality of the test process, and ultimately achieve the goal of improving the quality of software system products. Software defect prediction helps to reduce the time of software development and reduce the cost of software testing.

[0004] Building a software defect prediction model generally involves training the model on a given training data set, then evaluating the model's performance on a test data set, and then using the model to make predictions. There is a premise here that the distribution of the training data set, test data set, and target project data set are the same. Such software defect prediction can be called within-project defect prediction (WPDP). However, since new software projects do not have enough training data, it is impossible to collect enough defect data as a training set to train the model, making it impossible to make defect predictions. Therefore, it is a challenging problem to build a good prediction model for new projects. Since the distribution of defect data in historical projects may be very different from the distribution of the target data set of the current project, the prediction performance of the trained model is quite poor and cannot be applied in practice.

[0005] At present, many scholars have proposed different cross-project software defect prediction methods. For example, Ma et al. proposed "Transfer learning for cross-company software defect prediction" and proposed the transfer naive Bayes method using transfer learning technology. The TNB method is used for cross-project software defect prediction. The basic principle of TNB is: first measure the distribution characteristics of the target data set, then calculate the similarity between each sample in the source data and the target data set, then convert the similarity information into sample weights, and finally use the naive Bayes algorithm on the weighted source data for model training and prediction. Li et al. believe that nonlinearity and data imbalance will affect the prediction of cross-project software tendency, so they add kernel techniques and cost-sensitive learning to the CCA+ method at the same time and propose a cost-sensitive transfer canonical correlation analysis method "Cost-sensitive transfer kernel canonical correlation analysis for heterogeneous defect prediction[". Nam et al. introduced a classic transfer learning algorithm, namely transfer principal component analysis (TCA), into the field of cross-project software defect prediction. The basic principle of TCA is: use the maximum mean difference (MMD) as the distribution difference measurement indicator, and find a common feature subspace through spatial transformation to minimize the distribution difference between the source data and the target data. The author found that different data standardization methods have a great impact on the performance of TCA, so he extended it on the basis of TCA and proposed a transfer principal component analysis method "Transfer defect learning" that can automatically select data standardization methods. However, in the above literature, when aligning the source project measurement metadata and the target project measurement metadata through the transformation subspace, the cross-project heterogeneous software defect prediction based on feature space changes often only focuses on the difference in distribution characteristics of the source defect data and the target defect data, but fails to consider whether the transformed software measurement metadata still has good discrimination, that is, the classification performance of the transformed defect data.

[0006] Therefore, how to effectively deal with the problem of defect information loss after transforming the feature subspace and provide a method with higher prediction accuracy is an urgent problem that technical personnel in this field need to solve. Summary of the invention

[0007] In view of the above problems, the present invention provides a heterogeneous software defect tendency prediction method based on deep learning to at least solve some of the technical problems mentioned in the above background technology.

[0008] In order to achieve the above object, the present invention adopts the following technical solution:

[0009] A method for predicting heterogeneous software defect tendency based on deep learning includes the following steps:

[0010] Preprocess the software defect measurement metadata in the source project defect data;

[0011] Constructing a common subspace transformation model; based on the common subspace transformation model, transforming the source project defect data and the target project defect data into the same common subspace;

[0012] Constructing a defect prediction classification model, and training the defect prediction classification model and the common subspace transformation model;

[0013] The defect data of the target project is input into the trained defect prediction classification model to predict the software defect tendency of the target project.

[0014] Furthermore, the preprocessing specifically includes:

[0015] The Borderline-SMOTE method is used to process defect samples and non-defect samples in the software defect measurement metadata to balance the number of defect samples and non-defect samples.

[0016] The balanced software defect metric metadata is processed by deviation normalization to obtain normalized software defect metric metadata.

[0017] Furthermore, before preprocessing the software defect metric metadata, a preset number of defect samples and non-defect samples are converted into One-Hot encoding by random sampling.

[0018] Furthermore, the hidden layer of the common subspace transformation model includes a plurality of fully connected layers and a multi-layer perceptron;

[0019] The fully connected layer is used to analyze and output the input software defect metric metadata; each of the fully connected layers uses a linear rectification function as an activation function;

[0020] The multilayer perceptron includes multiple layers of neurons; each layer of neurons is fully interconnected with the next layer of neurons.

[0021] Furthermore, based on the common subspace transformation model, transforming the source project defect data and the target project defect data into the same common subspace specifically includes:

[0022] The source project defect data and the target project defect data are transformed into the same common subspace through the multi-layer perceptron; during the transformation process, a statistical feature alignment method is used to perform transfer learning on the source project defect data and the target project defect data.

[0023] Furthermore, the defect prediction classification model is constructed based on a deep residual network.

[0024] Furthermore, the Adam optimization algorithm is used as the optimizer for defect prediction classification model training.

[0025] Furthermore, the total loss function in the training process includes: a loss function based on distribution difference, a loss function of classification effect, and a loss function of the discriminability of the transformed software defect data.

[0026] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a method for predicting heterogeneous software defect tendency based on deep learning, which has the following beneficial effects:

[0027] The present invention establishes a heterogeneous cross-project software defect prediction model based on deep learning, and provides a solution for improving the prediction performance of the cross-project software defect prediction method. By analyzing the influence of transformation metrics on defect prediction results and adding the influence to the prediction algorithm, the prediction algorithm is improved. A loss function is designed based on the information distinguishability after the software defect data is transformed, which effectively handles the problem of defect information loss after the feature subspace is transformed, thereby improving the performance of the defect prediction model. Moreover, the method is simple and easy to implement.

[0028] The present invention designs a loss function corresponding to the distinguishability of the transformed metric metadata, adds it to the loss function of the original defect prediction algorithm based on the distribution difference of the transformed defect data, constructs a new total loss function, and solves the problem of reduced classification performance of the defect data after special transformation.

[0029] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the present invention.

[0030] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0032] Figure 1 A schematic flow chart of a method for predicting defect tendency of heterogeneous software based on deep learning provided in an embodiment of the present invention.

[0033] Figure 2 A schematic diagram of the framework of a heterogeneous software defect tendency prediction method based on deep learning provided in an embodiment of the present invention.

[0034] Figure 3 A schematic diagram of the network structure of the common subspace transformation model provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0036] The embodiment of the present invention discloses a method for predicting heterogeneous software defect tendency based on deep learning, the main framework of which is as follows: Figure 2 As shown: After the source data and target data are input, the features are transformed through a shared deep network and finally output through a classifier.

[0037] The specific implementation process is as follows Figure 1 As shown:

[0038] Preprocess the software defect measurement metadata in the source project defect data;

[0039] Construct a common subspace transformation model; based on the common subspace transformation model, transform the source project defect data and the target project defect data into the same common subspace;

[0040] Construct a defect prediction classification model, and train the defect prediction classification model and the common subspace transformation model;

[0041] The defect data of the target project is input into the trained defect prediction classification model to predict the defects of each module in the target project.

[0042] The following is a detailed description of each of the above steps.

[0043] 1. Obtain software defect measurement metadata from the source project defect data, and preprocess the software defect measurement metadata; the preprocessing specifically includes:

[0044] (1) The Borderline-SMOTE method is used to process defect samples and non-defect samples in the software defect measurement metadata to achieve a balance between the number of defect samples and non-defect samples;

[0045] Software defect measurement metadata refers to various indicators and attributes used to measure and evaluate software defects. In order to avoid the impact of data imbalance of software defect measurement metadata on the prediction of software defect tendency, the present invention adopts the Borderline-SMOTE method to solve the category imbalance problem of software defect measurement metadata and narrow the gap in the number of different sample sets. Specifically, the Borderline-SMOTE method is used to process defect samples and non-defect samples in software defect measurement metadata so that the number of defect samples and non-defect samples is balanced.

[0046] (2) Using deviation normalization to process the balanced software defect metric metadata to obtain normalized software defect metric metadata;

[0047] Deviation standardization is a commonly used data standardization (i.e., normalization) method and a basic work of data mining. Different evaluation indicators often have different dimensions and dimensional units, which will affect the results of data analysis. In order to eliminate the dimensional impact between indicators, data standardization processing is required to solve the comparability between data indicators; after the original data is processed by data standardization, each indicator is at the same order of magnitude and is suitable for comprehensive comparative evaluation; specifically, in an embodiment of the present invention, deviation standardization is used to perform linear transformation processing on the balanced software defect metric metadata so that the result value is mapped to between [0-1].

[0048] (3) Before the above-mentioned preprocessing of the software defect metric metadata, a preset number (e.g., 30%) of partial indicator data of the software defect metric metadata (i.e., defect samples and non-defective samples) are randomly sampled and converted into One-Hot encoding to facilitate parameter training of the software defect prediction classification model and accelerate the model training speed and convergence speed; wherein, One-Hot encoding is also called unique hot encoding and one-bit effective encoding; One-Hot encoding is the representation of categorical variables as binary vectors; this first requires mapping categorical values ​​to integer values; then, each integer value is represented as a binary vector, except for the index of the integer, it is all zero value, which is marked as 1.

[0049] 2. Construct a common subspace transformation model, and transform the source project defect data and the target project defect data into the same common subspace through the common subspace transformation model, which specifically includes the following contents:

[0050] (1) Through the multi-layer perceptron in the common subspace transformation model, the source project defect data and the target project defect data are transformed into the same common subspace, so as to facilitate the subsequent software defect tendency prediction; this process also realizes the transformation of the software defect metric metadata in the source project defect data into the metric metadata feature space of the same dimension;

[0051] The network structure diagram of the above common subspace transformation model is as follows: Figure 3 As shown: the leftmost layer is the input layer, the rightmost layer is the output layer, and the middle layer includes 4 hidden layers. The input layer receives the original data and inputs it into the network. The hidden layer performs feature extraction and representation learning, which mainly includes convolutional layers and residual modules. Finally, the final prediction result is generated through the output layer. The hidden layer includes multiple fully connected layers and multi-layer perceptrons, among which the fully connected layer is used to analyze and output the input software defect metric metadata; each fully connected layer uses a linear rectified function (Rectified Linear Unit, ReLU), also known as a rectified linear unit, as an activation function; the linear rectified function can be more efficient in gradient descent and back propagation: avoiding the problems of gradient explosion and gradient disappearance; at the same time, it can also simplify the calculation process: the common subspace transformation model in the embodiment of the present invention is not affected by other complex activation functions (such as exponential functions), and the dispersion of activity reduces the overall calculation cost of the neural network.

[0052] Perception is the basis of neural network and SVM (support vector machine), and is a binary linear classification model; Multilayer Perceptron (MLP) is a feedforward artificial neural network model, which maps multiple input data sets to a single output data set; Multilayer Perceptron introduces one or more hidden layers on the basis of single-layer neural network; The hidden layer is located between the input layer and the output layer; The learning process of the multilayer perceptron machine uses the backpropagation error algorithm to iteratively adjust the network parameters. This algorithm is derived from the least squares method, so that the average error between the input sample label and the corresponding output node category judgment is minimized; Multilayer Perceptron is a type of feedforward (artificial) neural network and an extension of the perceptron. It consists of at least three layers of functional neurons (input layer, hidden layer, output layer), each layer of neurons is fully interconnected with the next layer of neurons, and there is no same-layer connection or cross-layer connection between neurons. The hidden layer or hidden layer is between the input layer and the output layer, and the signal is gradually processed, feature extracted, and representation learning is mainly performed through nonlinear function compounding.

[0053] (2) In the process of transforming the source project defect data and the target project defect data into the same common subspace, a statistical feature alignment method is used to perform transfer learning on the source project defect data and the target project defect data, thereby narrowing the distribution difference between the source project defect data and the target project defect data, and making the source project defect data and the target project defect data have similar distributions;

[0054] Specifically, subspace learning is a subfield of machine learning that uses algorithms to learn features at different levels in order to model complex relationships between data. The statistical feature alignment method is a subspace learning method for transfer learning. By transforming and aligning the statistical features of the source project defect data and the target project defect data, the distribution difference between the source project defect data and the target project defect data is reduced, so that the classifier that performs well on the source project defect data can also perform well on the target project defect data.

[0055] 3. Construct a defect prediction classification model, and train the defect prediction classification model and the above-mentioned common subspace transformation model; specifically, the following contents are included:

[0056] (1) Construct defect prediction classification model:

[0057] Deep residual network (ResNet) is used as the classification model of the defect prediction model. The Adam optimization algorithm that performs first-order gradient optimization on the random objective function based on adaptive low-order moment estimation is used as the optimizer for defect prediction classification model training.

[0058] The above-mentioned deep residual network (ResNet) is a type of convolutional neural network that is widely used. The main idea of ​​the residual network is to add a direct channel to the network. The structure of the residual network can extremely accelerate the training of the neural network, thereby effectively improving the accuracy of the model. The reason for this effect is that, on the one hand, the residual network can better fit the classification function to obtain higher classification accuracy, and on the other hand, the residual network can solve the problem of optimizing training when the number of network layers increases.

[0059] (2) The defect prediction classification model and the common subspace transformation model are trained simultaneously in the same context:

[0060] Training method: multi-task learning under the same context. The subspace transformation model converts the source project data and the target project data into a common subspace using a multi-layer perceptron. The defect prediction model is trained using the source project defect data, adjusting the network parameters, and then applied to the software defect data of the target project to predict the presence or absence of software defects in each module of the target project. "Same context" refers to hard parameter sharing: the most commonly used method for multi-task learning in neural networks. It is applied by sharing hidden layers between all tasks, while retaining several task-specific output layers, and using its own unique parameters in specific task layers (deeper layers of the neural network). In this case, the shared parameters are less likely to overfit (relative to non-shared parameters). The more tasks that are learned simultaneously, the more the model needs to find a representation that covers all tasks, and the less likely it is to overfit with the original task;

[0061] Training purpose: To reduce the distribution difference between the source project defect data and the target project defect data in the common subspace, pay attention to the distinguishability of the defect data after transformation, and improve the classification performance of the classifier on the defect data. Multi-task learning is performed to solve these problems.

[0062] Training process: The total loss function during training includes: the loss function based on distribution difference, the loss function of classification effect, and the loss function of the discriminability of software defect data after transformation; during the training process, the total loss function should be optimized to minimize the total loss function;

[0063] The above total loss function loss is expressed as:

[0064] loss=lossce +loss mmd / loss dis

[0065] loss mmd represents the loss function based on distribution difference, using the maximum mean discrepancy (MMD) to measure the distribution of source items X s With target project distribution X t similarities between;

[0066] loss ce Represents the loss function for measuring the effect of tendency prediction or classification. Categorical cross-entropy is used to evaluate the difference between the probability distribution obtained by the current training and the true distribution. It is mainly used to measure the difference information between two probability distributions, and softmax is used as the activation function of the output layer.

[0067] loss dis The loss function representing the discriminability of the transformed software defect data is calculated by calculating the variance of the transformed feature data set in each dimension and taking the mean as this indicator.

[0068] The training goal of deep learning networks is to reduce loss, that is, to reduce loss mmd And loss ce , increase loss dis ; Among them, loss mmd and loss dis Used to update the parameters of the feature transformation network shared by the source data and the target data, loss ce Used to update the parameters of the entire network.

[0069] The stopping conditions of the training process are set as follows: 1. Set the minimum number of training generations to exclude the situation where the evaluation indicators fluctuate greatly in the early stage; 2. Record the evaluation indicators of each training cycle; 3. At the end of each training cycle, compare the evaluation indicators after the end of the current training cycle with the evaluation indicators of the previous 20 cycles; 4. If the current evaluation indicator is less than the average value of the evaluation indicator of the previous 20 cycles, it is judged that the training of the model has entered convergence and the training model is stopped; otherwise, the model training continues.

[0070] 4. Input the defect data of the target project into the trained defect prediction classification model to predict the software defect tendency of the target project;

[0071] In another embodiment, the method further includes: in a heterogeneous cross-project software defect tendency prediction scenario, comparing the defect prediction classification model obtained by training with the total loss function with the model obtained by training with the loss function before adding the loss function that distinguishes the software defect data, and evaluating the performance of the defect prediction classification model after training in the present invention.

[0072] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0073] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for predicting heterogeneous software defect tendency based on deep learning, characterized in that: The steps include: Preprocess the software defect measurement metadata in the source project defect data; Constructing a common subspace transformation model; based on the common subspace transformation model, transforming the source project defect data and the target project defect data into the same common subspace; Constructing a defect prediction classification model, and training the defect prediction classification model and the common subspace transformation model; The defect data of the target project is input into the trained defect prediction classification model to predict the software defect tendency of the target project.

2. According to claim 1, a method for predicting heterogeneous software defect tendency based on deep learning is characterized in that: The pre-processing specifically includes: The Borderline-SMOTE method is used to process defect samples and non-defect samples in the software defect measurement metadata to balance the number of defect samples and non-defect samples. The balanced software defect metric metadata is processed by deviation normalization to obtain normalized software defect metric metadata.

3. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 2, characterized in that: Before preprocessing the software defect metric metadata, a preset number of defect samples and non-defect samples are converted into One-Hot encoding by random sampling.

4. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 1, characterized in that: The hidden layer of the common subspace transformation model includes multiple fully connected layers and multi-layer perceptrons; The fully connected layer is used to analyze and output the input software defect metric metadata; each of the fully connected layers uses a linear rectification function as an activation function; The multilayer perceptron includes multiple layers of neurons; each layer of neurons is fully interconnected with the next layer of neurons.

5. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 4, characterized in that: The transforming of the source project defect data and the target project defect data into the same common subspace based on the common subspace transformation model specifically includes: The source project defect data and the target project defect data are transformed into the same common subspace through the multi-layer perceptron; during the transformation process, a statistical feature alignment method is used to perform transfer learning on the source project defect data and the target project defect data.

6. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 1, characterized in that: The defect prediction classification model is constructed based on a deep residual network.

7. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 1, characterized in that: The Adam optimization algorithm is used as the optimizer for defect prediction classification model training.

8. The method for predicting heterogeneous software defect tendency based on deep learning according to claim 1, characterized in that: The total loss function in the training process includes: the loss function based on distribution difference, the loss function of classification effect, and the loss function of the discriminability of software defect data after transformation.

Citation Information

Patent Citations

  • Heterogeneous cross-project software defect prediction method based on nuclear spectrum mapping migration integration

    CN110659207A

  • Weak label industrial defect image classification method based on improved deep residual network

    CN116091502A

  • Dry cleaning device

    KR1020250039649A