# A Software Defect Prediction Approach Based on BiGAN Anomaly Detection

Authors: Shenggang Zhang; Shujuan Jiang; Yue Yan
Journal: Scientific Programming
 (2022)

---

## Abstract

Software defect prediction usually is regarded as a classification problem, but classification models will face the class imbalance problem. Although there are many methods to solve the class imbalance problem, there is no method that can fundamentally solve the problem currently. In addition, supervised learning algorithms are always used to train defect prediction models, but obtaining a large amount of high-quality labelled data requires a lot of time and labor cost. In order to solve the class imbalance problem and eliminate the disadvantage of supervised learning, this paper attempts to predict software defects from a new perspective of anomaly detection. We propose an Anomaly Detection Model Based on BiGAN for Software Defect Prediction (ADGAN-SDP). The model proposed in this paper not only does not need to consider the class imbalance problem but also uses a semi-supervised method to train the model. Eight classification-based software defect prediction models are used as the baseline models and compared with ADGAN-SDP model. We evaluate ADGAN-SDP on 19 projects from NASA, AEEEM, and ReLink repositories. The experimental results show that the ADGAN-SDP model, which has a higher recall, outperforms all baseline models. It is suggested that the anomaly detection approach can be applied to the software defect prediction to fundamentally solve the class imbalance problem.


---

## Body

## 1. Introduction

Software defect prediction can find defects in advance to improve development efficiency and reduce development costs. Therefore, it remains a research highlight [1–3]. At present, most researchers usually use various classifiers to construct software defect prediction models, e.g., naive Bayes [4], decision tree (DT) [5], and support vector machine (SVM) [6], etc. However, these prediction models usually face the class imbalance problem, which leads to the prediction of defective samples as nondefect samples.Currently, researchers have proposed various methods to solve the class imbalance problem. These methods can be roughly divided into the following three kinds [7, 8]:(1)
Sampling methods. This kind of method refers to the use of various oversampling or undersampling methods to add the majority class samples or reduce minority class samples in order to balance the data.(2)
Cost-sensitive learning methods. This kind of method refers to giving different misclassification costs to minority and majority classes.(3)
Ensemble learning methods. This kind of method refers to improving the overall classification effect by integrating multiple weak classifiers.In addition, most studies use supervised methods to train prediction models in the field of software defect prediction, so a large amount of high-quality labelled data is required. However, it takes a lot of cost to obtain a large amount of high-quality labelled data. For this problem, SZZ and its improved algorithms are commonly used in the field of software defect prediction to achieve automatic data labelling [9, 10].


### 1.1. Motivation

Although researchers have proposed various methods to solve the class imbalance problem, all methods have certain deficiencies to solve the problem. Sampling methods will change the original data distribution which leads to over-fitting or under-fitting problems. Specifically, undersampling methods will lose some important information, while oversampling methods may give rise to over-fitting problems. In cost-sensitive learning methods, it is difficult to accurately determine the cost of the two types of misclassification. As for ensemble learning methods, each weak classification still faces the class imbalance problem. Therefore, to the best of our knowledge, there is no method to fundamentally solve the class imbalance problem.In order to obtain a large amount of high-quality labelled data, although researchers have tried to improve the original data labelling algorithm: SZZ [9], noise data are still inevitable. Therefore, it is a limitation for a given solution that tries to use supervised learning methods to train software defect prediction models.According to previous analysis, the current methods still do not completely solve the class imbalance problem which has a great impact on the prediction performance. However, the root cause of the class imbalance problem arises from treating the defect prediction problem as the classification problem and consequently using various classifiers to build software defect prediction models. In addition, a large amount of high-quality labelled data is often required to obtain predictive models with better performance. However, current techniques do not allow for a large amount of high-quality labelled data at the desired cost. Therefore, we need to discard the solution that treats the defect prediction problem as a classification problem. Motivated to study works of Nahar Neela et al. [11] and Afric et al. [12], we decided to treat software defect prediction as an anomaly detection.


### 1.2. Contribution

In this paper, we propose an Anomaly Detection Model Based on Bidirectional Generative Adversarial networks (BiGAN) [13] for Software Defect Prediction (ADGAN-SDP). It is worth noting that adversarial generative network (GAN) can capture the feature distribution of complex data and has made a lot of breakthroughs in the field of computer vision [14]. From the perspective of anomaly detection, nondefective samples are treated as normal samples, while defective samples are considered as abnormal samples. That is, only normal data samples (nondefective samples) are used to train the prediction model. ADGAN-SDP uses BiGAN to capture the feature distribution of nondefective samples, and determines whether a sample is a nondefective or defective sample according to the loss function. From the perspective of anomaly detection to build software defect prediction model, it not only does not need to consider the class imbalance problem that exists in the classification-based model but also uses a semi-supervised method to train the prediction model.In empirical research, we compare ADGAN-SDP with eight classification-based software defect prediction (C-SDP) models that are widely used in other software defect prediction researches. Experimental results show that the prediction performance of ADGAN-SDP is superior to eight C-SDP models selected in this paper.In summary, this paper makes the following contributions:(1)
This paper proposes an anomaly detection model based on bidirectional generative adversarial networks (BiGAN) for software defect prediction. ADGAN-SDP not only does not need to consider the class imbalance problem but also a semi-supervised method is used to train the prediction model.(2)
Through detailed empirical research, we find that the prediction performance of ADGAN-SDP outperforms eight C-SDP models. Thus, it is suggested that the anomaly detection can be applied to the software defect prediction to fundamentally solve the class imbalance problem.The rest of this paper is organized as follows. Section2 introduces researching background. Our model: ADGAN-SDP is elaborated in Section 3. We evaluate our model and analyze the results in Section 4. Section 5 discusses relevant experimental results and conclusions. Related works are presented in Section 6. The threats to validity are discussed in Section 7. We conclude in Section 8.


## 1.1. Motivation

Although researchers have proposed various methods to solve the class imbalance problem, all methods have certain deficiencies to solve the problem. Sampling methods will change the original data distribution which leads to over-fitting or under-fitting problems. Specifically, undersampling methods will lose some important information, while oversampling methods may give rise to over-fitting problems. In cost-sensitive learning methods, it is difficult to accurately determine the cost of the two types of misclassification. As for ensemble learning methods, each weak classification still faces the class imbalance problem. Therefore, to the best of our knowledge, there is no method to fundamentally solve the class imbalance problem.In order to obtain a large amount of high-quality labelled data, although researchers have tried to improve the original data labelling algorithm: SZZ [9], noise data are still inevitable. Therefore, it is a limitation for a given solution that tries to use supervised learning methods to train software defect prediction models.According to previous analysis, the current methods still do not completely solve the class imbalance problem which has a great impact on the prediction performance. However, the root cause of the class imbalance problem arises from treating the defect prediction problem as the classification problem and consequently using various classifiers to build software defect prediction models. In addition, a large amount of high-quality labelled data is often required to obtain predictive models with better performance. However, current techniques do not allow for a large amount of high-quality labelled data at the desired cost. Therefore, we need to discard the solution that treats the defect prediction problem as a classification problem. Motivated to study works of Nahar Neela et al. [11] and Afric et al. [12], we decided to treat software defect prediction as an anomaly detection.


## 1.2. Contribution

In this paper, we propose an Anomaly Detection Model Based on Bidirectional Generative Adversarial networks (BiGAN) [13] for Software Defect Prediction (ADGAN-SDP). It is worth noting that adversarial generative network (GAN) can capture the feature distribution of complex data and has made a lot of breakthroughs in the field of computer vision [14]. From the perspective of anomaly detection, nondefective samples are treated as normal samples, while defective samples are considered as abnormal samples. That is, only normal data samples (nondefective samples) are used to train the prediction model. ADGAN-SDP uses BiGAN to capture the feature distribution of nondefective samples, and determines whether a sample is a nondefective or defective sample according to the loss function. From the perspective of anomaly detection to build software defect prediction model, it not only does not need to consider the class imbalance problem that exists in the classification-based model but also uses a semi-supervised method to train the prediction model.In empirical research, we compare ADGAN-SDP with eight classification-based software defect prediction (C-SDP) models that are widely used in other software defect prediction researches. Experimental results show that the prediction performance of ADGAN-SDP is superior to eight C-SDP models selected in this paper.In summary, this paper makes the following contributions:(1)
This paper proposes an anomaly detection model based on bidirectional generative adversarial networks (BiGAN) for software defect prediction. ADGAN-SDP not only does not need to consider the class imbalance problem but also a semi-supervised method is used to train the prediction model.(2)
Through detailed empirical research, we find that the prediction performance of ADGAN-SDP outperforms eight C-SDP models. Thus, it is suggested that the anomaly detection can be applied to the software defect prediction to fundamentally solve the class imbalance problem.The rest of this paper is organized as follows. Section2 introduces researching background. Our model: ADGAN-SDP is elaborated in Section 3. We evaluate our model and analyze the results in Section 4. Section 5 discusses relevant experimental results and conclusions. Related works are presented in Section 6. The threats to validity are discussed in Section 7. We conclude in Section 8.


## 2. Background

This section mainly introduces the background knowledge of class imbalance problem and anomaly detection.


### 2.1. Class Imbalance Problem

For software defect data, more than 80% of defects usually exist in only 20% or less of the data. Therefore, the classifiers pay more attention to majority class and ignore minority class, which results in the class imbalance problem [7, 8]. For software defect prediction, when there is a class imbalance problem, the prediction model usually predicts defect samples as defect-free samples, which leads to higher accuracy and lower recall. Therefore, if the class imbalance problem is not well solved, it can greatly affect the performance of defect prediction. At present, the researchers have proposed various methods to solve the class imbalance problem. These methods can be roughly divided into two categories: data-level and algorithm-level methods. Data-level methods include miscellaneous data oversampling and undersampling methods. The algorithm-level methods solve the class imbalance problem by directly changing the training process to pay more attention to the minority class. Besides, ensemble learning is also a common method used to deal with the class imbalance problem.


### 2.2. Anomaly Detection

Anomaly detection refers to finding data that are inconsistent with the expected behavior pattern. Anomalies can be classified into three categories, namely, point anomalies, contextual anomalies, and collective anomalies [15]. As an important research field, anomaly detection has been extensively studied and many anomaly detection methods have been proposed [16, 17].Anomaly detection models can be divided into classification-based, clustering-based, nearest neighbor-based, statistics-based, information theory-based, and spectrum-based. In addition, some deep learning-based anomaly detection technology has also been proposed with the widespread application of deep learning [18]. The classification-based anomaly detection technology uses labelled training samples to train a classification model. Then, the trained classifier is used to classify the test samples into normal or abnormal. The anomaly detection technology based on clustering, which has been extensively studied by many researchers, usually uses various unsupervised or semi-supervised clustering algorithms for anomaly detection. According to the different types of clustering algorithms, the technology can be divided into two categories, namely, anomaly detection based on hierarchical clustering and partitional clustering. Anomaly detection technology based on the nearest neighbor usually needs to define a standard to calculate the similarity or distance between two samples firstly. Then, the correlation between the current sample and other samples is calculated to judge whether the current sample is an abnormal sample. Statistics-based anomaly detection technology uses given data (usually normal samples) and a statistical method to train a statistical model. Then, an unknown sample is tested to determine whether it belongs to the statistical model. If the probability of the sample belonging to the statistical model is lower, the sample is judged to be an abnormal sample; otherwise, the sample is a normal sample. Anomaly detection technology based on information theory assumes that if the data have anomalies, the information content of the data set will become irregular. Kolomogorov complexity, entropy, and relative entropy are usually used to analyze the information content to determine whether there are anomalies in the data. Spectrum-based anomaly detection technology assumes that normal samples and anomalies will present obvious differences when data can be embedded into a lower dimensional subspace [15]. PCA (Principal Component Analysis) is a commonly used technology to embed data to a low-dimensional subspace [19]. Anomaly detection technology based on deep learning has also made a lot of progress in recent years. Autoencoder [20] and GAN models [21] are usually used for anomaly detection. Reinforcement learning [22] can also be used to build anomaly detection models.


## 2.1. Class Imbalance Problem

For software defect data, more than 80% of defects usually exist in only 20% or less of the data. Therefore, the classifiers pay more attention to majority class and ignore minority class, which results in the class imbalance problem [7, 8]. For software defect prediction, when there is a class imbalance problem, the prediction model usually predicts defect samples as defect-free samples, which leads to higher accuracy and lower recall. Therefore, if the class imbalance problem is not well solved, it can greatly affect the performance of defect prediction. At present, the researchers have proposed various methods to solve the class imbalance problem. These methods can be roughly divided into two categories: data-level and algorithm-level methods. Data-level methods include miscellaneous data oversampling and undersampling methods. The algorithm-level methods solve the class imbalance problem by directly changing the training process to pay more attention to the minority class. Besides, ensemble learning is also a common method used to deal with the class imbalance problem.


## 2.2. Anomaly Detection

Anomaly detection refers to finding data that are inconsistent with the expected behavior pattern. Anomalies can be classified into three categories, namely, point anomalies, contextual anomalies, and collective anomalies [15]. As an important research field, anomaly detection has been extensively studied and many anomaly detection methods have been proposed [16, 17].Anomaly detection models can be divided into classification-based, clustering-based, nearest neighbor-based, statistics-based, information theory-based, and spectrum-based. In addition, some deep learning-based anomaly detection technology has also been proposed with the widespread application of deep learning [18]. The classification-based anomaly detection technology uses labelled training samples to train a classification model. Then, the trained classifier is used to classify the test samples into normal or abnormal. The anomaly detection technology based on clustering, which has been extensively studied by many researchers, usually uses various unsupervised or semi-supervised clustering algorithms for anomaly detection. According to the different types of clustering algorithms, the technology can be divided into two categories, namely, anomaly detection based on hierarchical clustering and partitional clustering. Anomaly detection technology based on the nearest neighbor usually needs to define a standard to calculate the similarity or distance between two samples firstly. Then, the correlation between the current sample and other samples is calculated to judge whether the current sample is an abnormal sample. Statistics-based anomaly detection technology uses given data (usually normal samples) and a statistical method to train a statistical model. Then, an unknown sample is tested to determine whether it belongs to the statistical model. If the probability of the sample belonging to the statistical model is lower, the sample is judged to be an abnormal sample; otherwise, the sample is a normal sample. Anomaly detection technology based on information theory assumes that if the data have anomalies, the information content of the data set will become irregular. Kolomogorov complexity, entropy, and relative entropy are usually used to analyze the information content to determine whether there are anomalies in the data. Spectrum-based anomaly detection technology assumes that normal samples and anomalies will present obvious differences when data can be embedded into a lower dimensional subspace [15]. PCA (Principal Component Analysis) is a commonly used technology to embed data to a low-dimensional subspace [19]. Anomaly detection technology based on deep learning has also made a lot of progress in recent years. Autoencoder [20] and GAN models [21] are usually used for anomaly detection. Reinforcement learning [22] can also be used to build anomaly detection models.


## 3. Our Approach

This part will elaborate the model proposed in this paper. We regard software defect prediction as anomaly detection with similar intuition and motivation as study works of Nahar Neela et al. [11] and Afric et al. [12], but our model is completely different from theirs. This section first briefly introduces the principle of anomaly detection based on BiGAN, then elaborates the ADGAN-SDP model.


### 3.1. Anomaly Detection Based on GAN

The adversarial generation network (GAN) can obtain complex high-dimensional data distribution, which implies that it can be applied for anomaly detection [23]. In the training phase, since only normal data samples are used to train the GAN model, a trained GAN should be able to obtain normal samples feature distribution. In the testing phase, the loss for normal data samples (nondefective data) is smaller, while the loss for abnormal data samples (defective data) is larger, thus abnormal data samples can be identified [23, 24].Bidirectional Generative Adversarial networks (BiGAN) [13] is employed in this paper, and the overall architecture of BiGAN is shown in Figure 1. Comparing with the general GAN model, BiGAN not only includes a generator G and a discriminator D but also has an encoder E that maps real input data to a latent encoding representation. By introducing encoder E, we not only acquire meaningful semantic representations related to given tasks but also the amount of calculation of the testing phase can be reduced. Specifically, the input of the discriminator of the GAN model usually is real data or generated data and the output is usually the probability value of current sample belonging to real samples. However, the input of discriminator of the BiGAN model is data array, that is [x, E (x)] or [G (z), z], the output is the same as the general GAN. The training objective function of the BiGAN model is similar to general GAN model, so its objective function can also be defined as a minimax function. The objective function is shown in equation (1). There are a variety of methods to train the BiGAN. In this paper, we adopted the strategy of simultaneously training the generator G and the encoder E according to suggestion of Dumoulin et al. [25].(1)minG,EmaxDVD=ElogX,EX+Elog1−DZ,GZ.Figure 1
The overall framework of BiGAN.The anomaly detection based on BiGAN includes two stages. First, BiGAN network model is trained according to the above training strategy using normal data samples (no-defective samples). Then, we need to define a convex function to measure the abnormality of the current sample, that is, if the output value of the function exceeds a predefined threshold, the current sample will be judged as an abnormal sample, otherwise a normal sample. The convex function is shown in the following equation.(2)Lt=αLGt+1−αLDt,where, in equation (2), t represents the current sample to be tested, LG represents the reconstruction loss of the sample t, LD represents the loss based on the discriminant model D of the sample t, and α represents the weight coefficient of two different losses. For detailed information about the anomaly detection model based on BiGAN, please refer to [24].


### 3.2. Software Defect Prediction Approach Based on BiGAN Anomaly Detection

Algorithm procedure of the ADGAN-SDP model can be divided into three stages: data preprocessing, model construction, and model prediction, which is shown in Figure2. Unlike most researches which usually regard software defect prediction as a classification problem, we try to construct the software defect prediction model from the perspective of anomaly detection in order to solve the class imbalance problem. Compared with the classification-based software defect prediction models, our model only needs nondefect samples as training data without considering the class imbalance problem. Our model uses BiGAN to model the nondefect samples, while the classification-based model needs to use classifiers such as random forests, support vector machines, and naive Bayes to model the overall samples. In the prediction stage, our model needs to manually specify a threshold while the classification-based model does not need. In contrast to study works of Nahar Neela et al. [11] and Afric et al. [12], ADGAN-SDP uses BiGAN to build the anomaly detection model so that it can better capture the characteristics of nondefect samples.Figure 2
The overall framework of ADGAN-SDP.In the first stage, we need to perform some necessary data preprocessing (feature selection, data normalization, etc.). In the second stage, the BiGAN model is trained with nondefective samples, so that the distribution characteristics of normal data samples (nondefective samples) can be obtained. In the third stage, we predict whether the current sample contains defects by comparing the loss value of the sample with the predefined threshold [24]. The detail is shown in Algorithm 1.As shown in Algorithm 1, ADGAN-SDP is an anomaly detection approach based on data reconstruction for software defect prediction. ADGAN-SDP attempts to fit the data distribution of the nondefective samples. Furthermore, because the data distribution of defective samples is different from the nondefective samples, there will be larger reconstruction loss if the current sample comes from defective samples set. ADGAN-SDP software defect prediction framework consists of three stages: data preprocessing stage, model construction stage, and software defect prediction stage. In the data preprocessing stage (lines 1–4), first, we use the Correlation-based Feature Selection (CFS) algorithm [26] to select the best feature subset (line 1). Then, we perform min-max scaling on all project data (line 2). Finally, we divide the dataset into training dataset and test dataset (line 3) and remove defect data samples from the training dataset to obtain the required final training data (line 4).Algorithm 1: Software defect prediction framework based on BiGAN anomaly detection.
Input: original data set SdataOutput: the predicted result of the testset/∗ Data preprocessing stage∗/(1)
Sdata⟶CFSS’data(2)
S’data⟶MinMaxScalingSnew(3)
Snew⟶Strain(80%)∪​Stest(20%)(4)
Sfinal_train←Strain−Sdefect_train/∗Model construction stage∗/(5)
Initialize encoderE, generator G, and discriminator D in the BiGAN model(6)
Train BiGAN model usingSfinal_train/∗ Software defect prediction stage ∗/(7)
fort in Stestdo(8)
LRt=t−GEt(9)
LDt=FDt,Et−FDGEt,Et(10)
Lt=αLRt+1−αLDt(11)
if L(t)<=Pthresholdthen(12)
pre_result[t] = 0(13)
else(14)
pre_result[t] = 1(15)
end if(16)
end for(17)
returnpre_resultIn the model construction stage (lines 5–6), we use the training data obtained in the previous step to alternate training encoderE, generator G, and discriminator D of the BiGAN model repeatedly in order to acquire the data distribution of no-defective samples. Specifically, we first train the discriminator D iteratively for k times with the encoder E and generator G remaining unchanged. Then, we train the encoder and generator for only once, while the discriminator D keeps unchanged. Next, we repeat the previous two steps until the specified number of iterations is reached. In the software defect prediction stage (lines 7–16), we make predictions by judging whether the current sample t in the testset is an abnormal sample. Specifically, we calculate the reconstruction loss of the current sample t firstly (line 8). Then, we calculate the corresponding feature matching loss based on the discriminator (line 9). Finally, the final loss of sample t is obtained (line 10). We make predictions by comparing the final loss value with the specified threshold (lines 11–15); if the loss is less than a predetermined threshold, it is a nondefective sample, otherwise it is a defective sample. In the end, the predicted values of each test sample are saved and outputted.


## 3.1. Anomaly Detection Based on GAN

The adversarial generation network (GAN) can obtain complex high-dimensional data distribution, which implies that it can be applied for anomaly detection [23]. In the training phase, since only normal data samples are used to train the GAN model, a trained GAN should be able to obtain normal samples feature distribution. In the testing phase, the loss for normal data samples (nondefective data) is smaller, while the loss for abnormal data samples (defective data) is larger, thus abnormal data samples can be identified [23, 24].Bidirectional Generative Adversarial networks (BiGAN) [13] is employed in this paper, and the overall architecture of BiGAN is shown in Figure 1. Comparing with the general GAN model, BiGAN not only includes a generator G and a discriminator D but also has an encoder E that maps real input data to a latent encoding representation. By introducing encoder E, we not only acquire meaningful semantic representations related to given tasks but also the amount of calculation of the testing phase can be reduced. Specifically, the input of the discriminator of the GAN model usually is real data or generated data and the output is usually the probability value of current sample belonging to real samples. However, the input of discriminator of the BiGAN model is data array, that is [x, E (x)] or [G (z), z], the output is the same as the general GAN. The training objective function of the BiGAN model is similar to general GAN model, so its objective function can also be defined as a minimax function. The objective function is shown in equation (1). There are a variety of methods to train the BiGAN. In this paper, we adopted the strategy of simultaneously training the generator G and the encoder E according to suggestion of Dumoulin et al. [25].(1)minG,EmaxDVD=ElogX,EX+Elog1−DZ,GZ.Figure 1
The overall framework of BiGAN.The anomaly detection based on BiGAN includes two stages. First, BiGAN network model is trained according to the above training strategy using normal data samples (no-defective samples). Then, we need to define a convex function to measure the abnormality of the current sample, that is, if the output value of the function exceeds a predefined threshold, the current sample will be judged as an abnormal sample, otherwise a normal sample. The convex function is shown in the following equation.(2)Lt=αLGt+1−αLDt,where, in equation (2), t represents the current sample to be tested, LG represents the reconstruction loss of the sample t, LD represents the loss based on the discriminant model D of the sample t, and α represents the weight coefficient of two different losses. For detailed information about the anomaly detection model based on BiGAN, please refer to [24].


## 3.2. Software Defect Prediction Approach Based on BiGAN Anomaly Detection

Algorithm procedure of the ADGAN-SDP model can be divided into three stages: data preprocessing, model construction, and model prediction, which is shown in Figure2. Unlike most researches which usually regard software defect prediction as a classification problem, we try to construct the software defect prediction model from the perspective of anomaly detection in order to solve the class imbalance problem. Compared with the classification-based software defect prediction models, our model only needs nondefect samples as training data without considering the class imbalance problem. Our model uses BiGAN to model the nondefect samples, while the classification-based model needs to use classifiers such as random forests, support vector machines, and naive Bayes to model the overall samples. In the prediction stage, our model needs to manually specify a threshold while the classification-based model does not need. In contrast to study works of Nahar Neela et al. [11] and Afric et al. [12], ADGAN-SDP uses BiGAN to build the anomaly detection model so that it can better capture the characteristics of nondefect samples.Figure 2
The overall framework of ADGAN-SDP.In the first stage, we need to perform some necessary data preprocessing (feature selection, data normalization, etc.). In the second stage, the BiGAN model is trained with nondefective samples, so that the distribution characteristics of normal data samples (nondefective samples) can be obtained. In the third stage, we predict whether the current sample contains defects by comparing the loss value of the sample with the predefined threshold [24]. The detail is shown in Algorithm 1.As shown in Algorithm 1, ADGAN-SDP is an anomaly detection approach based on data reconstruction for software defect prediction. ADGAN-SDP attempts to fit the data distribution of the nondefective samples. Furthermore, because the data distribution of defective samples is different from the nondefective samples, there will be larger reconstruction loss if the current sample comes from defective samples set. ADGAN-SDP software defect prediction framework consists of three stages: data preprocessing stage, model construction stage, and software defect prediction stage. In the data preprocessing stage (lines 1–4), first, we use the Correlation-based Feature Selection (CFS) algorithm [26] to select the best feature subset (line 1). Then, we perform min-max scaling on all project data (line 2). Finally, we divide the dataset into training dataset and test dataset (line 3) and remove defect data samples from the training dataset to obtain the required final training data (line 4).Algorithm 1: Software defect prediction framework based on BiGAN anomaly detection.
Input: original data set SdataOutput: the predicted result of the testset/∗ Data preprocessing stage∗/(1)
Sdata⟶CFSS’data(2)
S’data⟶MinMaxScalingSnew(3)
Snew⟶Strain(80%)∪​Stest(20%)(4)
Sfinal_train←Strain−Sdefect_train/∗Model construction stage∗/(5)
Initialize encoderE, generator G, and discriminator D in the BiGAN model(6)
Train BiGAN model usingSfinal_train/∗ Software defect prediction stage ∗/(7)
fort in Stestdo(8)
LRt=t−GEt(9)
LDt=FDt,Et−FDGEt,Et(10)
Lt=αLRt+1−αLDt(11)
if L(t)<=Pthresholdthen(12)
pre_result[t] = 0(13)
else(14)
pre_result[t] = 1(15)
end if(16)
end for(17)
returnpre_resultIn the model construction stage (lines 5–6), we use the training data obtained in the previous step to alternate training encoderE, generator G, and discriminator D of the BiGAN model repeatedly in order to acquire the data distribution of no-defective samples. Specifically, we first train the discriminator D iteratively for k times with the encoder E and generator G remaining unchanged. Then, we train the encoder and generator for only once, while the discriminator D keeps unchanged. Next, we repeat the previous two steps until the specified number of iterations is reached. In the software defect prediction stage (lines 7–16), we make predictions by judging whether the current sample t in the testset is an abnormal sample. Specifically, we calculate the reconstruction loss of the current sample t firstly (line 8). Then, we calculate the corresponding feature matching loss based on the discriminator (line 9). Finally, the final loss of sample t is obtained (line 10). We make predictions by comparing the final loss value with the specified threshold (lines 11–15); if the loss is less than a predetermined threshold, it is a nondefective sample, otherwise it is a defective sample. In the end, the predicted values of each test sample are saved and outputted.


## 4. Experiment and Result

This section mainly introduces experimental data, evaluation metrics, experiment design, and results and analysis.


### 4.1. Experimental Data

The experimental data used in this paper comes from NASA, AEEEM, and Relink, three public software defect databases. In the software defect prediction field, NASA is a widely used public dataset. The NASA dataset comes from the projects of the national aeronautics and space administration of the United States [27]. The AEEEM dataset was published by D’Ambros et al. [28]. It contains about five Java projects. Relink defect dataset was provided by Wu et al. [29]. It contains three Java projects. This paper uses nine, five, and three projects from the NASA, AEEEM, and Relink, respectively. The detailed information of experimental data is shown in Table 1. The table shows the dataset name (column 1), the projects name (column 2), granularity level (column 3), the number of features (column 4), the number of instances (column 5), the number of defective samples (column 6), and the defect rate (column 7).Table 1
Information table of experiment data.
DatasetProjectLevel#feature# instances# defects%defect (%)NASACM1Method373274212.8JM1Method217782167221.5KC3Method391943618.6MC1Method381988462.3MC2Method391254435.2MW1Method372532710.7PC1Method37705618.7PC2Method36745162.1PC3Method37107713412.4PC4Method37128717713.8PC5Method38171147127.5AEEEMEQClass6132412939.8LCClass61691649.3MLClass61186224513.2JDTClass6199720621PDEClass61149720914RelinkApacheFile261949850.5SafeFile26562239.3ZXingFile2639911829.6


### 4.2. Evaluation Metrics

Because the software defect prediction dataset has the nature of class imbalance, we use AUC (Area under the ROC Curve),F1 value, and G-means, three evaluation indicators to evaluate the prediction performance of the models [30, 31].AUC refers to the area under ROC (receiver operating characteristic curve) curve. Meanwhile, the ROC curve is generated by TPR (true-positive rate) and FPR (false-positive rate) considering different decision thresholds.F1 value is an evaluation index that considers both precision and recall. The calculation method is shown in the following equation.(3)F1=2×Precision×RecallPrecision+Recall.G-mean is another commonly used evaluation indicator that is similar to the F1 value, which considers both specificity and recall. The calculation method is presented in the following equation.(4)G−mean=Recall×1−Specificity.


### 4.3. Experiment Setup

ADGAN-SDP is mainly proposed to solve the class imbalance problem. Therefore, we choose cost-sensitive learning, oversampling, undersampling, and ensemble learning, four types of methods, to solve the class imbalance problem as comparison methods. Cost-sensitive learning methods try to solve the class imbalance problem by giving different misclassification costs and minimizing the total expected costs. Cost-sensitive learning methods are implemented by parameter setting provided in thescikit-learn library, wherein the parameter “class_weight”is set to “balanced.” We use SMOTE (Synthetic Minority Oversampling Technique) [32] and RandomUnderSampler as oversampling and undersampling methods, respectively. They are implemented by invoking imblearn tool with default settings. RF (Random Forest) [33] and ADA (AdaBoost) [34], which are implemented by calling scikit-learn toolkit with default settings, are used as ensemble learning method. We use SVM (Support Vector Machine) and RF (Random Forest), two classifiers with better performance, to evaluate the effect of four types of methods on the 19 projects. Two classifiers are implemented by invoking the scikit-learn toolkit with default settings. Therefore, there are RFB (RF + Balance), SVMB (SVM + Balance), RFS (RF + SMOTE), SVMS (SVM + SMOTE), RFU (RF + Undersampling), SVMU (SVM + Undersampling), RF, and ADA (AdaBoost), eight comparison models.All software defect prediction models studied in this paper are implemented inpython language. ADGAN-SDP model uses the tensorflow deep learning framework. The CFS feature selection algorithm [26] is implemented by invoking the weka tool with default settings. The ADGAN-SDP model consists of three parts, namely, Encoder, Discriminator, and Generator. The three parts are all composed of four layers, using the relu activation function. AdamOptimizer is used as optimizer. Due to the difference of each project, the threshold value of each project and the weight value of two kinds of losses are determined manually according to the experimental results.In our experiment, we randomly choose 80% of each project as the training data and the rest as the test data. The number of training on each project is set to 100. In order to ensure that the experimental results are not affected by randomness, we repeat the experiment 10 times on each project and take the average value of 10 times as the final result. AUC andF1 value, two evaluation indicators, use tools provided by the scikit-learn library. Since many experiments in this paper are implemented by third-party tools, the reproducibility of the experimental results can be greatly improved.


### 4.4. Experiments and Analysis

The experimental results are provided in Figure3. It is box plots of prediction performance using AUC, G-mean, and F1, three evaluation indicators. The experimental detailed results are presented in Tables 2–4, the best predicted value of each project is in bold.Figure 3
The boxplots of ADGAN-SDP model and other comparison models under (a) AUC, (b)G-mean, and (c) F1 evaluation metrics.
(a)(b)(c)Table 2
Prediction result of ADGAN-SDP and other comparison models on 19 projects under the AUC metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.50730.62890.53640.61120.63680.63560.50620.52120.7000JM10.56100.59420.60630.59260.61010.57670.56650.53880.6312KC30.56660.64290.58700.57060.57560.60370.52140.51510.6281MC10.62450.71160.68490.69090.75020.66000.65050.53180.7127MC20.62390.62700.62780.58720.60380.58590.58660.57580.6667MW10.58400.70530.65980.70790.65040.63640.57120.55660.7427PC10.55430.69970.70320.70400.74040.63480.56660.58020.7035PC20.50000.69690.56160.68010.68390.70630.50000.50600.7957PC30.55240.73520.65770.74830.72910.71430.56310.57210.7453PC40.59750.75210.70030.75480.73730.71740.61020.58760.7028PC50.63410.63130.66550.63230.67060.62860.63560.59100.6835EQ0.75680.72280.77750.72410.77130.70470.75430.71890.7857LC0.72600.75420.77880.74800.78390.73130.73530.71930.7364ML0.58840.66710.63400.66260.69600.68640.60520.61190.7033JDT0.59520.68060.66370.68330.74010.62970.59570.57270.6775PDE0.58240.65670.61940.65690.67540.63330.59280.57320.7048Apache0.66380.71390.65370.69000.61310.68670.63420.67280.7696Safe0.61850.66400.63070.69840.64140.67110.61610.60630.8571ZXing0.53200.58590.53760.59290.54030.59230.53460.53150.6774AVE0.59830.67740.64660.67030.67630.65450.59720.58330.7171W/D/L0/0/194/0/151/0/185/0/145/0/141/0/180/0/190/0/19—p value0.00000.02860.00130.01680.05560.00080.00000.0000—Cliff’sδ0.82830.35180.63430.37950.32410.53460.81720.8504—The bold values of each row represent best predicted values of each project except last three rows.Table 3
Prediction result of ADGAN-SDP and other comparison models on 19 projects underG-mean metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.13510.61420.41130.59260.62300.61270.09770.23300.6971JM10.40960.52260.55290.51340.60950.46370.42690.31590.6152KC30.43120.61830.54150.52620.56190.48630.31100.22520.5956MC10.48160.70560.60180.66100.74030.63740.53530.18110.7008MC20.57400.59370.60330.53760.59350.53130.45020.54060.5774MW10.38440.62990.60390.66010.59170.53380.35530.37520.7333PC10.29770.69450.66050.69950.73570.60210.35020.39800.6991PC20.00000.67880.21980.59730.67040.64800.00000.05000.7851PC30.34190.73290.61380.74650.72660.71120.36860.40520.7408PC40.46470.74060.67280.74640.73430.70310.48810.43390.6886PC50.56660.61430.64670.61720.66970.30110.57400.49030.6824EQ0.75370.72010.77430.72030.76670.69940.75040.70950.7559LC0.68710.74070.76660.73370.78290.71120.70160.68360.7236ML0.39710.62700.54970.62430.69310.64240.46560.49600.7023JDT0.46080.67160.60890.68050.73900.58950.46290.41130.6769PDE0.41950.62370.53250.62920.67380.56920.44720.41720.7046Apache0.66000.70790.64970.68320.61010.67710.63130.66760.7690Safe0.56480.62810.59600.66700.61050.63390.56110.54900.8452ZXing0.44730.56400.47990.56870.53120.56990.44190.34780.6765AVE0.44620.65410.58350.64240.66650.59600.44310.41740.7037W/D/L0/0/195/0/143/0/165/0/147/0/121/0/180/0/190/0/19—p value0.00000.02100.00060.00930.10810.00040.00000.0000—Cliff’sδ0.86700.37950.68420.46260.28530.63430.84490.8618—Table 4
Prediction result of ADGAN-SDP and other comparison models on 19 projects underF1 metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.06920.28740.19240.27400.29600.31310.05410.12150.4516JM10.25740.35160.37840.34770.40100.30600.27390.17180.4083KC30.27000.37450.32850.31150.30810.32570.15790.14240.4000MC10.36230.11550.36860.09110.12250.10600.42530.10230.1750MC20.47160.46980.49750.39970.50800.41530.36680.43970.5000MW10.25580.38960.37010.41490.29120.27570.22870.19280.5263PC10.18160.29160.39820.30270.31290.25420.21480.24220.2381PC20.00000.09880.04670.08860.09960.10210.00000.04000.2500PC30.19410.40250.37950.41290.39030.37980.22140.24390.4138PC40.31390.41110.46060.42090.42350.37730.34430.29080.3418PC50.44610.46550.51410.47180.52790.45730.45110.35450.4678EQ0.70580.66850.73420.66380.72980.64120.69450.64900.5161LC0.59250.60610.64350.59160.59850.57270.60180.57280.5455ML0.28330.33560.31880.31980.29410.37820.31130.31470.3509JDT0.30670.37480.42170.36670.42510.33720.30770.25330.3600PDE0.27990.38720.35350.38200.36800.36670.30410.25520.4026Apache0.65420.67310.66310.66980.60110.65560.60910.66850.5333Safe0.50330.56080.53540.59990.53550.56210.47140.47720.5000ZXing0.29410.42200.32560.42550.38640.43330.28830.20880.4500AVE0.33900.40450.41740.39760.40100.38210.33300.30220.4122W/D/L5/0/147/0/129/0/108/0/119/0/107/0/125/0/144/0/15—p-value0.14390.85990.90680.74340.80090.48460.10780.0289—Cliff’sδ0.29640.08590.05820.10250.07480.16900.34070.4294—The bold values of each row represent best predicted values of each project except last three rows.What stands out from Figure3 is that the prediction performance of ADGAN-SDP is significantly better than other models. As shown in Figure 3(a), the first, the second, and the third quartile of ADGAN-SDP all higher other comparison models. The results of Figure 3(b) are similar with Figure 3(a). However, results of Figure 3(c) are somewhat different from other the two figures. Figure 3(c) shows that only the second and the third quartile of ADGAN-SDP rank higher than other comparison models. Further observation shows that for class imbalance problems dealing, ensemble learning method has the worst effect, while the other three types of methods have their own advantages in different classifiers.Tables2–4 are the detailed experiment results. From Table 2 we can see that ADGAN-SDP achieves the best AUC value on 12 out of 19 projects; this performance is better than the other comparison models. Closer inspection of the table shows that the mean of ADGAN-SDP in 19 projects is higher than the other eight comparison models. ADGAN-SDP outperforms RFB, SVMB, RFS, SVMS, RFU, SVMU, RF, and ADA by 19.86%, 5.86%, 10.9%, 6.98%, 6.03%, 9.56%, 20.08%, and 22.94%, respectively, in terms of average AUC value. As shown in Table 3, ADGAN-SDP gets the best G-mean value on 10 out of 19 projects; this performance is also superior to the other comparison models. Further observation provides that the mean of ADGAN-SDP in 19 projects is also higher than other comparison models. ADGAN-SDP outperforms RFB, SVMB, RFS, SVMS, RFU, SVMU, RF, and ADA by 57.71%, 7.58%, 20.6%, 9.54%, 5.58%, 18.07%, 58.81%, and 68.59%, respectively, in terms of average G-mean value. It can be seen from the data in Table 4 that ADGAN-SDP achieves the best F1 value on 9 out of 19 projects; this performance is better than the other comparison models. However, Table 4 presents that the mean of ADGAN-SDP in 19 projects is higher than other comparison models except for the RFS model. ADGAN-SDP outperforms RFB, SVMB, SVMS, RFU, SVMU, RF, and ADA by 21.59%, 1.9%, 3.67%, 2.79%, 7.88%, 23.78%, and 36.4%, respectively, in terms of average F1 value. In addition, we also apply win/draw/loss statistics for ADGAN-SDP and other comparison models. The statistical results of the “W/D/L” row in Tables 2–4 provide that the prediction performance of ADGAN-SDP outperforms other comparison models.To check if the differences of the prediction performance of ADGAN-SDP and eight comparison models are statistically significant, we use the Wilcoxon signed-rank test at 95% significance level on three evaluation indicators. To make statistics more accurate, we also use Bonferroni to correct statistics results [35]. Besides, we also apply Cohen’s delta (a nonparametric effect size measure) [36] to measure the effect size with four-level effect size, which is shown in Table 5. Statistical test results are shown in “p value” and “Cliff’s d” row of Tables 2–4. Table 2 presents that ADGAN-SDP shows significant improvements (p values <0.05) on all comparison models with medium or large size effect except for the RFU model. As for the G-mean metric, the statistical test results are similar with AUC metrics. However, statistical test results on F1 metric are different from the AUC and G-mean two metrics. For F1 metric, Table 3 provides a surprising result that ADGAN-SDP shows significant improvements (p values <0.05) only on the ADA model with medium size effect (δ = 0.4294).Table 5
Cliff’s delta and the effectiveness level [36].
Cliff’s Delta(|δ|)Effectiveness level0.000 ≤ |δ| < 0.147Negligible0.147 ≤ |δ| < 0.330Small0.330 ≤ |δ| < 0.474Medium0.474 ≤ |δ| < 1.000LargeFinally, we conduct the nonparametric Friedman test with post-hoc Nemenyi test [37] (a = 0.05) comparing ADGAN-SDP with eight comparison models over the 19 projects on three evaluation metrics. The analysis results are presented in Figure 4.Figure 4
The ranks on (a) AUC, (b)G-mean, and (c) F1 for ADGAN-SDP model and other comparison models with post-hoc Nemenyi test. Models connected by gray lines are not significantly different.
(a)(b)(c)In Figure4, the results of the post-hoc test provide that ADGAN-SDP always belongs to the top rank group in terms of AUC and G-mean two indicators. However, SVMB belongs to the top rank group in terms of F1. These observations indicate that ADGAN-SDP performs significantly better than the eight comparison models in terms of AUC and G-mean two indicators.However, we notice that prediction performance ofF1 metric is different from AUC and G-mean two metrics. We guess that it may be caused by different recall and precision of models. In order to analyze the reason, average precision and recall of different models on 19 projects are shown in Figure 5. As shown in Figure 5, this is an expected result that precision is inversely proportional to recall. From the figure we can see that ADGAN-SDP has higher recall rate, but lower precision. For F1 value, the prediction performance of ADGAN-SDP is not ideal due to considering both precision and recall.Figure 5
Average recall and precision of ADGAN-SDP and other comparison models on 19 projects.In summary, these results show that the prediction performance of ADGAN-SDP model is better than classification-based software defect prediction models. The evidences from those studies suggest that the anomaly detection models can be applied to the software defect prediction to fundamentally solve the problem of class imbalance.


## 4.1. Experimental Data

The experimental data used in this paper comes from NASA, AEEEM, and Relink, three public software defect databases. In the software defect prediction field, NASA is a widely used public dataset. The NASA dataset comes from the projects of the national aeronautics and space administration of the United States [27]. The AEEEM dataset was published by D’Ambros et al. [28]. It contains about five Java projects. Relink defect dataset was provided by Wu et al. [29]. It contains three Java projects. This paper uses nine, five, and three projects from the NASA, AEEEM, and Relink, respectively. The detailed information of experimental data is shown in Table 1. The table shows the dataset name (column 1), the projects name (column 2), granularity level (column 3), the number of features (column 4), the number of instances (column 5), the number of defective samples (column 6), and the defect rate (column 7).Table 1
Information table of experiment data.
DatasetProjectLevel#feature# instances# defects%defect (%)NASACM1Method373274212.8JM1Method217782167221.5KC3Method391943618.6MC1Method381988462.3MC2Method391254435.2MW1Method372532710.7PC1Method37705618.7PC2Method36745162.1PC3Method37107713412.4PC4Method37128717713.8PC5Method38171147127.5AEEEMEQClass6132412939.8LCClass61691649.3MLClass61186224513.2JDTClass6199720621PDEClass61149720914RelinkApacheFile261949850.5SafeFile26562239.3ZXingFile2639911829.6


## 4.2. Evaluation Metrics

Because the software defect prediction dataset has the nature of class imbalance, we use AUC (Area under the ROC Curve),F1 value, and G-means, three evaluation indicators to evaluate the prediction performance of the models [30, 31].AUC refers to the area under ROC (receiver operating characteristic curve) curve. Meanwhile, the ROC curve is generated by TPR (true-positive rate) and FPR (false-positive rate) considering different decision thresholds.F1 value is an evaluation index that considers both precision and recall. The calculation method is shown in the following equation.(3)F1=2×Precision×RecallPrecision+Recall.G-mean is another commonly used evaluation indicator that is similar to the F1 value, which considers both specificity and recall. The calculation method is presented in the following equation.(4)G−mean=Recall×1−Specificity.


## 4.3. Experiment Setup

ADGAN-SDP is mainly proposed to solve the class imbalance problem. Therefore, we choose cost-sensitive learning, oversampling, undersampling, and ensemble learning, four types of methods, to solve the class imbalance problem as comparison methods. Cost-sensitive learning methods try to solve the class imbalance problem by giving different misclassification costs and minimizing the total expected costs. Cost-sensitive learning methods are implemented by parameter setting provided in thescikit-learn library, wherein the parameter “class_weight”is set to “balanced.” We use SMOTE (Synthetic Minority Oversampling Technique) [32] and RandomUnderSampler as oversampling and undersampling methods, respectively. They are implemented by invoking imblearn tool with default settings. RF (Random Forest) [33] and ADA (AdaBoost) [34], which are implemented by calling scikit-learn toolkit with default settings, are used as ensemble learning method. We use SVM (Support Vector Machine) and RF (Random Forest), two classifiers with better performance, to evaluate the effect of four types of methods on the 19 projects. Two classifiers are implemented by invoking the scikit-learn toolkit with default settings. Therefore, there are RFB (RF + Balance), SVMB (SVM + Balance), RFS (RF + SMOTE), SVMS (SVM + SMOTE), RFU (RF + Undersampling), SVMU (SVM + Undersampling), RF, and ADA (AdaBoost), eight comparison models.All software defect prediction models studied in this paper are implemented inpython language. ADGAN-SDP model uses the tensorflow deep learning framework. The CFS feature selection algorithm [26] is implemented by invoking the weka tool with default settings. The ADGAN-SDP model consists of three parts, namely, Encoder, Discriminator, and Generator. The three parts are all composed of four layers, using the relu activation function. AdamOptimizer is used as optimizer. Due to the difference of each project, the threshold value of each project and the weight value of two kinds of losses are determined manually according to the experimental results.In our experiment, we randomly choose 80% of each project as the training data and the rest as the test data. The number of training on each project is set to 100. In order to ensure that the experimental results are not affected by randomness, we repeat the experiment 10 times on each project and take the average value of 10 times as the final result. AUC andF1 value, two evaluation indicators, use tools provided by the scikit-learn library. Since many experiments in this paper are implemented by third-party tools, the reproducibility of the experimental results can be greatly improved.


## 4.4. Experiments and Analysis

The experimental results are provided in Figure3. It is box plots of prediction performance using AUC, G-mean, and F1, three evaluation indicators. The experimental detailed results are presented in Tables 2–4, the best predicted value of each project is in bold.Figure 3
The boxplots of ADGAN-SDP model and other comparison models under (a) AUC, (b)G-mean, and (c) F1 evaluation metrics.
(a)(b)(c)Table 2
Prediction result of ADGAN-SDP and other comparison models on 19 projects under the AUC metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.50730.62890.53640.61120.63680.63560.50620.52120.7000JM10.56100.59420.60630.59260.61010.57670.56650.53880.6312KC30.56660.64290.58700.57060.57560.60370.52140.51510.6281MC10.62450.71160.68490.69090.75020.66000.65050.53180.7127MC20.62390.62700.62780.58720.60380.58590.58660.57580.6667MW10.58400.70530.65980.70790.65040.63640.57120.55660.7427PC10.55430.69970.70320.70400.74040.63480.56660.58020.7035PC20.50000.69690.56160.68010.68390.70630.50000.50600.7957PC30.55240.73520.65770.74830.72910.71430.56310.57210.7453PC40.59750.75210.70030.75480.73730.71740.61020.58760.7028PC50.63410.63130.66550.63230.67060.62860.63560.59100.6835EQ0.75680.72280.77750.72410.77130.70470.75430.71890.7857LC0.72600.75420.77880.74800.78390.73130.73530.71930.7364ML0.58840.66710.63400.66260.69600.68640.60520.61190.7033JDT0.59520.68060.66370.68330.74010.62970.59570.57270.6775PDE0.58240.65670.61940.65690.67540.63330.59280.57320.7048Apache0.66380.71390.65370.69000.61310.68670.63420.67280.7696Safe0.61850.66400.63070.69840.64140.67110.61610.60630.8571ZXing0.53200.58590.53760.59290.54030.59230.53460.53150.6774AVE0.59830.67740.64660.67030.67630.65450.59720.58330.7171W/D/L0/0/194/0/151/0/185/0/145/0/141/0/180/0/190/0/19—p value0.00000.02860.00130.01680.05560.00080.00000.0000—Cliff’sδ0.82830.35180.63430.37950.32410.53460.81720.8504—The bold values of each row represent best predicted values of each project except last three rows.Table 3
Prediction result of ADGAN-SDP and other comparison models on 19 projects underG-mean metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.13510.61420.41130.59260.62300.61270.09770.23300.6971JM10.40960.52260.55290.51340.60950.46370.42690.31590.6152KC30.43120.61830.54150.52620.56190.48630.31100.22520.5956MC10.48160.70560.60180.66100.74030.63740.53530.18110.7008MC20.57400.59370.60330.53760.59350.53130.45020.54060.5774MW10.38440.62990.60390.66010.59170.53380.35530.37520.7333PC10.29770.69450.66050.69950.73570.60210.35020.39800.6991PC20.00000.67880.21980.59730.67040.64800.00000.05000.7851PC30.34190.73290.61380.74650.72660.71120.36860.40520.7408PC40.46470.74060.67280.74640.73430.70310.48810.43390.6886PC50.56660.61430.64670.61720.66970.30110.57400.49030.6824EQ0.75370.72010.77430.72030.76670.69940.75040.70950.7559LC0.68710.74070.76660.73370.78290.71120.70160.68360.7236ML0.39710.62700.54970.62430.69310.64240.46560.49600.7023JDT0.46080.67160.60890.68050.73900.58950.46290.41130.6769PDE0.41950.62370.53250.62920.67380.56920.44720.41720.7046Apache0.66000.70790.64970.68320.61010.67710.63130.66760.7690Safe0.56480.62810.59600.66700.61050.63390.56110.54900.8452ZXing0.44730.56400.47990.56870.53120.56990.44190.34780.6765AVE0.44620.65410.58350.64240.66650.59600.44310.41740.7037W/D/L0/0/195/0/143/0/165/0/147/0/121/0/180/0/190/0/19—p value0.00000.02100.00060.00930.10810.00040.00000.0000—Cliff’sδ0.86700.37950.68420.46260.28530.63430.84490.8618—Table 4
Prediction result of ADGAN-SDP and other comparison models on 19 projects underF1 metric.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM10.06920.28740.19240.27400.29600.31310.05410.12150.4516JM10.25740.35160.37840.34770.40100.30600.27390.17180.4083KC30.27000.37450.32850.31150.30810.32570.15790.14240.4000MC10.36230.11550.36860.09110.12250.10600.42530.10230.1750MC20.47160.46980.49750.39970.50800.41530.36680.43970.5000MW10.25580.38960.37010.41490.29120.27570.22870.19280.5263PC10.18160.29160.39820.30270.31290.25420.21480.24220.2381PC20.00000.09880.04670.08860.09960.10210.00000.04000.2500PC30.19410.40250.37950.41290.39030.37980.22140.24390.4138PC40.31390.41110.46060.42090.42350.37730.34430.29080.3418PC50.44610.46550.51410.47180.52790.45730.45110.35450.4678EQ0.70580.66850.73420.66380.72980.64120.69450.64900.5161LC0.59250.60610.64350.59160.59850.57270.60180.57280.5455ML0.28330.33560.31880.31980.29410.37820.31130.31470.3509JDT0.30670.37480.42170.36670.42510.33720.30770.25330.3600PDE0.27990.38720.35350.38200.36800.36670.30410.25520.4026Apache0.65420.67310.66310.66980.60110.65560.60910.66850.5333Safe0.50330.56080.53540.59990.53550.56210.47140.47720.5000ZXing0.29410.42200.32560.42550.38640.43330.28830.20880.4500AVE0.33900.40450.41740.39760.40100.38210.33300.30220.4122W/D/L5/0/147/0/129/0/108/0/119/0/107/0/125/0/144/0/15—p-value0.14390.85990.90680.74340.80090.48460.10780.0289—Cliff’sδ0.29640.08590.05820.10250.07480.16900.34070.4294—The bold values of each row represent best predicted values of each project except last three rows.What stands out from Figure3 is that the prediction performance of ADGAN-SDP is significantly better than other models. As shown in Figure 3(a), the first, the second, and the third quartile of ADGAN-SDP all higher other comparison models. The results of Figure 3(b) are similar with Figure 3(a). However, results of Figure 3(c) are somewhat different from other the two figures. Figure 3(c) shows that only the second and the third quartile of ADGAN-SDP rank higher than other comparison models. Further observation shows that for class imbalance problems dealing, ensemble learning method has the worst effect, while the other three types of methods have their own advantages in different classifiers.Tables2–4 are the detailed experiment results. From Table 2 we can see that ADGAN-SDP achieves the best AUC value on 12 out of 19 projects; this performance is better than the other comparison models. Closer inspection of the table shows that the mean of ADGAN-SDP in 19 projects is higher than the other eight comparison models. ADGAN-SDP outperforms RFB, SVMB, RFS, SVMS, RFU, SVMU, RF, and ADA by 19.86%, 5.86%, 10.9%, 6.98%, 6.03%, 9.56%, 20.08%, and 22.94%, respectively, in terms of average AUC value. As shown in Table 3, ADGAN-SDP gets the best G-mean value on 10 out of 19 projects; this performance is also superior to the other comparison models. Further observation provides that the mean of ADGAN-SDP in 19 projects is also higher than other comparison models. ADGAN-SDP outperforms RFB, SVMB, RFS, SVMS, RFU, SVMU, RF, and ADA by 57.71%, 7.58%, 20.6%, 9.54%, 5.58%, 18.07%, 58.81%, and 68.59%, respectively, in terms of average G-mean value. It can be seen from the data in Table 4 that ADGAN-SDP achieves the best F1 value on 9 out of 19 projects; this performance is better than the other comparison models. However, Table 4 presents that the mean of ADGAN-SDP in 19 projects is higher than other comparison models except for the RFS model. ADGAN-SDP outperforms RFB, SVMB, SVMS, RFU, SVMU, RF, and ADA by 21.59%, 1.9%, 3.67%, 2.79%, 7.88%, 23.78%, and 36.4%, respectively, in terms of average F1 value. In addition, we also apply win/draw/loss statistics for ADGAN-SDP and other comparison models. The statistical results of the “W/D/L” row in Tables 2–4 provide that the prediction performance of ADGAN-SDP outperforms other comparison models.To check if the differences of the prediction performance of ADGAN-SDP and eight comparison models are statistically significant, we use the Wilcoxon signed-rank test at 95% significance level on three evaluation indicators. To make statistics more accurate, we also use Bonferroni to correct statistics results [35]. Besides, we also apply Cohen’s delta (a nonparametric effect size measure) [36] to measure the effect size with four-level effect size, which is shown in Table 5. Statistical test results are shown in “p value” and “Cliff’s d” row of Tables 2–4. Table 2 presents that ADGAN-SDP shows significant improvements (p values <0.05) on all comparison models with medium or large size effect except for the RFU model. As for the G-mean metric, the statistical test results are similar with AUC metrics. However, statistical test results on F1 metric are different from the AUC and G-mean two metrics. For F1 metric, Table 3 provides a surprising result that ADGAN-SDP shows significant improvements (p values <0.05) only on the ADA model with medium size effect (δ = 0.4294).Table 5
Cliff’s delta and the effectiveness level [36].
Cliff’s Delta(|δ|)Effectiveness level0.000 ≤ |δ| < 0.147Negligible0.147 ≤ |δ| < 0.330Small0.330 ≤ |δ| < 0.474Medium0.474 ≤ |δ| < 1.000LargeFinally, we conduct the nonparametric Friedman test with post-hoc Nemenyi test [37] (a = 0.05) comparing ADGAN-SDP with eight comparison models over the 19 projects on three evaluation metrics. The analysis results are presented in Figure 4.Figure 4
The ranks on (a) AUC, (b)G-mean, and (c) F1 for ADGAN-SDP model and other comparison models with post-hoc Nemenyi test. Models connected by gray lines are not significantly different.
(a)(b)(c)In Figure4, the results of the post-hoc test provide that ADGAN-SDP always belongs to the top rank group in terms of AUC and G-mean two indicators. However, SVMB belongs to the top rank group in terms of F1. These observations indicate that ADGAN-SDP performs significantly better than the eight comparison models in terms of AUC and G-mean two indicators.However, we notice that prediction performance ofF1 metric is different from AUC and G-mean two metrics. We guess that it may be caused by different recall and precision of models. In order to analyze the reason, average precision and recall of different models on 19 projects are shown in Figure 5. As shown in Figure 5, this is an expected result that precision is inversely proportional to recall. From the figure we can see that ADGAN-SDP has higher recall rate, but lower precision. For F1 value, the prediction performance of ADGAN-SDP is not ideal due to considering both precision and recall.Figure 5
Average recall and precision of ADGAN-SDP and other comparison models on 19 projects.In summary, these results show that the prediction performance of ADGAN-SDP model is better than classification-based software defect prediction models. The evidences from those studies suggest that the anomaly detection models can be applied to the software defect prediction to fundamentally solve the problem of class imbalance.


## 5. Discussion

### 5.1. Discussion on Experimental Results

Because of the class imbalance in itself, it is a limitation for a given solution that tries to tackle the problem of defect prediction as a binary classification problem. We use anomaly detection methods to build software defect prediction models that can fundamentally solve the class imbalance problem. We verify the effectiveness of ADGAN-SDP by using eight prediction models with better performance as baseline models, while there are other better and improved classification models.By means of observing Table1 and experimental results, we find that ADGAN-SDP can achieve better prediction performance compared with other baseline models when the defect rate is higher. These findings suggest that ADGAN-SDP can find more defective instances so as to result in higher recall, which further supports the experimental results of Figure 5. Taken together, ADGAN-SDP has higher recall and lower precision, while in other baseline models it is contrary. Furthermore, lower recall means more false negative (defective instance marked nondefective instance), while lower precision means more false positive (nondefective instance marked defective instance). In practice, the cost for incorrectly marking a nondefective instance as a defective instance is far lower than the cost for marking a defective sample as a nondefective instance. For training prediction models, the model proposed in this paper only needs nondefective samples, and nondefective samples are easier to obtain than defective samples. Therefore, it is more favorable to use anomaly detection methods to build defect prediction models. Theoretically, ADGAN-SDP has natural advantages compared with classification-based models. The software defect prediction model based on anomaly detection proposed in this paper is essentially different from the past classification-based models; the former only tries to capture the feature distribution of nondefective samples, while the latter needs to know the overall feature distribution including nondefective and defective samples. In summary, these discussions are very encouraging. We recommend using anomaly detection models instead of classification models to build software defect prediction models.


### 5.2. Time Efficiency of ADGAN-SDP

Table6 provides model training and test time across 19 projects. From Table 6, we notice that the training and test time of ADGAN-SDP model is reasonable. Specifically, on average, it takes about 11.265 seconds to train a model, and 0.078 seconds to predict the label of instances in the test set using the model. It is worth noting that the model does not need to be updated once the training is completed. The ADGAN-SDP model training time is much longer than that of other models across all projects, which implies that ADGAN-SDP model is more complex than other methods. The ADGAN-SDP model test time is slightly longer than other models, but we believe it is still acceptable. In summary, ADGAN-SDP model can be applied to real software defect prediction in terms of time efficiency.Table 6
Model training and test time.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM1Training0.2010.0700.3700.0800.1900.0700.2100.1304.679Test0.0200.0100.0100.0000.0100.0000.0100.0100.072JM1Training1.1902.7202.2405.6200.6400.4761.2440.39465.399Test0.0400.7300.0701.0980.0400.3100.0400.0200.114KC3Training0.2500.0800.2300.0800.2300.0700.2000.1803.479Test0.0100.0000.0100.0000.0100.0000.0400.0100.069MC1Training0.2900.1700.6200.4300.2100.1000.2700.19019.582Test0.0200.0300.0200.0500.0200.0000.0200.0100.074MC2Training0.1900.0600.1900.0600.1900.0600.1900.1202.767Test0.0200.0000.0100.0000.0100.0000.0100.0100.069MW1Training0.2180.0600.2300.0700.1910.0630.2040.1334.232Test0.0100.0000.0100.0000.0120.0010.0130.0080.078PC1Training0.2340.0840.3050.1090.2160.0750.2360.1657.659Test0.0130.0040.0130.0080.0130.0010.0160.0090.076PC2Training0.2230.0850.3250.1060.2060.0790.2290.1577.873Test0.0130.0040.0150.0070.0120.0010.0130.0080.068PC3Training0.2770.1050.4580.1600.2290.0810.2820.17210.452Test0.0140.0100.0180.0160.0150.0030.0180.0100.076PC4Training0.2880.1150.3990.1710.2400.0880.2830.17111.705Test0.0150.0130.0170.0190.0150.0030.0160.0100.079PC5Training0.3980.1820.5220.2580.3020.1140.3690.20814.797Test0.0190.0320.0190.0420.0170.0170.0200.0100.115EQTraining0.2720.1250.2690.1390.2750.1290.2710.1952.752Test0.0130.0010.0110.0010.0120.0010.0120.0080.081LCTraining0.2950.1180.3660.1550.2590.1110.2790.1917.548Test0.0130.0050.0140.0100.0130.0010.0390.0080.069MLTraining0.4160.2530.6110.4600.3230.1370.4010.26915.050Test0.0190.0470.0190.0680.0170.0130.0410.0110.070JDTTraining0.3450.1400.4340.1760.2990.1190.3250.2238.489Test0.0140.0110.0150.0160.0140.0050.0370.0090.070PDETraining0.4320.2000.6080.3570.3130.1340.3890.25212.220Test0.0160.0280.0180.0530.0170.0100.0420.0160.070ApacheTraining0.1820.0510.1910.0570.1920.0540.1830.1194.700Test0.0110.0010.0120.0000.0110.0010.0130.0080.080SafeTraining0.1870.0440.1910.0460.1780.0470.1650.1014.189Test0.0110.0000.0110.0000.0120.0000.0120.0080.080ZXingTraining0.2130.0720.2200.0620.2040.0570.2160.1416.460Test0.0130.0020.0130.0030.0130.0010.0130.0080.070AVETraining0.3210.2490.4620.4520.2570.1090.3130.18511.265Test0.0160.0490.0170.0730.0150.0190.0220.0100.078


## 5.1. Discussion on Experimental Results

Because of the class imbalance in itself, it is a limitation for a given solution that tries to tackle the problem of defect prediction as a binary classification problem. We use anomaly detection methods to build software defect prediction models that can fundamentally solve the class imbalance problem. We verify the effectiveness of ADGAN-SDP by using eight prediction models with better performance as baseline models, while there are other better and improved classification models.By means of observing Table1 and experimental results, we find that ADGAN-SDP can achieve better prediction performance compared with other baseline models when the defect rate is higher. These findings suggest that ADGAN-SDP can find more defective instances so as to result in higher recall, which further supports the experimental results of Figure 5. Taken together, ADGAN-SDP has higher recall and lower precision, while in other baseline models it is contrary. Furthermore, lower recall means more false negative (defective instance marked nondefective instance), while lower precision means more false positive (nondefective instance marked defective instance). In practice, the cost for incorrectly marking a nondefective instance as a defective instance is far lower than the cost for marking a defective sample as a nondefective instance. For training prediction models, the model proposed in this paper only needs nondefective samples, and nondefective samples are easier to obtain than defective samples. Therefore, it is more favorable to use anomaly detection methods to build defect prediction models. Theoretically, ADGAN-SDP has natural advantages compared with classification-based models. The software defect prediction model based on anomaly detection proposed in this paper is essentially different from the past classification-based models; the former only tries to capture the feature distribution of nondefective samples, while the latter needs to know the overall feature distribution including nondefective and defective samples. In summary, these discussions are very encouraging. We recommend using anomaly detection models instead of classification models to build software defect prediction models.


## 5.2. Time Efficiency of ADGAN-SDP

Table6 provides model training and test time across 19 projects. From Table 6, we notice that the training and test time of ADGAN-SDP model is reasonable. Specifically, on average, it takes about 11.265 seconds to train a model, and 0.078 seconds to predict the label of instances in the test set using the model. It is worth noting that the model does not need to be updated once the training is completed. The ADGAN-SDP model training time is much longer than that of other models across all projects, which implies that ADGAN-SDP model is more complex than other methods. The ADGAN-SDP model test time is slightly longer than other models, but we believe it is still acceptable. In summary, ADGAN-SDP model can be applied to real software defect prediction in terms of time efficiency.Table 6
Model training and test time.
ProjectRFBSVMBRFSSVMSRFUSVMURFADAADGAN-SDPCM1Training0.2010.0700.3700.0800.1900.0700.2100.1304.679Test0.0200.0100.0100.0000.0100.0000.0100.0100.072JM1Training1.1902.7202.2405.6200.6400.4761.2440.39465.399Test0.0400.7300.0701.0980.0400.3100.0400.0200.114KC3Training0.2500.0800.2300.0800.2300.0700.2000.1803.479Test0.0100.0000.0100.0000.0100.0000.0400.0100.069MC1Training0.2900.1700.6200.4300.2100.1000.2700.19019.582Test0.0200.0300.0200.0500.0200.0000.0200.0100.074MC2Training0.1900.0600.1900.0600.1900.0600.1900.1202.767Test0.0200.0000.0100.0000.0100.0000.0100.0100.069MW1Training0.2180.0600.2300.0700.1910.0630.2040.1334.232Test0.0100.0000.0100.0000.0120.0010.0130.0080.078PC1Training0.2340.0840.3050.1090.2160.0750.2360.1657.659Test0.0130.0040.0130.0080.0130.0010.0160.0090.076PC2Training0.2230.0850.3250.1060.2060.0790.2290.1577.873Test0.0130.0040.0150.0070.0120.0010.0130.0080.068PC3Training0.2770.1050.4580.1600.2290.0810.2820.17210.452Test0.0140.0100.0180.0160.0150.0030.0180.0100.076PC4Training0.2880.1150.3990.1710.2400.0880.2830.17111.705Test0.0150.0130.0170.0190.0150.0030.0160.0100.079PC5Training0.3980.1820.5220.2580.3020.1140.3690.20814.797Test0.0190.0320.0190.0420.0170.0170.0200.0100.115EQTraining0.2720.1250.2690.1390.2750.1290.2710.1952.752Test0.0130.0010.0110.0010.0120.0010.0120.0080.081LCTraining0.2950.1180.3660.1550.2590.1110.2790.1917.548Test0.0130.0050.0140.0100.0130.0010.0390.0080.069MLTraining0.4160.2530.6110.4600.3230.1370.4010.26915.050Test0.0190.0470.0190.0680.0170.0130.0410.0110.070JDTTraining0.3450.1400.4340.1760.2990.1190.3250.2238.489Test0.0140.0110.0150.0160.0140.0050.0370.0090.070PDETraining0.4320.2000.6080.3570.3130.1340.3890.25212.220Test0.0160.0280.0180.0530.0170.0100.0420.0160.070ApacheTraining0.1820.0510.1910.0570.1920.0540.1830.1194.700Test0.0110.0010.0120.0000.0110.0010.0130.0080.080SafeTraining0.1870.0440.1910.0460.1780.0470.1650.1014.189Test0.0110.0000.0110.0000.0120.0000.0120.0080.080ZXingTraining0.2130.0720.2200.0620.2040.0570.2160.1416.460Test0.0130.0020.0130.0030.0130.0010.0130.0080.070AVETraining0.3210.2490.4620.4520.2570.1090.3130.18511.265Test0.0160.0490.0170.0730.0150.0190.0220.0100.078


## 6. Related Work

### 6.1. Class Imbalance Problem

The class imbalance problem is one of the main problems affecting the performance of defect prediction. Researchers have proposed several methods to solve the problem. Bennin et al. [38] proposed a data oversampling method called MAHAKIL; this method was based on the genetic theory of chromosomes to synthesize new minority samples. MAHAKIL could increase the diversity of data and reduce data over-fitting risk. Arar and Ayan [39] used cost-sensitive artificial neural networks to predict software defects. Meanwhile, they used a bee colony algorithm to train prediction models. For solving the class imbalance problem, Zhang et al. [40] proposed a model called the cost-sensitive residual convolutional neural network (CS-ResNet) for PCB cosmetic defect detection. The model added a cost-sensitive adjustment layer that assigned larger weights to minority real defects based on the class-imbalance degree in the standard ResNet [41]. In addition, ensemble learning can also be used to deal with class imbalance problems [42, 43]. Unlike most researchers who regard defect prediction as a classification, we study defect prediction from the perspective of anomaly detection to completely solve the problem of class imbalance. Besides, instead of the supervised learning method commonly used in the classification model to train the prediction model, a semi-supervised method is employed in this paper.


### 6.2. Software Defect Prediction Based on Anomaly Detection

At present, the research on treating defect prediction as anomaly detection is relatively less. In order to solve the class imbalance problem, Nahar Neela et al. [11] first tried to apply anomaly detection to software defect prediction. They first used Exhaustive subsetting and Iterative subsetting to select the best attributes set. Then, they modeled nondefected software module by incorporating both univariate and multivariate Gaussian distribution. Finally, unseen instances were determined as nondefective or defective based on their deviation from the generated model. Afric et al. [12] proposed the Reconstruction Error Probability Distribution (REPD) model for Source code defect prediction. They employed autoencoder neural network architecture to establish an anomaly detection model, and classified the examples as nondefective or defective according to different reconstruction error. The experimental results showed that the REPD model achieved significantly better predicted results. Those study works that treat defect prediction as anomaly detection are quite promising for solving the class imbalance problem. As far as we know, we are the first to propose a model like ADGAN-SDP, which utilized BiGAN to construct defect prediction model based on anomaly detection.


## 6.1. Class Imbalance Problem

The class imbalance problem is one of the main problems affecting the performance of defect prediction. Researchers have proposed several methods to solve the problem. Bennin et al. [38] proposed a data oversampling method called MAHAKIL; this method was based on the genetic theory of chromosomes to synthesize new minority samples. MAHAKIL could increase the diversity of data and reduce data over-fitting risk. Arar and Ayan [39] used cost-sensitive artificial neural networks to predict software defects. Meanwhile, they used a bee colony algorithm to train prediction models. For solving the class imbalance problem, Zhang et al. [40] proposed a model called the cost-sensitive residual convolutional neural network (CS-ResNet) for PCB cosmetic defect detection. The model added a cost-sensitive adjustment layer that assigned larger weights to minority real defects based on the class-imbalance degree in the standard ResNet [41]. In addition, ensemble learning can also be used to deal with class imbalance problems [42, 43]. Unlike most researchers who regard defect prediction as a classification, we study defect prediction from the perspective of anomaly detection to completely solve the problem of class imbalance. Besides, instead of the supervised learning method commonly used in the classification model to train the prediction model, a semi-supervised method is employed in this paper.


## 6.2. Software Defect Prediction Based on Anomaly Detection

At present, the research on treating defect prediction as anomaly detection is relatively less. In order to solve the class imbalance problem, Nahar Neela et al. [11] first tried to apply anomaly detection to software defect prediction. They first used Exhaustive subsetting and Iterative subsetting to select the best attributes set. Then, they modeled nondefected software module by incorporating both univariate and multivariate Gaussian distribution. Finally, unseen instances were determined as nondefective or defective based on their deviation from the generated model. Afric et al. [12] proposed the Reconstruction Error Probability Distribution (REPD) model for Source code defect prediction. They employed autoencoder neural network architecture to establish an anomaly detection model, and classified the examples as nondefective or defective according to different reconstruction error. The experimental results showed that the REPD model achieved significantly better predicted results. Those study works that treat defect prediction as anomaly detection are quite promising for solving the class imbalance problem. As far as we know, we are the first to propose a model like ADGAN-SDP, which utilized BiGAN to construct defect prediction model based on anomaly detection.


## 7. Threat to Validity

Internal validity threats. We have carefully checked the codes and data. However, there may still errors that are ignored. Moreover, eight baseline models are implemented by calling theImblearn and Scikit-learn toolkits with default settings. In the field of machine learning, different parameter settings lead to different experimental results. Therefore, other tools or different parameter settings may deviate from the experimental results in this paper.External validity threats. The experimental data in this paper use 19 projects from NASA, AEEEM, and ReLink. However, in order to further prove the generality of ADGAN-SDP, it is necessary to experiment on more projects.Construct validity threats. We use AUC, G-mean, and F1, three widely used evaluation indicators. In addition, precision and recall, two evaluation indicators, are also used. Moreover, the Wilcoxon signed-rank test and post-Nemenyi test are applied to investigate the statistical difference between ADGAN-SDP and baseline models.


## 8. Conclusion

For software defect prediction, class imbalance problem makes prediction model more biased towards majority classes so as to reduce prediction performance. In addition, due to the lack of a large amount of high-quality labelled data, a robust high-quality prediction model usually cannot be obtained. In response to the above challenges, this paper attempts to make a binary classification problem convert to an anomaly detection problem. The ADGAN-SDP model can not only fundamentally avoid the class imbalance problem but also alleviate the problem of lack of a large amount of high-quality labelled data to a certain extent because the semi-supervised training method is used. The experimental results show that ADGAN-SDP model outperforms all baseline models. In addition, the ADGAN-SDP model has more recall compared with other baseline models. These findings suggest that the anomaly detection model has more advantages than classification-based models for software defect prediction. In summary, the anomaly detection method can be applied to the software defect prediction to fundamentally solve the problem of class imbalance.



---

*Source: 5024399-2022-04-13.xml*