# The Optimized Anomaly Detection Models Based on an Approach of Dealing with Imbalanced Dataset for Credit Card Fraud Detection

Authors: Yan-Feng Zhang; Hong-Liang Lu; Hong-Fan Lin; Xue-Chen Qiao; Hao Zheng
Journal: Mobile Information Systems
 (2022)

---

## Abstract

Credit card fraud is a major problem in today’s financial world. It induces severe damage to financial institutions and individuals. There has been an exponential increase in the losses due to fraud in recent years. Hence, effectively detecting fraudulent behavior is of vital importance for either financial institutions or individuals. Since credit fraud events account for a small proportion of all transaction events in real life, the datasets about credit fraud are usually imbalanced. Some common classifiers, such as decision tree and naïve Bayes, are unable to detect fraud. Furthermore, in some cases, traditional strategies for dealing with an imbalanced problem, such as the synthetic minority oversampling technique (SMOTE), are not effective for the fraud detection datasets. To accurately detect fraud behavior, this study uses anomaly detection on imbalanced data, as well as Isolation Forest (IForest) with kernel principal component analysis. A one-class support vector machine (OCSVM) with AdaBoost is used as two models to detect outliers which significantly improves detection accuracy and efficiency. The model achieved 96% accuracy, 100% precision, 96% recall, and 98%F1 score, respectively. The proposed model is expected to become a helpful tool for finding credit card fraud detection, and the analysis presented in this study will provides useful insights into credit card fraud detection mechanisms.


---

## Body

## 1. Introduction

The unauthorized use of credit cards to obtain money, products, or services is known as credit card fraud. Credit cards are now extensively used anywhere and at any time, especially with the introduction of E-commerce and contactless payment [1]. Every year, millions of people become victims of credit card theft. Credit card fraud is pervasive worldwide as a result of the widespread use of credit cards. Due to the large volume of data, monitoring credit card transactions is challenging. As a result, credit card theft is usually ignored, resulting in significant losses for both consumers and issuers [2].Over the years, the quantity of card transactions appears to have increased, resulting in a similar increase in stolen card numbers. Credit card fraud losses follow a similar pattern, with increasing losses recorded each year [3]. The fraud detection system has evolved into an important tool for ensuring the integrity of E-payments. To allow authentic consumers to conduct their transactions, a safe and reliable banking system for E-commerce needs real-time scrutiny of transactions [4].Many strategies for detecting credit card fraud have been recommended in the literature [5, 6]. Lucas and Johannes [7] identified three challenging problems in credit card fraud detection. The first is a data imbalance issue created by the large disparity in numbers between the positive and negative classes. Credit card fraud detection systems are prone to overfit normal transactions since normal transactions greatly outnumber illegal transactions. The second issue is the shifting in datasets, which means that fraud patterns may change. New client behaviors and attacks on credit card transactions will make it difficult for fraud detection methods to maintain their effectiveness. The final issue is the omission of sequential data between consecutive operations. Srivastava et al. [8] proposed a credit card fraud detection system based on a hidden Markov model and explained the respective stochastic process. Kunlin [9] developed a memory-enhanced framework for detecting credit card frauds. A sequential memory-enhanced neural network is used in the model. The authors employed transaction logs in their model, bringing it nearer to a real-world application. It also has a low false positive rate, which aids in system stability and the reduction of false complaints. The disadvantage of this model is that it included a full description of each consumer. The authors in [10] proposed a new fraud detection system called CoDetect. It detects several types of frauds using graph similarity and feature matrices. A confidence level is also included to detect potentially suspicious transactions. The system can be used to observe the fraudulent transaction, as well as to see the characteristic that caused the flag to be raised. Moreover, tests were conducted on real-world datasets and yielded positive results. The patterns of features were also developed, which can aid in the detection of emerging fraud methods. Randhawa et al. [11] employed various algorithms for credit card fraud detection. The performance of different algorithms was compared including Bayesian, neural networks, decision trees, logistic regression, support vector machine, and AdaBoost. The statistic employed was the Matthews correlation coefficient. Using AdaBoost and majority voting, they get a perfect score of 1.0. Different levels of noise were added to the data to ensure the robustness of the system. Satisfactory results were obtained with up to 30% noise addition. Jiang et al. [12] used the user’s behavioral tendencies to create a profile of the user. The classifier rating is updated based on the stream of data as the system provides a feedback option, so users can be confident in the results. Acceptable results were obtained with up to 30% noise addition. Gmez et al. [13] used artificial neural networks to detect and prevent fraudulent transactions and analyzed the model using several indicators, including value detection rate and true false positive rate. The authors in [14] employed a bagging ensemble classifier for credit card fraud detection using a decision tree. They put the models to the test with varied numbers of fraud cases ranging from 3% to 20%. Across all test cases, the model produced the same results.Taking credit fraud information as the dataset, in this study, a new model is proposed to effectively detect a few sample categories and abnormal samples while ensuring accuracy. Anomaly detection algorithms are employed to the imbalanced dataset problems, building new models, and Isolation Forest with KPCA and OCSVM with AdaBoost instead of conventional methods such as SMOTE. The model is evaluated in terms of accuracy, precision, recall, andF1 score. The proposed model has the potential to detect more fraud samples accurately and provide high performance as compared to the other fraud detection models.The rest of the manuscript is organized into five sections. In Section2, a detailed description of the data preparation is presented and four different classifiers and SMOTE are used on the dataset to detect fraud samples. The IForest with KPCA and OCSVM with AdaBoost as two models are used to detect fraud samples. In Section 3, the proposed model is evaluated and compared with other state-of-the-art models. Finally, Section 4 is the conclusion.


## 2. Data Preparation

### 2.1. Dataset

In this study, a credit card fraud dataset is used. The dataset is imbalanced data. The dataset is comprised of 307510 rows and 122 columns including target columns. The feature information includes the gender of the client, the income of the client, and loan annuity. The dataset is too large and is divided into 3 parts (object, integer, and float) based on its data type. Second, missing value detection is performed on the dataset. Next, a histogram is used to check the distribution of variables. Numerical values are used to represent relationships between variables and between variables and classes.


### 2.2.K-Best Feature Selection

Feature selection is a critical issue in machine learning, which can reduce some irrelevant features and improve classification performance. Therefore, it is a good way to analyze high-dimensional datasets [15]. Through EDA, we found a lot of missing data in this dataset. Moreover, many features play a minor role in anomaly detection. The K-best feature selection algorithm is used to screen out 10 features that critically influence anomaly detection.


### 2.3. SMOTE

SMOTE algorithm is a typical oversampling method. An unbalanced dataset is one in which at least one of the classes represents a very small minority. SMOTE is an oversampling method that can be applied to datasets that are unbalanced [16]. When a model is tested on an unbalanced dataset, the results can be substantially different. When SMOTE is used to an unbalanced dataset, the minority class is increased until it equals the total number of majority class members. One of the common issues found in datasets used for classifications is the imbalanced class issue. In this study, SMOTE is used to balance the credit card detection database [17].


### 2.4. IForest

IForest is an ensemble technique that realizes data anomaly detection by isolating abnormal data points. The IForest has the characteristics of high precision and high calculation rate, and it is suitable for dealing with big data problems. The IForest algorithm has a similar idea with random forest; however, it does not require computing the distance between two points. The IForest is an unsupervised version of random forest and is widely used in anomaly detection. The IForest randomly isolates the data space to construct an isolation tree [18]. It also conforms to the idea of quality evaluation. Quality is defined as the depth of nodes in the isolation tree, which is also called ITree. The smaller the depth, the more likely it is to be an outlier.The iForest solves two problems of anomaly detection in high-dimensional datasets. First, the IForest does not depend on distance, and time cost does not relate to data dimension, which is a linear time complexity, and second, the IForest can deal with large datasets and is an ensemble method. The more there are ITrees, the more stable is the IForest [19]. Although IForest is suitable for anomaly detection of high-dimensional datasets, the detection efficiency will decrease with data distribution complexity. The algorithm has high volatility in anomaly detection of very high-dimensional data. Therefore, this paper proposes to use KPCA to reduce the dimension of the dataset to improve accuracy and efficiency. In short, to isolate high-density clusters, it requires to be cut so many times. However, low-density points can be isolated easily, which are depicted in Figure 1.Figure 1
The example of isolation forest partitioning non-anomalous and anomalous points [5].
(a)
Isolatingxi(b)
IsolatingxoThe process of detecting abnormal data through iForest is shown in Figure2. It shows each step and marks the training stage and testing stage for iForest.Figure 2
The process of detecting abnormal data through an isolated forest.Firstly, the dataset is subsampled. The definition of an anomaly in IForest algorithm is “few but different.” If the amount of data is too large, the anomaly points may be densely distributed. In this case, it is difficult to separate the abnormal data a few times. If there is little difference between the average path length required by the abnormal value and the normal value, it is difficult to distinguish the abnormal data for a long time. Therefore, subsampling should be carried out, and establishing the local model through subsampling can reduce this impact to achieve a better anomaly detection effect. The details are given in Algorithm1.Algorithm 1: iForest(X,t,ψ) [5]
Inputs: X: input data, t: number of trees, ψ: subsampling sizeOutput: a set of tiTrees1:Initialize Forest2:set height limitl=ceilinglog2ψ3:fori=1 to t do4:X′⟵sampleX,ψ5:Forest⟵Forest∪iTreeX′,0,l6:end for7:returnForestThe construction method of the ITree is a binary method, which recursively builds ITree to form an isolation forest. For each generation of ITree, we need to randomly select attributes and randomly select the partition value between the maximum and minimum values to divide the data into left and right sub-trees. The process is illustrated in Algorithm2.Algorithm 2:iTreeX,e,l [5]
Inputs: X: input data, e: current tree height, l: height limitOutput: an iTree1:ife≥lorX≤1then2:  returnexNodeSize⟵X3:else4:  letQ be a list of attributes in X5:  randomly select an attributeq∈Q6:  randomly select a split pointp from max and min values of attribute q in X7:Xl⟵filterX,q<p8:Xr⟵filterX,q≥p9:  returninNodeLeft⟵iTreeXl,e+1,l,10:Right⟵iTreeXr,e+1,l,11:SplitAtt⟵q,12:SplitValue⟵p13:end ifThe path lengthHx of sample point x is the number of edges passing from the root node of ITree to the leaf node. The computation of Hx is listed in Algorithm 3.Algorithm 3: PathLengthx,T,e [5]
Input: x: an instance, T: an iTREE, e: current path length;to be initialized to zero when first calledOutput: path length of x1:ifT is an external node then2:  returne+cT.size {c. is defined in Equation (1)}3:end if4:a⟵T.splitAtt5:ifxa<T.splitValuethen6:  returnPathLengthx,T,left,e+17:elsexa≥T.splitValue8:  returnPathLengthx,T.right,e+19:end ifThe anomaly score is calculated by Equation (1). If s approaches 1, the sample is judged as abnormal, and if s approaches 0, the sample is judged as normal.
(1)sx,n=2−Ehx/cn.


### 2.5. KPCA

PCA is a linear transformation approach for compressing high-dimensional data with minimal data loss. The original sample space is used for PCA, whereas the extended feature space is used for kernel PCA. Kernel PCA is a form of learning machine that is built on kernels. PCA is not good at extracting nonlinear features from data, but KPCA can solve such problems [8]. Generally, KPCA uses kernel functions to map data samples to nonlinear functions, transform the nonlinear relations in the original space into linear relations in the high-dimensional space, and calculate the principal components of the high-dimensional feature space.KPCA can project the input control into high-dimensional feature space through nonlinear mapping to process nonlinear data.SupposeΦ can be a random nonlinear map into the feasibly high-dimensional space F. To calculate dot products (Φx∙Φy), kernel representations can be used to calculate the dot product value without using Φ.
(2)kx,y=<Φx∙Φy.Figure3 is an example of KPCA. It shows a possibility that after a nonlinear map, nonlinear data become linear data.Figure 3
The principals of PCA and KPCA [6].The RBF is used to realize the division of nonlinear data. The process is shown in Figure4.Figure 4
The process of KPCA with RBF.


### 2.6. OCSVM

An OCSVM based on the traditional SVM can be used to train a model for anomaly detection to solve the problem of training classification with only one class of samples. Using negative samples during the training can improve the performance of the OCSVM, such as obtaining a tighter boundary for the target data with outliers surrounded.The basic idea of OCSVM is using a kernel function to map the input space into a high-dimensional space. The coordinate origin is seen as the abnormal sample, OCSVM then tries to separate samples from the origin with maximum margin in the high-dimensional space. After training datad, the decision function fd will be made. As shown in Figure 5, the positive value is considered the normal class, and the negative value is on behalf of the abnormal class.Figure 5
One-class SVM classifier [18].To separate the dataset from the origin, this study solves the following quadratic programming problem.(3)minω,ξ,ρ12∥ω∥2+1υN∑i=1Nξi−ps.t.ω·ΦXi≥ρ−ξi,ξi≥0,i=1,⋯,NTheXi represents the input space, the training data points are represented by N, and Φ denotes the map from input to feature space. ω and ρ are normal vector and compensation parameters of a hyperplane in feature space, respectively. The adjustable parameter υ∈0,1 shows an upper bound on the fraction of outliers and varies to get the best performance. Moreover, the slack variable ξi allows some training points that are misclassified. If ω and ρ are the solutions of the previous quadratic programming problem, the decision function can be obtained as follows:
(4)fx=signω·Φx−ρ.Since most of the point values in the dataset are positive. At the same time, the value of∥ω∥2 should be relatively small. In this study, we used the Gaussian radial basis kernel function (RBF), which is commonly used for the OCSVM.
(5)Kxi,yi=<Φxi,Φyi>=exp−g∥xi−yi∥2.Therefore, we can get that the parametersυ and g are the keys to solving the problem, and g,υ is the parameter combination that is optimized.In this study, the process of the OCSVM algorithm dealing with grid search is depicted in Figure6.Figure 6
OCSVM algorithm with GridSearch.The major steps are described as follows:(i)
Step 1: find the training samples and test samples from the dataset(ii)
Step 2: apply normalization to reduce the training time and guarantee the converge of the model(iii)
Step 3: select the RBF kernel function and use cross-validated grid search to find the best parameter combinationg,υ. Through the experiment, we got that g=0.1,υ=0.08(iv)
Step 4: complete the algorithm and build the OCSVM model


### 2.7. Boosting-AdaBoost

AdaBoost combines a group of weak learners into a solid learner to make the training errors minimum. This algorithm iteratively combines weak learners to form a powerful learner that predicts the outcomes more accurately. There are different types of boosting methods. In this study, we used the AdaBoost classifier.As shown in Figure7, the AdaBoost algorithm gets better results by repeating the given base classifier several times. By using iterative operation, the AdaBoost algorithm identifies misclassified data points and adjusts their weights to minimize the training error. The model continues to optimize sequentially until it yields the strongest predictor. One of the advantages of the algorithm is that it uses the classification error rate to adjust the distribution of the data and the coefficients of the base classifiers.Figure 7
Architecture of AdaBoost [17].To optimize OCSVM and further compare it with IForest at the same level, we used OCSVM as a base classifier to carry out boosting-integrated training. From the principle of the AdaBoost algorithm, we know that the training error drops exponentially if each weak base classifier is slightly better than the random classifier, and we can get better results.We modified the AdaBoost algorithm to make it fit for OCSVM as given in Algorithm4. To obtain the appropriately considerable weight of misclassification data and significant coefficients of high-accuracy classifiers, we selected a constant like the exponent of the weight for varying base classifiers.Algorithm 4: OCSVM algorithm with AdaBoost [16]
InputTraining set:xi∈X,i=1⋯NThe probability distribution of each data:DtiMaximum number of iterations:TOutputHx, which is the ensemble of the base classifiers.Initialize:Dti=1/NFort=1,⋯,TStep 1: train base learner by distributionDt.Step 2: get base classifiersht, get the rate of the error-classified samples εti=Pri~Dtht−1Step 3 chooseαt=eεtic,c is a constant.Step 4: updateDt+1i=Dti/Zt×eεt/1−εtwhereZt is a normalization factor.End forOutput the final hypothesis:Hx=sign∑t=1Tαthtx.


## 2.1. Dataset

In this study, a credit card fraud dataset is used. The dataset is imbalanced data. The dataset is comprised of 307510 rows and 122 columns including target columns. The feature information includes the gender of the client, the income of the client, and loan annuity. The dataset is too large and is divided into 3 parts (object, integer, and float) based on its data type. Second, missing value detection is performed on the dataset. Next, a histogram is used to check the distribution of variables. Numerical values are used to represent relationships between variables and between variables and classes.


## 2.2.K-Best Feature Selection

Feature selection is a critical issue in machine learning, which can reduce some irrelevant features and improve classification performance. Therefore, it is a good way to analyze high-dimensional datasets [15]. Through EDA, we found a lot of missing data in this dataset. Moreover, many features play a minor role in anomaly detection. The K-best feature selection algorithm is used to screen out 10 features that critically influence anomaly detection.


## 2.3. SMOTE

SMOTE algorithm is a typical oversampling method. An unbalanced dataset is one in which at least one of the classes represents a very small minority. SMOTE is an oversampling method that can be applied to datasets that are unbalanced [16]. When a model is tested on an unbalanced dataset, the results can be substantially different. When SMOTE is used to an unbalanced dataset, the minority class is increased until it equals the total number of majority class members. One of the common issues found in datasets used for classifications is the imbalanced class issue. In this study, SMOTE is used to balance the credit card detection database [17].


## 2.4. IForest

IForest is an ensemble technique that realizes data anomaly detection by isolating abnormal data points. The IForest has the characteristics of high precision and high calculation rate, and it is suitable for dealing with big data problems. The IForest algorithm has a similar idea with random forest; however, it does not require computing the distance between two points. The IForest is an unsupervised version of random forest and is widely used in anomaly detection. The IForest randomly isolates the data space to construct an isolation tree [18]. It also conforms to the idea of quality evaluation. Quality is defined as the depth of nodes in the isolation tree, which is also called ITree. The smaller the depth, the more likely it is to be an outlier.The iForest solves two problems of anomaly detection in high-dimensional datasets. First, the IForest does not depend on distance, and time cost does not relate to data dimension, which is a linear time complexity, and second, the IForest can deal with large datasets and is an ensemble method. The more there are ITrees, the more stable is the IForest [19]. Although IForest is suitable for anomaly detection of high-dimensional datasets, the detection efficiency will decrease with data distribution complexity. The algorithm has high volatility in anomaly detection of very high-dimensional data. Therefore, this paper proposes to use KPCA to reduce the dimension of the dataset to improve accuracy and efficiency. In short, to isolate high-density clusters, it requires to be cut so many times. However, low-density points can be isolated easily, which are depicted in Figure 1.Figure 1
The example of isolation forest partitioning non-anomalous and anomalous points [5].
(a)
Isolatingxi(b)
IsolatingxoThe process of detecting abnormal data through iForest is shown in Figure2. It shows each step and marks the training stage and testing stage for iForest.Figure 2
The process of detecting abnormal data through an isolated forest.Firstly, the dataset is subsampled. The definition of an anomaly in IForest algorithm is “few but different.” If the amount of data is too large, the anomaly points may be densely distributed. In this case, it is difficult to separate the abnormal data a few times. If there is little difference between the average path length required by the abnormal value and the normal value, it is difficult to distinguish the abnormal data for a long time. Therefore, subsampling should be carried out, and establishing the local model through subsampling can reduce this impact to achieve a better anomaly detection effect. The details are given in Algorithm1.Algorithm 1: iForest(X,t,ψ) [5]
Inputs: X: input data, t: number of trees, ψ: subsampling sizeOutput: a set of tiTrees1:Initialize Forest2:set height limitl=ceilinglog2ψ3:fori=1 to t do4:X′⟵sampleX,ψ5:Forest⟵Forest∪iTreeX′,0,l6:end for7:returnForestThe construction method of the ITree is a binary method, which recursively builds ITree to form an isolation forest. For each generation of ITree, we need to randomly select attributes and randomly select the partition value between the maximum and minimum values to divide the data into left and right sub-trees. The process is illustrated in Algorithm2.Algorithm 2:iTreeX,e,l [5]
Inputs: X: input data, e: current tree height, l: height limitOutput: an iTree1:ife≥lorX≤1then2:  returnexNodeSize⟵X3:else4:  letQ be a list of attributes in X5:  randomly select an attributeq∈Q6:  randomly select a split pointp from max and min values of attribute q in X7:Xl⟵filterX,q<p8:Xr⟵filterX,q≥p9:  returninNodeLeft⟵iTreeXl,e+1,l,10:Right⟵iTreeXr,e+1,l,11:SplitAtt⟵q,12:SplitValue⟵p13:end ifThe path lengthHx of sample point x is the number of edges passing from the root node of ITree to the leaf node. The computation of Hx is listed in Algorithm 3.Algorithm 3: PathLengthx,T,e [5]
Input: x: an instance, T: an iTREE, e: current path length;to be initialized to zero when first calledOutput: path length of x1:ifT is an external node then2:  returne+cT.size {c. is defined in Equation (1)}3:end if4:a⟵T.splitAtt5:ifxa<T.splitValuethen6:  returnPathLengthx,T,left,e+17:elsexa≥T.splitValue8:  returnPathLengthx,T.right,e+19:end ifThe anomaly score is calculated by Equation (1). If s approaches 1, the sample is judged as abnormal, and if s approaches 0, the sample is judged as normal.
(1)sx,n=2−Ehx/cn.


## 2.5. KPCA

PCA is a linear transformation approach for compressing high-dimensional data with minimal data loss. The original sample space is used for PCA, whereas the extended feature space is used for kernel PCA. Kernel PCA is a form of learning machine that is built on kernels. PCA is not good at extracting nonlinear features from data, but KPCA can solve such problems [8]. Generally, KPCA uses kernel functions to map data samples to nonlinear functions, transform the nonlinear relations in the original space into linear relations in the high-dimensional space, and calculate the principal components of the high-dimensional feature space.KPCA can project the input control into high-dimensional feature space through nonlinear mapping to process nonlinear data.SupposeΦ can be a random nonlinear map into the feasibly high-dimensional space F. To calculate dot products (Φx∙Φy), kernel representations can be used to calculate the dot product value without using Φ.
(2)kx,y=<Φx∙Φy.Figure3 is an example of KPCA. It shows a possibility that after a nonlinear map, nonlinear data become linear data.Figure 3
The principals of PCA and KPCA [6].The RBF is used to realize the division of nonlinear data. The process is shown in Figure4.Figure 4
The process of KPCA with RBF.


## 2.6. OCSVM

An OCSVM based on the traditional SVM can be used to train a model for anomaly detection to solve the problem of training classification with only one class of samples. Using negative samples during the training can improve the performance of the OCSVM, such as obtaining a tighter boundary for the target data with outliers surrounded.The basic idea of OCSVM is using a kernel function to map the input space into a high-dimensional space. The coordinate origin is seen as the abnormal sample, OCSVM then tries to separate samples from the origin with maximum margin in the high-dimensional space. After training datad, the decision function fd will be made. As shown in Figure 5, the positive value is considered the normal class, and the negative value is on behalf of the abnormal class.Figure 5
One-class SVM classifier [18].To separate the dataset from the origin, this study solves the following quadratic programming problem.(3)minω,ξ,ρ12∥ω∥2+1υN∑i=1Nξi−ps.t.ω·ΦXi≥ρ−ξi,ξi≥0,i=1,⋯,NTheXi represents the input space, the training data points are represented by N, and Φ denotes the map from input to feature space. ω and ρ are normal vector and compensation parameters of a hyperplane in feature space, respectively. The adjustable parameter υ∈0,1 shows an upper bound on the fraction of outliers and varies to get the best performance. Moreover, the slack variable ξi allows some training points that are misclassified. If ω and ρ are the solutions of the previous quadratic programming problem, the decision function can be obtained as follows:
(4)fx=signω·Φx−ρ.Since most of the point values in the dataset are positive. At the same time, the value of∥ω∥2 should be relatively small. In this study, we used the Gaussian radial basis kernel function (RBF), which is commonly used for the OCSVM.
(5)Kxi,yi=<Φxi,Φyi>=exp−g∥xi−yi∥2.Therefore, we can get that the parametersυ and g are the keys to solving the problem, and g,υ is the parameter combination that is optimized.In this study, the process of the OCSVM algorithm dealing with grid search is depicted in Figure6.Figure 6
OCSVM algorithm with GridSearch.The major steps are described as follows:(i)
Step 1: find the training samples and test samples from the dataset(ii)
Step 2: apply normalization to reduce the training time and guarantee the converge of the model(iii)
Step 3: select the RBF kernel function and use cross-validated grid search to find the best parameter combinationg,υ. Through the experiment, we got that g=0.1,υ=0.08(iv)
Step 4: complete the algorithm and build the OCSVM model


## 2.7. Boosting-AdaBoost

AdaBoost combines a group of weak learners into a solid learner to make the training errors minimum. This algorithm iteratively combines weak learners to form a powerful learner that predicts the outcomes more accurately. There are different types of boosting methods. In this study, we used the AdaBoost classifier.As shown in Figure7, the AdaBoost algorithm gets better results by repeating the given base classifier several times. By using iterative operation, the AdaBoost algorithm identifies misclassified data points and adjusts their weights to minimize the training error. The model continues to optimize sequentially until it yields the strongest predictor. One of the advantages of the algorithm is that it uses the classification error rate to adjust the distribution of the data and the coefficients of the base classifiers.Figure 7
Architecture of AdaBoost [17].To optimize OCSVM and further compare it with IForest at the same level, we used OCSVM as a base classifier to carry out boosting-integrated training. From the principle of the AdaBoost algorithm, we know that the training error drops exponentially if each weak base classifier is slightly better than the random classifier, and we can get better results.We modified the AdaBoost algorithm to make it fit for OCSVM as given in Algorithm4. To obtain the appropriately considerable weight of misclassification data and significant coefficients of high-accuracy classifiers, we selected a constant like the exponent of the weight for varying base classifiers.Algorithm 4: OCSVM algorithm with AdaBoost [16]
InputTraining set:xi∈X,i=1⋯NThe probability distribution of each data:DtiMaximum number of iterations:TOutputHx, which is the ensemble of the base classifiers.Initialize:Dti=1/NFort=1,⋯,TStep 1: train base learner by distributionDt.Step 2: get base classifiersht, get the rate of the error-classified samples εti=Pri~Dtht−1Step 3 chooseαt=eεtic,c is a constant.Step 4: updateDt+1i=Dti/Zt×eεt/1−εtwhereZt is a normalization factor.End forOutput the final hypothesis:Hx=sign∑t=1Tαthtx.


## 3. Results

### 3.1. IForest and IForest with KPCA

It can be seen from the confusion matrix that the IForest achieves the effect of identifying exceptions, which is higher than the traditional classifier without SMOTE processing. However, there are still many outliers that have not been identified.The dataset has more than 100 dimensions; because it is taken from the real dataset, there are many missing values and attributes that contribute little to anomaly detection. However, the IForest algorithm selects attributes randomly, so too many attributes will reduce the probability of selecting practical attributes and have a bad impact on the training effect.According to Figure8 and Table 1, after adding KPCA, the overall effect of the algorithm is significantly improved with 87% accuracy as compared to independent IForest with 80% accuracy. This shows the proposed model is significantly improved, and more outliers can be detected.Figure 8
The confusion matrix of IForest and IForest with KPCA.Table 1
The performance of IForest and IForest+KPCA.
Performance metricIForestIForest with KPCAAccuracy0.8090.873Precision0.8600.937Recall0.8550.925F1 score0.8520.931


### 3.2. OCSVM and AdaBoost-OCSVM

From the confusion matrix shown in Figure9, although the performance of OCSVM seems to be great in handling one-class classification problems, its classification ability and outlier detection ability still need to be enhanced. Therefore, in this study, we modified AdaBoost to adapt it to OCSVM for better performance. The results of the modified AdaBoost are shown in Table 2 and Figure 9, respectively. It can be easily seen that the precision of the modified AdaBoost with OCSVM is superior to that of the traditional OCSVM. The AdaBoost-OCSVM achieved an accuracy of 96% as compared to the accuracy of OCSVM with 91% accuracy. Through the experiment, the modified AdaBoost with OCSVM has a tighter boundary than the traditional one when ν has the same value.Figure 9
The confusion matrix of (a) OCSVM and (b) OCSVM with AdaBoost.
(a)(b)Table 2
Performance comparison of OCSVM and OCSVM with AdaBoost.
Performance metricOCSVMAdaBoost-OCSVMAccuracy0.910.96Precision0.941.0Recall0.960.96F1_score0.950.98


### 3.3. Performance Comparison

To validate the performance of the proposed model, we used some basic machine learning algorithms to test their accuracy and performance and make a comparison with the proposed model. Table3 shows that the four classifiers (logistic regression, decision tree, K-nearest neighbors, and naïve Bayes) contain a high accuracy, and the performances of the four classifiers are also relatively high. However, the four classifies are either unable to detect outliers. Since the dataset we used is highly imbalanced, they could not partition the fraud and nonfraud one precisely. This is significantly lower than the accuracy of the proposed model (AdaBoost+OCSVM) with 96% accuracy (Table 2).Table 3
Performance comparison with existing models.
ClassifierAccuracyPrecisionRecallF1 score1Logistic regression0.920.921.000.962K-nearest neighbors0.910.920.990.953Decision tree0.840.930.900.914Gaussian NB0.920.921.000.96


#### 3.3.1. SMOTE and IForest

As the performances are shown in Figure10, although the SMOTE could detect outliers, its accuracy is relatively low. We believe it is because the dataset is super high dimensional, so even though with the technique like SMOTE to oversample the dataset, it still seems very complex for classifiers to process efficiently. However, IForest, according to its theory, could not only detect outliers with high efficiency but also maintain a very high level of accuracy and performance. Moreover, the IForest process the dataset within one second, which is much lower than SMOTE which required ten seconds.Figure 10
The confusion matrix of four basic classifiers after implementing SMOTE.
(a)
Logistic regression(b)
K-nearest neighbors(c)
Decision tree(d)
Naive Bayes


## 3.1. IForest and IForest with KPCA

It can be seen from the confusion matrix that the IForest achieves the effect of identifying exceptions, which is higher than the traditional classifier without SMOTE processing. However, there are still many outliers that have not been identified.The dataset has more than 100 dimensions; because it is taken from the real dataset, there are many missing values and attributes that contribute little to anomaly detection. However, the IForest algorithm selects attributes randomly, so too many attributes will reduce the probability of selecting practical attributes and have a bad impact on the training effect.According to Figure8 and Table 1, after adding KPCA, the overall effect of the algorithm is significantly improved with 87% accuracy as compared to independent IForest with 80% accuracy. This shows the proposed model is significantly improved, and more outliers can be detected.Figure 8
The confusion matrix of IForest and IForest with KPCA.Table 1
The performance of IForest and IForest+KPCA.
Performance metricIForestIForest with KPCAAccuracy0.8090.873Precision0.8600.937Recall0.8550.925F1 score0.8520.931


## 3.2. OCSVM and AdaBoost-OCSVM

From the confusion matrix shown in Figure9, although the performance of OCSVM seems to be great in handling one-class classification problems, its classification ability and outlier detection ability still need to be enhanced. Therefore, in this study, we modified AdaBoost to adapt it to OCSVM for better performance. The results of the modified AdaBoost are shown in Table 2 and Figure 9, respectively. It can be easily seen that the precision of the modified AdaBoost with OCSVM is superior to that of the traditional OCSVM. The AdaBoost-OCSVM achieved an accuracy of 96% as compared to the accuracy of OCSVM with 91% accuracy. Through the experiment, the modified AdaBoost with OCSVM has a tighter boundary than the traditional one when ν has the same value.Figure 9
The confusion matrix of (a) OCSVM and (b) OCSVM with AdaBoost.
(a)(b)Table 2
Performance comparison of OCSVM and OCSVM with AdaBoost.
Performance metricOCSVMAdaBoost-OCSVMAccuracy0.910.96Precision0.941.0Recall0.960.96F1_score0.950.98


## 3.3. Performance Comparison

To validate the performance of the proposed model, we used some basic machine learning algorithms to test their accuracy and performance and make a comparison with the proposed model. Table3 shows that the four classifiers (logistic regression, decision tree, K-nearest neighbors, and naïve Bayes) contain a high accuracy, and the performances of the four classifiers are also relatively high. However, the four classifies are either unable to detect outliers. Since the dataset we used is highly imbalanced, they could not partition the fraud and nonfraud one precisely. This is significantly lower than the accuracy of the proposed model (AdaBoost+OCSVM) with 96% accuracy (Table 2).Table 3
Performance comparison with existing models.
ClassifierAccuracyPrecisionRecallF1 score1Logistic regression0.920.921.000.962K-nearest neighbors0.910.920.990.953Decision tree0.840.930.900.914Gaussian NB0.920.921.000.96


### 3.3.1. SMOTE and IForest

As the performances are shown in Figure10, although the SMOTE could detect outliers, its accuracy is relatively low. We believe it is because the dataset is super high dimensional, so even though with the technique like SMOTE to oversample the dataset, it still seems very complex for classifiers to process efficiently. However, IForest, according to its theory, could not only detect outliers with high efficiency but also maintain a very high level of accuracy and performance. Moreover, the IForest process the dataset within one second, which is much lower than SMOTE which required ten seconds.Figure 10
The confusion matrix of four basic classifiers after implementing SMOTE.
(a)
Logistic regression(b)
K-nearest neighbors(c)
Decision tree(d)
Naive Bayes


## 3.3.1. SMOTE and IForest

As the performances are shown in Figure10, although the SMOTE could detect outliers, its accuracy is relatively low. We believe it is because the dataset is super high dimensional, so even though with the technique like SMOTE to oversample the dataset, it still seems very complex for classifiers to process efficiently. However, IForest, according to its theory, could not only detect outliers with high efficiency but also maintain a very high level of accuracy and performance. Moreover, the IForest process the dataset within one second, which is much lower than SMOTE which required ten seconds.Figure 10
The confusion matrix of four basic classifiers after implementing SMOTE.
(a)
Logistic regression(b)
K-nearest neighbors(c)
Decision tree(d)
Naive Bayes


## 4. Conclusion

Although the traditional models with SMOTE have achieved excellent performance for solving the unbalanced class issue, their classification ability still needs to be enhanced in many real-world applications. This study utilized anomaly detection on unbalanced data, as well as IForest with kernel principal component analysis, to accurately detect fraud activity. To detect outliers, two models were used: a one-class support vector machine (OCSVM) and AdaBoost, which considerably improved detection accuracy and efficiency. The proposed fraud detection model obtained 96% accuracy, 100% precision, 96% recall, and 98%F1 score. Furthermore, the proposed method was compared with other algorithms such as logistic regression, K-nearest neighbors, decision tree, and naïve Bayes. The results show that the improved IForest and AdaBoost with OCSVM have better performance than the traditional methods. The method will be extended in the future by incorporating numerous more datasets for solving other application problems that can be solved using the proposed anomaly detection method.



---

*Source: 8027903-2022-04-25.xml*