Fraud Detection Using Supervised Learning Algorithms: March 2024
Fraud Detection Using Supervised Learning Algorithms: March 2024
net/publication/378680090
CITATIONS READS
0 44
1 author:
SEE PROFILE
All content following this page was uploaded by Daniel Ihotu Abutu on 02 March 2024.
Project on:
“Online payment Fraud detection”
Submitted By
Daniel Ihotu Abutu (S5549478)
Submitted On
12th May 2023
1
Table of Content
Page
ABSTRACT 3
CHAPTER ONE
1.1. Introduction 5
1.2. Real world problem 5
1.3. Aim and objectives 6
CHAPTER TWO
2.1. Adopted artificial intelligence approach 7
2.2. Artificial intelligence approach implementation 7
2.2.2. Random forest 8
2.2.3. Ada boost classifier 8
2.2.4. Logistic regression 8
2.2.5. Decision tree classifier 8
CHAPTER THREE
3.1. Evaluation 9
3.1.1. Feature engineering and data cleaning 10
3.1.2. Model selection and performance analysis 10
CHAPTER FOUR
4.1. Results and discussion 12
CHAPTER FIVE
5.1. Conclusion and future work 15
References 16
Appendices 18
LIST OF ABBREVATIONS
DT Decision Tree
RF Random Forest
LR Logistic Regression
AB AdaBoost
AUC-ROC Area under the curve - Receiver Operating Characteristic
EDA Exploratory Data Analysis
2
LIST OF FIGURES
Page
LIST OF TABLES
3
ABSTRACT
The rise of online payment systems has led to an increase in payment fraud, particularly in
credit card fraud. Credit card fraud involves theft or fraud using or during payment with a credit
card. Online payment fraud is a significant concern for financial institutions as it affects
customer trust and can cause monetary loss. In this project, we use a comprehensive evaluation
method to compare the performance of four different machine learning models on the same
online payment transaction information dataset. The performance of each model was evaluated
using the Area under the ROC Curve (AUC), classification report, and confusion matrix. The
four models are Random Forest, Decision Tree, Logistic Regression and AdaBoost. In this
project, a dataset contains over six million online payment transactions were preprocessed and
divided into 80% training and 20% testing. The data was heavily skewed so we used random
undersampling to balance our dataset by randomly removing samples from the majority class
and evaluated the performance of the four models. The performance of the models in term of
AUC-ROC can be ranked as RF 99.76% > DT 99.73% >AB 97.57% > LR 76.21% and in terms
of execution time, DT > LR>AB>RF. According to the comparison results, Random Forest has
the highest AUC-ROC and consistency in predicting fraudulent transactions within this dataset.
Selecting the most important feature for the model reduces the execution time to predict our
result, increases efficiency and provides a more accurate result. After performing feature
selection, we were able to achieve an AUC of 100% for Random Forest which indicates a
perfect classifier. Therefore, it is recommended as the primary machine learning algorithm for
online payment fraud detection.
4
CHAPTER ONE
1.1. INTRODUCTION
The rise of online payment systems has led to an increase in payment fraud, particularly in
credit card fraud. Credit card fraud involves theft or fraud using or during payment with a credit
card. The theft of identity, which is closely related to credit card fraud, has also increased over
the years. Credit card fraud is a broad term used to describe illegal activities that involve theft
or fraud during a payment transaction using a credit card. "Credit card fraud" often refers to
the fraudulent use of payment cards, such as debit or credit cards. The procurement of goods
or services or payments to another account under the criminal's control could be the motivation.
Credit card fraud is a serious concern nowadays due to the rise in fraud in governmental
institutions, courts, the financial sector, the corporate sector, and many other institutions. Credit
card transaction fraud is the fraudulent use of a credit card account by a person other than the
account owner. Credit card fraud currently affects every nation and every country. Credit card
fraud is prohibited by the law. As a result, both financial institutions and individuals sustain
huge losses (Malaker et al., 2020). As reported by Forbes (2011 cited by Seera et al., 2021)
according to the American Bankers, payment card transactions are a prime target for fraud as
they estimate that approximately 10,000 such transactions take place every second on a global
scale. Fraud is now a major concern in many commercial and business domains. Credit card
companies have been fighting against fraud since the introduction of credit cards by the Diners
Club in 1950 as reported by Forbes (2011 cited by Seera et al., 2021). According to (Ahsan et
al., 2022, pp 1338) “The ease of using a credit card causes many people to use a credit card.
This triggers the emergence of credit card fraud. Credit card fraud events often occur and cause
big financial disadvantages. Villains can apply some methods (phishing or trojans) to swipe
credit card data from the customer. Hence, developing a powerful fraud detection system is
very crucial because it can detect fraud when hackers use stolen cards for consumption” Credit
card fraud detection models have become a common method of preventing consumers from
losing money to online criminals and fraudsters. As a result, many consumers can now avoid
falling victim to these types of scams (Garg, Chaudhary, and Mishra, 2021).
Machine learning has played a crucial role in automatic fraud detection. Machine
learning involves the use of algorithms and statistical models to enable computers to learn from
data and perform tasks automatically. This involves the computer recognizing and
understanding the characteristics of the data and using that information to make predictions or
decisions (Strelcenia and Prakoonwit, 2023). According to Bhattacharyya et al (2011 cited by
Seera et al., 2021, pp 172) “fraudulent mechanisms have evolved along with the models used
by the bank to avoid fraud detection”. Therefore, it's miles vital to broaden powerful and green
strategies to discover price fraud (Seera et al., 2021). The developed methods also need to be
revised continually by the advances in technologies.
The rise of online payment systems has led to an increase in payment fraud, particularly in
credit card fraud. Credit card fraud involves theft or fraud using or during payment with a credit
card. The theft of identity, which is closely related to credit card fraud, has also increased over
the years. Financial institutions can use machine learning algorithms to detect fraudulent
transactions and continuously update their methods to keep up with evolving fraud
mechanisms. This project aims to develop an effective and efficient fraud detection system that
will help credit card companies detect fraudulent transactions.
5
This project was built using data that is openly accessible. Financial data is typically private,
thus there aren't many publicly accessible datasets that may be utilized for research. This
project makes use of a fictitious dataset created by the simulator PaySim and made publicly
accessible on Kaggle. The dataset was created using aggregated measurements from a
multinational provider of mobile banking services' private dataset (Lopez-Rojas, Elmir, and
Axelsson, 2016).
There are 6,362,620 transactions, the data set has 11 attributes which include;
• Type of transactions
• Amount transacted
• Customer ID and Recipient ID
• Old and New balance of Customer and Recipient
• The time step of the transaction
• Whether the transaction was fraudulent or not
https://www.kaggle.com/datasets/ealaxi/paysim1
The focus of this project is to accurately classify a valid transaction from a fraudulent
transaction. The objectives for this project could be solved using artificial intelligence in the
following ways:
• Developing an accurate and effective machine learning model for online payment
fraud detection.
• Applying four supervised machine learning algorithms and evaluating which
algorithm gives the best result.
• To perform feature selection and improve the efficiency of the model.
• Applying an 80 to 20 ratio to train and test data.
• Evaluating the result using the confusion matrix, classification report and AUC-ROC.
6
CHAPTER TWO
Online payment fraud is a significant concern for financial institutions as it affects customer
trust and can cause monetary losses. Machine learning algorithms offer a solution to detect
fraudulent transactions accurately and efficiently in a fully automated process, saving time and
labour (He, 2022). However, choosing the right machine learning algorithm for fraud detection
is challenging as there are many different algorithms available that use various techniques and
models (He, 2022). Researchers have employed different machine learning algorithms to
predict credit card fraud with varying levels of accuracy. For example, Meier (2022) used KNN
and Naive Bayes to predict credit card fraud with 85% accuracy, while Sailusha et al. (2020b)
employed Random Forest and AdaBoost algorithms, obtaining high accuracy, precision, recall,
and F1 scores. The highest accuracy was achieved by Adaboost and Logistic Regression in the
work of Sailusha et al. (2020b).
To compare the efficiency of different models, this project focuses on classification
models in supervised learning. Four algorithms, namely Random Forest (RF), Logistic
Regression (LR), Decision Tree (DT), and AdaBoost (AB) are picked to analyze efficiency.
This paper aims to answer which model has the best accuracy and which model is the most
efficient. This project will address the gap in the literature where it is difficult to compare the
efficiency of different models due to varying datasets and evaluation metrics used in different
studies. By analyzing the four selected algorithms' efficiency, we will provide insights into the
most accurate and efficient machine-learning algorithm for detecting fraudulent transactions in
online payments.
The potential applications of automatic fraud detection are vast, as it can protect against
cybercriminals and guarantee the safety of online users. Furthermore, it can discourage
malicious actors who partake in web-based fraud. To effectively combat fraudulent activities
in a significant number of credit card transactions, the development of an accurate automatic
fraud detection method is of utmost importance, as highlighted by Strelcenia and Prakoonwit
(2023). Numerous approaches have been devised to detect fraudulent credit card transactions,
but none have provided a foolproof solution. Machine learning has emerged as the industry
standard for various applications due to its versatility. In machine learning, algorithms
concentrate on learning and enhancing themselves independently by analyzing relevant data
(Strelcenia and Prakoonwit, 2023).
Based on the above research, we have formulated the following hypothesis. i) “There’s no
significant difference in the performance of the model”. Ho: h1=h2=h3=h4
HA: At least AUC of one model is different than others.
7
2.2.2. Random Forest (RF)
Random Forest is a powerful machine learning technique that involves building multiple
decision trees and combining their results. Decision trees use information acquisition at each
node to classify data points. They categorize each data point and check for information at each
node. The node with the highest information gain is used for classification. This process
continues until all nodes are used or no further information is obtained (Valli et al., 2022).
Random forest was first proposed by Breiman (2001) who was inspired by earlier work by
Amit and Geman (1997).
train data
8
CHAPTER THREE
3.1. EVALUATION
There are 6,362,620 transactions, the data set has 11 attributes which include;
I. Type of transactions
II. Amount transacted
III. Customer ID and Recipient ID
IV. Old and New balance of Customer and Recipient
V. The time step of the transaction
VI. Whether the transaction was fraudulent or not
Fig 2 above shows that the data is imbalanced with only 0.13% of transactions being
fraudulent, and the number of safe transactions is much higher. The data needs to be balanced
for accurate predictions.
Fig 3 showed that the majority of fraudulent transactions belong to the 'TRANSFER' and
'CASH_OUT' types, indicating that these types are more susceptible to fraud.
9
Fig 4: Count of type transaction distribution
Fig 4 indicates that only 16 out of 4,097 fraud transfers were flagged by the system. This
suggests that the system's parameters for detecting fraud are unreasonable, and the
isFlaggedFraud feature can be considered insignificant and discarded without losing
information.
We split our data into 80% training and 20% testing and evaluated the performance of our
model on unbalanced data before using the random undersampling technique to balance the
data. To accurately evaluate the performance of our model, we used three evaluation metrics
namely, classification report, confusion matrix and AUC-ROC.
A classification report is a performance evaluation metric used to show the precision, recall,
F1 Score, and support of a classification model.
𝑇𝑃
Recall = 𝑇𝑃+𝐹𝑁 (1)
𝑇𝑃
Precision = 𝑇𝑃+𝐹𝑃 (2)
𝑃𝑟𝑒𝑐𝑠𝑖𝑜𝑛 ∗ 𝑅𝑒𝑐𝑎𝑙𝑙
F1 = 2 * 𝑃𝑟𝑒𝑐𝑠𝑖𝑜𝑛+ 𝑅𝑒𝑐𝑎𝑙𝑙 (3)
𝑇𝑃+𝑇𝑁
Accuracy = (4)
𝑇𝑃+𝑇𝑁+𝐹𝑃+𝐹𝑁
10
A confusion matrix can be described as a 2 x 2 matrix of the True positive, False positive,
False negative and True negative.
Confusion matrix
Positive(+) Negative(-)
Positive(+) TP FP
Negative(-) FN TN
The ROC curve is a graphical representation of the performance of a binary classifier. It plots
the true positive rate (sensitivity/recall) against the false positive rate (1 - specificity) at various
threshold settings.
The AUC is a performance metric for machine learning models that measures the overall
accuracy across all threshold settings. A score of 1 means perfect classification, while 0.5
means no better than random. Confusion matrix, classification report, and ROC curve
analysis help evaluate model performance beyond accuracy, showing how well the model
performs across various metrics.
11
CHAPTER FOUR
Table 1
Confusion matrix before random undersampling (unbalanced data)
Model False positive (FP) False Negative(FN)
Decision Tree 10 11
Random Forest 1 11
Logistic
Regression 83 783
AdaBoost 6 80
12
Table 2
Classification report before Random undersampling (unbalanced data)
precision Recall F1-score
RF valid(0) 1.00 1.00 1.00
Fraud(1) 1.00 0.99 1.00
Table 3
Confusion matrix after random undersampling (balanced data)
Model False positive (FP) False Negative(FN)
Decision Tree 9 9
Random Forest 3 5
Logistic
Regression 83 783
AdaBoost 6 80
Table 4
Classification report for balanced data
precision Recall F1-score
RF valid(0) 1.00 1.00 1.00
Fraud(1) 1.00 0.99 1.00
13
Table 5
AUC before and after random undersampling
Model AUC score (%) before RUS AUC score (%) after RUS
Decision Tree 99.66 99.73
Random Forest 99.67 99.76
Logistic
Regression 76.21 76.21
AdaBoost 97.57 97.57
Table 6
Confusion matrix after feature selection
Model False positive (FP) False Negative(FN)
Random Forest 0 0
Table 7
Classification report for random forest after feature selection
precision Recall F1-score
RF valid(0) 1.00 1.00 1.00
Fraud(1) 1.00 1.00 1.00
Table 8
AUC after feature selection
AUC score (%) after feature
Model selection
14
CHAPTER FIVE
15
REFERENCES
Ahsan, M., Susanto, T. Y., Virania, T. A. and Jaya, A. I., 2022. CREDIT CARD
FRAUD DETECTION USING LINEAR DISCRIMINANT ANALYSIS
(LDA), RANDOM FOREST, AND BINARY LOGISTIC REGRESSION.
BAREKENG: Jurnal Ilmu Matematika dan Terapan, 16 (4), 1337–1346.
https://doi.org/10.30598/barekengvol16iss4pp1337-1346
Amit, Y. and Geman, D., 1997 .Shape Quantization and Recognition with Randomized Trees.
Bhattacharyya, S., Jha, S., Tharakunnel, K. and Westland, J. C., 2011. Data mining for credit
https://doi.org/10.1016/j.dss.2010.08.008.
https://doi.org/10.1023/a:1010933404324
Forbes. (2011). Bringing trust back to the table—part one: Adyen and Mobile Payments.
Garg, V., Chaudhary, S. and Mishra, A.K., 2021 .ANALYSING AUTO ML MODEL FOR
https://doi.org/10.21276/ijircst.2021.9.3.5.
He, Y., 2022 .Machine Learning Methods for Credit Card Fraud Detection. Highlights in
https://doi.org/10.54097/hset.v23i.3204.
Lopez-Rojas, E.A., Elmir, A. and Axelsson, S. 2016 .Paysim: a financial mobile money
https://www.msc-les.org/proceedings/emss/2016/EMSS2016_249.pdf.
16
Malaker, A., Miad, A. H., Mim, F. K., Badhan, W. B. W., and Hossen, MD. I., 2020. An
Meier, T. M., 2022. Early Detecting Credit Card Frauds. Medium, Towards Data Science,
https://towardsdatascience.com/early-detecting-credit-card-frauds-38db7c190e44.
Rb, A. and Kr, S.K., 2021 .Credit card fraud detection using artificial neural network. Global
Rokach, L. and Maimon, O., 2005. Decision Trees. In: Maimon, O., Rokach, L. (eds) Data
166. https://doi.org/10.1007/0-387-25465-X_9.
Sailusha, R., Gnaneswar, V., Ramesh, R. and Rao, G. R., 2020b. Credit Card Fraud Detection
https://doi.org/10.1109/iciccs48265.2020.9121114.
Seera, M., Lim, C. P., Kumar, A., Dhamotharan, L. and Tan, K. H., 2021. An intelligent
Strelcenia, E. and Prakoonwit, S., 2023. Improving Classification Performance in Credit Card
https://doi.org/10.3390/ai4010008.
Valli, L. N., Sujatha, N. and Divya, D., 2022. A Novel Approach for Credit Card Fraud
17
APPENDICES
There are 6,362,620 transactions, the data set has 11 attributes which include.
I. Type of transactions
II. Amount transacted.
III. Customer ID and Recipient ID
IV. Old and New balance of Customer and Recipient
V. The time step of the transaction
VI. Whether the transaction was fraudulent or not
step represents a real-world time unit. In this instance, 1 step equals 1 hour. 744 steps
altogether (30 days simulation).
oldbalanceDest is the receiver of the initial balance prior to the transaction. Notably, there is
no information available for clients whose names begin with M (merchants).
newbalanceDest - the recipient of the new balance following the transaction. Notably, there is
no information available for clients whose names begin with M (merchants).
isFraud - This represents the transactions carried out by the simulation's fraudulent agents.
The agents' dishonest behavior in this data seeks to make money by seizing control of or
clients' accounts and attempting to drain the funds by moving to another account before
cashing out of the system.
18
HOW THE ALGORITHM WORKS
B = {TRANSFER, CASH_OUT}
A = {instance 1, instance 2, …. instance n}
LOGISTIC REGRESSION
Step 1: Compute the probability of B having class 1 given the values from A
Step 2: use sigma function to convert the output value of B {Fraud, Valid}.
Step 3: train C on the data where B is known for each input to predict 0 and 1.
Step 3: Let C estimate the value of B.
Step: use threshold to covert the probability of values in step 1.
19
HOW OUR OBJECTIVES WERE ACHIEVED
OBSERVATIONS
1) There was no change in the AUC, classification report and confusion matrix for LR
and AB before and after sampling technique.
2) We can observe that TRANSFER (16) transaction type transfers are those that are
flagged as fraudulent. Therefore, only 16 of the 4097 Fraud Transfers were detected
by the system.
Thus, the system only flagged 16 out of 6 million transactions. It is safe to claim that
the system's criteria for identifying fraudulent transactions are irrational.
3) Despite the fact that isFraud is always set when isFlaggedFraud is set, the fact that
isFlaggedFraud is only set 16 times in an apparent meaningless manner allows us to
treat this feature as insignificant and remove it from the dataset without losing any
data.
4) 'TRANSFER' and 'CASH_OUT' transactions are the only ones where fraud happens,
according to the exploratory data analysis (EDA).
20
LIBRARY USED AND THEIR FUNCTION
Library Function
“Math” This library was used for mathematical
computation.
“NumPy” np was used for numerical computing on
multi-dimensional arrays and matrices
“Pandas” Pd module was used to read our data and
store it in a dataframe for manipulation
“Plotly.express” px was used create to create interactive pie
plot.
“matplotlib” Plt module was used to create dashboards.
“random” Seed and sample modules were used to
generate pseudorandom numbers.
“OS” This library was used to locate path in my
system.
“Sklearrn.preprocessing” StandardScaler module was used to scale
the numeric data.
“Sklearn.tree” Decision tree algorithm module was
imported from this library.
“Sklearn.ensemble” Random forest and Ada boost algorithm
module was imported from this library.
“Sklearrn.linear_model” Logistic regression module was imported
from this library
“Sklearn.metrics” Average_precision_score,
classification_report, confusion_matrix,
accuracy_score, roc_curve, auc, and
precision_score was imported for evaluating
the performance of our model.
“seabon” Sns module was imported for visualizing
our data.
“Warnings” This module was used to control the
behavior warnings in our environment.
“collections” Counter module was imported to count the
frequency of items in the list.
“Sklearn.dataset” Make_classification module was used for
generating synthetic data
“Imblearn.under_sampling” Randomundersampler module was used to
balance our data.
“Sklearn.preprocessing” LabelEncoder module was used for one-hot
encoding
21
LIST OF EQUATIONS
22