Detecting Credit Card Fraud using Machine Learning

Credit card is getting increasingly more famous in budgetary exchanges, simultaneously frauds are likewise expanding. Customary techniques use rule-based master frameworks to identify fraud practices, ignoring assorted circumstances, the outrageous lopsidedness of positive and negative examples. In this paper, we propose a CNN-based fraud detection system, to catch the natural examples of fraud practices gained from named information. Bountiful exchange information is spoken to by an element lattice, on which a convolutional neural organization is applied to recognize a bunch of idle examples for each example. Trials on true monstrous exchanges of a significant business bank show its boss presentation contrasted and some best-in-class strategies. The aim of this paper is to merge between Convolutional Neural Network (CNN), Long-Short Term Memory (LSTM), and Auto-encoder (AE) to increase credit card fraud detection and enhance the performance of the previous models. By using these four models; CNN, AE, LSTM, and AE&LSTM. each of these models is trained by different parameter values highest accuracy has been achieved where the AE model has accuracy =0.99, the CNN model has accuracy =0.85, the accuracy of the LSTM model is 0.85, and finally, the AE&LSTM model obtained an accuracy of 0.32 by 400 epoch. It is concluded that the AE classifies the best result between these models.


Introduction
The detection of credit card fraud has recently spread due to increased fraud that can be described as a deliberate ploy committed to achieve some kind of gain, usually based on money. It's an unfair practice that's becoming increasingly happening day after day. In recent times the use of electronic devices in payment methods such as credit cards, as a result of which, credit card fraud has increased [1], as the majority of people have become shopping through the Internet and pay and pay their bills from credit cards and pay as well, and people can get money and transfer them using their online banking systems. All this technology our lives are easier and faster, despite all these positive aspects. This technology has brought a significant risk in terms of unauthorized payments, known as financial frauds. We can express these banking transactions as fraud and online identity theft, and fraud on payment cards may amount to money laundering [2]. Prior to the widespread adoption of machine learning and deep learning, it was difficult for banks and businesses to classify fraud in detection systems. The problem is addressed by converting the fraud problem into a binary classification file, thanks to advances in learning supervision. Suitable for high-risk transactions. Many researchers have gathered financial data through networks and banks in recent years in order to build a fraud detection system. These algorithms' goal is to build a supervised learning model in the data set without being explicitly programmed [3].
Credit card fraud is a modern problem of our time as technology develops. In this chapter, we talk about the most important scientific terms related to fraud. We also study and analyze the history of experiments and research of scholars and experts on fraud, after which the proposed system will be presented and discussed briefly Credit card fraud can be described as illegal usage of Mastercard information for online purchase. Charge card trades are done truly or basically. Physical trades imply trades incorporating physical collaboration with shipper. Customers are expected to present a physical card at the reason for acquirement. Virtual trades suggest trades performed over the web or telephone. It anticipates that customers should give certain card information, (for instance, CVV number, mystery key, security question, etc.) for online purchases. The advancement of Visas has not recently made online trades reliable, more straightforward, pleasing and beneficial, it has moreover given new deception events to criminals, and extended the movement of blackmail. The effect of Mastercard distortion is upsetting and it is having affected the overall economy in quantifiable habits. An enormous number of US dollar has been lost by various individuals and organizations. In 2009, the full-scale assessment of online solicitation (for product and ventures just) was generally US$15 billion. Also, 84% of these solicitations were paid on the web. In 2013, coercion was surveyed to cost US retailers about $23 billion, and in 2014, the cost of deception rose to generally $32 billion [4].

Background
There are many benefits to using a credit card in everyday life, but there are also many drawbacks, the most significant of which is the risk of fraud. To mitigate this risk, some machine learning methods can be employed to collecting data, which is what we really discuss in this article [1].

Convolutional neural network (CNN)
Initially we give a portray for CNN-based fraud detection framework as illustrated in Figure 1. The CNN model is suitable for preparing a large amount of data, and it has the tool to avoid the model over-fit. Image order and discourse signal processing are two examples of disciplines where convolutional neural networks have found success. There is a total of six different levels in this system. The input is a feature matrix. Additionally, the first layer is a convolutional one, followed by a sub testing one. On top of it, there's a convolutional layer for good measure. As an added bonus, the final three layers are all located on the complete association layer. Figure 2 shows the structure of the CNN model [5]. Compared to conventional CNN the precision rate of traditional BP neural networks with two hidden layers can be stabilized at around 91%. When we talk about sequencing, we're referring to the complete network. Layers for pooling and a fully connected layer with four consecutive convolutional distribution and distributed layers the convolutional layer method extracts and automatically extracts the input data's local features. Derivative qualities are new features associated with the input characteristics, but their physical characteristics are not explained. Context does help the model classify things. The layer of pooling combines the properties of nearby regions. They work together to reduce information redundancy by performing a single higher-level function. In the final classification's position, the layer that is fully connected plays a role. There is a 65 second training process for the element sequencing convolutional neural network, as opposed to the other two convolutional neural networks. It takes 752 seconds to train a model with ten different feature combinations. It takes 352 seconds to train a CNN without using the feature derivative.
The model's overall performance is even worse than their method whenever we have included the computation of the generated features. The current CNN model is linked to the CNN based on feature sequencing. A number of experiments have shown that the new model presented in this study outperforms the conventional CNN model depending on the outcome of each forecast and does not require a huge number of derivatives. It does not require high-dimensional input features or derivative variables and can obtain a generally well-ordered input arrangement in a small number of iterations [6].

Long short-term memory (LSTM)
LSTM (Long Short-Term Memory) was developed in 1997. LSTM is much of the time utilized as a model to tackle issues in AI 28. It is intended to deal with long haul reliance issue that vanilla Recurrent Neural Network (RNN) can't oblige 29. Our inspiration in utilizing LSTM is to separate the data from successive information [2].

Auto-encoder (AE)
Autoencoder (AE) is a form of ANN (artificial neural network) is an algorithm that spread over backpropagation by placing inputs equivalent with outputs. As in Figure 3, it contains a hidden inner layer that defines the code used to describe the entry, and consists of two main elements: the first is encoding: it identifies the value of the entry in the code, and the other decoding: it draws a code to rebuild the primary portal as in. Autoencoder (AE) has several different types depending on their inclusion of hidden interior layers, The most important Encoded Automatic Noise Reduction. As illustrated in Figure 4. Literature review During our research, we read many scientific papers that specialized in detecting fraud on the credit card, and We collected the most important information in Table 1. Now we will talk about some of the research that will help us with our work. Pipe-ling and ensemble learning were proposed by the authors of [15] as a way to detect credit card fraud. Nine strategies were evaluated and compared for this work, including RF, LR, NB and KNN, as well as MLP and pipelining. Nine Method was applied to a database containing 284,807 anonymized transactions to extract the best of method in fraud detection depending on time and quantity, and compared to Accuracy where the nine Methodists were as follows: KNN  Similarly, the authors of [7] present a detection method for credit card fraud constructed by machine learning models and the collection of machine learning models. While researching several credit card fraud detection systems, the authors of this work compiled data to find the most effective algorithm for solving their problem. We used each method of LR, DT, SVM and RF on database consisting of 284,786 transactions to be the result of my random forest achieved the best value as the of Precision = 0.997, Sensitivity = 0.984 and the Accuracy = 0.986.
To improve performance, the paper proposes a deep neural network-based algorithm for credit card detection in [3]. We employ four methods: NN, SVM, Nave Bayes, and Logistic Regression. On both scores, the neural network model (NN) outperforms the other models. NN has a precision of 0.954. NN accuracy with (focal loss) = 0.957. The NN with a focal loss has a higher fraud detection accuracy, implying that the focal loss can improve NN model training. The work on [9] suggest data imbalance, they proposed framework is presented as being two main stages are involved: learning and prediction. The learning is offline and includes transformation of functions, normalization, training of models, and optimization. To build the model of Deep Ensemble Learning, To fit into the model, the characteristics are converted to tensors and they applied Extra-Tree Ensemble in and class derived using DNN are improved through the ensemble method in this path, but in the prediction phase the online transaction characteristics are transformed into a tensor and Supplied to the model proposed. To mark the transaction as fraudulent or legitimate, the model generates the alarm, the accuracy of their model up 99.99.8% and proposed comparison of the proposed DEAL with benchmark ML classifiers, LR and SVM, and DL models, CNN, MLP, and, Auto-Encoder (AE), SVM 67%, LR 63% ,CNN 82%, MLP 81%, AE 67%, and DEAL 99.8%.
In the study of [12], Using sliding window methodology, the authors proposed and developed a new fraud detection approach for streaming transactional data with the goal of extracting behavioral patterns from prior customer transaction details. After that they applied different Methods the Random forest is higher accuracy up to 0.99% and others Local Outlier factor and Accuracy up to 45% and Isolation forest is 0.58%, Logistic regression is 0.97%, Decision tree 0.97%. Monitoring for Credit Card Theft They used two different classification techniques from artificial neural networks focused on the Multilayer Perceptron and Extreme Learning Machine Structures to detect fake transactions on the credit card fraud dataset with an accuracy of up to 97.84 percent: the Multilayer Perceptron (MLP) and the Extreme Learning Machine (ELM). One hidden layer feedforward artificial neural network (SLFN) is used in Extreme Learning Machine, and the weights connecting the hidden nodes to their outputs are computed analytically. Only one neural network feeds information into it. MLP is a feed-forward net that also uses the gradient descent Method to reduce the amount of the error evaluated by the mean absolute percentage error.

Experiments
This part presents the proposed fraud detection model and depict its stages, as in Figure 5. The model is divided into 3 phases to be specific input stage, during applying the model stage and output stage. First the credit card dataset is taken details and the process of training from the selection of the coding environment and the preprocessing used on the dataset before balance and after. We explain two techniques that are used to deal with imbalance dataset. We divided into two parts data preprocessing and code implementation. In the Implementation of our project, we used the following tools: the first tool is the Colab which is a creation from google research it is a Jupyter notebook hosted service that provides free access to computing resources including GPUs (Graphics Processing Unit) and TPU (Tensor Processing Unit) industrialized by Google specifically for neural network machine learning. TPU considered to quicken deep learning methods. The second tool is Python has become popular programming language. we used to develop code to predict frauds using machine learning. Data Preprocessing The project aims to increase the accuracy and the imbalanced data should be solved before the training. In most cases, imbalance data refers to a classification problem in which the classes are not defined similarly. As shown in Figure 6, there is a very high difference between the number of Normal and fraud from our dataset which mean imbalanced data and that will affect the test result. Imbalanced data affect the prediction by predict Credit card Fraud and Normal operation. There are two ways to deal with imbalanced data. Remove sample data from the major class due to Under-Sampling. The Over-Sampling, which duplicates samples from the minority, is also a concern. Figure 7 depicts the outcome after data balancing was applied. Through our experimentation with both under-Sampling and over-Sampling, it became clear to us that better and higher values using over-Sampling due to taking a large data sample, training it and testing it, which improves the accuracy ratio.
We employ Accuracy, precision, recall, F1-score, ROC, AUC, and a confusion matrix to assess the classification model's performance.
Accuracy: addressing the quantity of exact expectations for all forecasts, is additionally the establishment boundary utilized for model assessment.

accuracy TP TN TP TN FP FN
Precision: is the part of effectively predicted positive perceptions to the absolute expected positive perceptions.
Recall: is an estimation of the quantity of positive cases altogether the positive information which the classifier effectively anticipated.
F1-score: is the Precision and Recall weighted normal. This score subsequently considers both bogus positive and bogus negatives. It isn't as clear to get a handle on instinctively as accuracy, yet F1 is by and large more valuable than exactness, specifically if the class appropriation is lopsided. It shows the presentation of an arrangement model at all grouping limitations via a curve called the receiver operating characteristic curve (ROC curve). True Positive Rate and False Positive Rate are two of the parameters included. .

Results and discussion
This study was implemented in Google Colab Notebook, using python. It was not a successful experience and the Classify the AE best result with Over-Sampling technique, The our dataset is contain 284315 Normal transaction and 492 fraud transaction [16] [17] as we mentioned previously we used Under-Sampling and Over-Sampling to balanced dataset we use this technique with AE, CNN, LSTM, AE&LSTM and with different epoch value on Colab Notebook, the result after sampling dataset with Under-Sampling and Over-Sampling at epoch 400 shown in Table 2. As shown in Figure 8, the train and validation accuracy. The train accuracy and the validation accuracy significantly increased from 0 to 40 epoch and from 40 to 400 the train accuracy increased in Converging values but the validation accuracy is not fixed in the same value. The figure shows also the train and validation loss. The train loss decreased when the epoch value increase. The validation loss is not fixed. It is increased and decreased in different values. Figure 9 illustrates the train and validation accuracy. The train accuracy and the validation accuracy significantly increased from 0 to 50 epoch and from 50 to 400 the train accuracy increased in Converging values but the loss value is not fixed. It is increased and decreased in different values. The train loss decreased when the epoch value increase. The loss value decreased when the number of epochs value increase.   Figure 10 illustrates the train and validation accuracy. The train accuracy and the validation accuracy significantly increased from 0 to 40 epoch and from 40 to 400 the train accuracy increased in Converging values but the validation accuracy is not fixed in the same value. It also shows the train and validation loss. The train loss decreased when the epoch value increases the loss value is not fixed. It is increased and decreased in different values. While in Figure 11 the train and validation accuracy. The train accuracy fixed from 0 to 50 but from 50 to 400 is not fixed some time decreased or increased. the accuracy value is not fixed in the same value. In addition, it shows the train and validation loss. The train loss fixed from 0 to 200 but from 200 to 400 is not fixed. The validation loss is not fixed. It is increased and decreased in different values. The difference between the three previous methods and our proposed is demonstrated in Figure 12. The four models: CNN, AE, LSTM, and AE&LSTM, have been trained by different parameter values and the highest test accuracy achieved AE = 0.99, CNN = 0.85, LSTM = 0.85 and AE&LSTM = 0.32 by 400 epochs. we conclude the AE classify best result between this models and AE&LSTM did not achieve good results.

Conclusion
The goal of this research is to combine between CNN, LSTM, and Auto-encoders (AEs) in order to progress credit card fraud detection and the performance of prior models. CNN, AE, LSTM, and AE&LSTM are four models that can be used. Different parameter values are used to train each of these models. The AE model has the highest accuracy, with an accuracy of 0.99, the CNN model has an accuracy of 0.85, the LSTM model has an accuracy of 0.85, and the AE&LSTM model has an accuracy of 0.32 after 400 epochs. The AE classifies the best outcome among these models, it is concluded. In the near future, we will explore some more technique [18][19][20][21][22][23][24][25][26][27] of security to detect and classify the fraud detection in credit card.