Bank Payment Fraud Detection Simulation
Bank Payment Fraud Detection Simulation
CHAPTER-1
INTRODUCTION
1. INTRODUCTION
1.1 OVERVIEW:
The main purpose of Fraud Detection on Bank Payments is the generation of synthetic
data that can be used for fraud detection. BankSim is an agent-based simulator of bank
payment based on a sample of aggregated transactional data provided by a bank of Spain. Our
ultimate goal is for BankSim to be usable to model relevant scenarios that combine normal
payments and injected known fraud signatures. The dataset generated by BankSim contain no
personal information or disclosure of legal and private customer transactions. Therefore, data
can be shared by academic and others to develop and reason about fraud detection methods.
Synthetic data has the added benefit of being easier to acquire, faster and at less cost, for
Experimentation even for those that have access to their own data.
The main goal of developing this simulation is that it enables us to share realistic
fraud data, without exposing potentially business or personally sensitive information about
the actual source. As data relevant for computer security research often is sensitive, for a
multitude of reasons financial, privacy related, legal, contractual and other research has
historically been hampered by a lack of publicly available relevant datasets. Our aim with this
work is to address that situation. However, Simulation also have other benefits, It can be
much faster and less expensive than trying different scenarios of fraud, detection algorithms,
and personnel and security policy approaches in an actual store.
Fraudulent behavior can be seen across many different fields such as e-commerce,
healthcare, payment and banking systems. Fraud is a billion – dollar business and it is
increasing every year. The Pwc global economic crime survey of 2018 found that half of the
7200 companies they surveyed had experienced fraud of some kind.
Rules are great for detecting some type of frauds but they can fire a lot of false
positives or false Negatives in some cases because they have predefined threshold values. For
example let’s think of a rule for denying transaction which has an amount that is bigger than
10,000 dollars for a specific user. If this user is an experienced fraudster, he/she may be
aware of the fact that the system would have a threshold and he/she can just make a
transaction just below the threshold value (9999 dollars). For these types of problems
Machine Learning comes for help and reduces the risk of frauds and the risk of business to
lose Money. With the combination of rules and machine learning, detection of the fraud
would be more precise and confident. Fraud detection has been subjected to great interest to
the public. One way to generate a solution is to develop a machine learning model to detect a
fraud.
1.3 MOTIVATION:-
Fraudulent behavior can be seen across many different fields such as e-commerce,
healthcare, payment and banking systems. Fraud is a billion – dollar business and it is
increasing every year. The defense against fraud is an important topic that has seen some
study. In a bank the cost of fraud are of course ultimately transferred to the consumer, and
finally impacts the overall economy. Our aim with BankSim is to learn the relevant
parameters that govern the behavior of a bank payment system to simulate normal behavior
and inject specific fraud scenarios that are interesting to study.
The main contribution and focus of this project is a method of generating anonymous
synthetic data from aggregated transactional data of a bank payment system, that can be used
as part of the necessary data for the development and testing of fraud detection techniques.
Even so, the data set generated could also be the basis for research in other fields, such as
consumer behavior, general economic study including social development and forecasting.
1.4 CHALLENGES:-
The main challenges of this project are to produce a simulation that resembles a bank
payment system. Our main purpose is to generate a synthetic data set of commercial
transactions that can be used for the development and testing of different fraud detection
techniques. If we want to use the real original data for the development fraud detection
methods, it often happens that is difficult to find diverse and enough cases of fraud.
1.5 APPLICATION:-
The main goal of developing this project is that it enables us to share realistic fraud
data, without exposing potentially business or personally sensitive information about the
actual source. As data relevant for computer security research often is sensitive information
about the actual source. As data relevant for computer security research often is sensitive, for
a multitude of reasons financial, privacy related, legal, contractual and other, research has
historically been hampered by a lack of publically available relevant datasets. Our aim with
this work is to address that situation. However, simulation also have other benefits, it can be
much faster and less expensive than trying different scenarios of fraud, detection algorithms,
and personnel and security policy approaches in an actual store. Data has the added benefit of
being easier to acquire, faster and at less cost, for Experimentation even for those that have
access to their own data.
Chapter 1: Gives a brief overview about the project in terms of its, Statement of the
problem, Challenges, motivation, importance, application and the approach that is used to
achieve the goal. It also provides definitions and terms that are widely used throughout this
framework.
Chapter 2: Literature Survey in this section which shows the various analysis and
research made in the fields of one’s interest and the result analysis and research made in the
fields of one’s interest and the result already published, taking into account the various
parameters of the project and extent of the project.
Chapter 4: Experiments and results. The experiments and results include the
screenshots of some important aspects of the project.
Chapter 5: provides the conclusion drawn from testing. It also states the work that can
be done in future in order to further enhance the proposed system.
CHAPTER-2 LITERATURE
SURVEY
2.1:- OVERVIEW:-
In the Literature, while there are some related work, where there is currently a lack of
research in the area of simulation of Bank Systems, more specifically for fraud detection and
we have seen previously analyzed the implications of using machine learning techniques for
fraud detection using a synthetic data set (Lopez-Rojas and Axelsson, 2012a). We then built a
simple simulation of a financial transaction system based on these assumptions, in order to
overcome our limitations and lack of real data (Lopez- Rojas and Axelsson, 2012b).
The PwC global economic crime survey of 2018 [1] found that half (49 percent) of
the 7,200 companies they surveyed had experienced fraud of some kind. Even if fraud seems
to be scary for businesses it can be detected using intelligent systems such as rules engines or
machine learning. Many traditional machine learning algorithms have been applied
successfully in fraud detection scenario at [2016]. The challenge associated with detecting
fraud is that it requires real time detection and prevention. This section focuses on deep
anomaly detection (DAD) techniques for fraud detection.
Data mining research has yielded many significant and useful results such as
discovering consumer spending habits, detecting credit card fraud and identifying anomalous
social behavior. Information discovery and analysis systems (IDAS) extract information from
multiple sources of data and use data mining methodologies to identify potential significant
events and relationships. This research designed and developed a tool called IDAS data and
scenario generator (IDSG) to facilitate enough to generator synthetic data based on complex
semantic graphs.
In this section we describe how three example of fraud that can be implemented in
BankSim. These fraud scenarios are based on selected cases from the Grant Thornton report
Member and Council (2009). As can be seen, the different scenarios can be implemented in
almost the same way. Furthermore, a fraudster will probably use several different methods of
fraud, which means that BankSim needs to be able to model combinations of all fraud
scenarios implemented. Although the implementation of these scenarios is out of the scope of
this paper, we include a description and explain how to implement them in BankSim.
We will focus on card related frauds. This kind of fraud usually begins when the important
data on the card is compromised: Account name, credit card number, and expiration date and
verification code. This data can be acquired by a fraudster either by theft of the physical card
or by gaining knowledge of the important data associated with the account.
Theft
This scenario includes cases where the customer loses physical possession of her card
and a fraudster impersonates the customer purchasing goods or service with the stolen card.
In terms of the object model used in BankSim the Theft scenario can be implemented by the
following setting: Include in the fraudster the behavior of sensing customer proximity, then
execute the theft and later purchase goods from another merchant with the information from
the customer. The volume of fraudulent activity can be modeled changing the specific
parameter of number of theft, zip code and frequency. A ”red flag'' for detection in this case
could be a high number of unusual transactions with high value in a short period.
Cloned Card/Skimming
This scenario includes cases where the fraudster creates a clone of the card, letting the
user keep the original card but without knowledge of the loss of security. In terms of the
object model used in BankSim, the cloned card scenario can be implemented by the
following setting: Include in the fraudster the behavior of sensing customers’ proximity, then
execute the acquisition or cloning of a card and later purchase goods from another merchant
with the information from the customer. An alternative way to implement this scenario could
be when a merchant is compromised in different ways (e.g. by hacking) and allow a fraudster
to steal information from all customers that have been served there on a massive scale. The
volume of fraudulent activity can be modeled changing the specific parameter of number of
theft and merchant affected, zip code and frequency of use for purchasing. A”red flag'' for
detection in this case could be similar as previous case, a high number of unusual transactions
with high value in a short period. Other methods such as simultaneous payments in different
physical locations, or using the card far from previously known locations, could also be
flagged.
Internet purchases
This scenario includes cases where the fraudster uses a method called Carding to
purchase immaterial goods, e.g. music files, redeemable coupons, tickets etc. on the Internet
using websites that check the validity of the card instantly. This is to ascertain whether the
card data is still valid without having to run the risk of getting caught when using the card
while physically present. Similar to cloned cards the customer keeps the original card but
without knowledge of the situation. In terms of the object model used in BankSim the cloned
card scenario can be implemented by the following setting: Include in the fraudster the
behavior of sense customer’s proximity, then execute the acquisition of the important
information of a card and later on proceed with the method of Carding, to check for validity.
A ``red flag'' for detection in this case could be to have a black list of Carding websites and
proceed to cross this information with current user activity to detect any unusual purchases
after the Carding was executed.
CHAPTER-3
METHODOLOGY
3. METHODOLOGY
3.1 OVERVIEW:-
We aim to produce a simulation that resembles a bank payment system. Our main
purpose is to generate a synthetic data set of commercial transactions that can be used for the
development and testing of different fraud detection techniques.
If we want to use the real original data for the development of fraud detection
methods, it often happens that is difficult to find diverse and enough cases of fraud. However
this is not the case of a simulated environment, where fraud can be injected following known
patterns of fraud and flagged for easy recognition and evaluation of the performance of the
detectors.
Fraud detection results are highly dependent on the dataset. In this project we
collected the sample of aggregated transactional data provided by one bank in Spain with the
aim of promoting the development of applications for Big Data. This data contains several
thousand records of transactional data covering six months, from November 2012 until April
2013. BankSim, a simulator built on a sample of aggregated transactional data that one
Spanish bank made available for a contest to encourage the development of application in the
big data field and specifically based on their dataset. We detect the fraudulent transactions
from the BankSim dataset. This synthetically generated dataset consists of payments from
various customers made in different time periods and with different amounts. We produce
594643 records in total. Where 587443 are normal payments and 7200 fraudulent
transactions. Since this is a randomized simulation the values are of course not identical to
original data.
Depending on the way the real data is provided, we need to perform several
operations to convert the data into the format required. The simulator uses aggregations of
information over a period of time, as input. The time granularity of the aggregation is
specified on the simulation as a STEP. To accurately mimic the data distribution, we must
extract aggregated information from the original data that matches each step in the
simulation. There are also initial values and other input values extracted from the real data.
The information extracted is represented in terms of
Probabilities to ease the decision processes of the agents. Social Network Analysis (SNA)
helps to recreate the topology of the customers’ relations inside the simulation. The agent
interacts with other agents within the environment and this interaction is specified by the
information extracted during the SNA. The data analysis can also be done by employees of
the financial institution that have access to the sample. Researchers only need the output of
this step, to continue the process; this allows financial institutions to preserve the privacy of
the customers
www
The simulators are usually built to serve a purpose. Our simulators contain agents
that, under certain conditions, act contrary to the law. The synthetic dataset has the benefit
that can be generated according to the researcher’s needs to study how certain fraud might
affect a specific scenario. It can be a representation of the original dataset (sample). That is
why we extract the aggregated information from the sample. Part of the simulator validation
is to show that, given certain parameters, we can reproduce similar datasets.
4 Run the simulator several times using different random number seeds
This is one of the most important steps in the method. By changing the parameters in
the previews step, we can generate diverse scenarios. These scenarios produce datasets
with data that are labeled as fraudulent or not fraudulent. Once a dataset is generated,
different methods for fraud detection can be tested and evaluated using the fraud label. A
method for fraud detection can also be tested and evaluated with different scenarios that
use the same fraud label. Fraud prevention methods can be also is added to the simulator to
test and evaluate against fraud scenarios with the same flagged fraud.
The biggest advantage of using a simulator over a real dataset is that we know with
certainty how much fraud is present and where it is located. In a real dataset, it is
impossible to guaranty that there isn’t any undetected hidden fraud. Since we control our
malicious agents, we can flag all fraudulent behavior, because we have prior knowledge
about the level of fraud injected into the dataset. Measuring all the fraud present in a
dataset is one of the biggest challenges when using real data, but not with synthetic data. I
presented the classification report visualize displays the precision, recall, F1 and support
scores, Accuracy, Confusion matrix for the model. We have seen that these three
classifications such as xgBoost classifier, Random forest classification, K-NN are best for
the fraud detection. In order to support easier interpretation and problem detection.
3.2.1MODULES:-
The design of BankSim was based on the ODD model introduced by Grimm et al. (2006).
ODD contains 3 main parts: -
Overview
Design concepts
Details.
1. Overview
Purpose
In this project we collected the sample of aggregated transactional data provided by
one bank in Spain with the aim of promoting the development of applications for Big Data.
We detect the fraudulent transactions from the BankSim dataset. This synthetically generated
dataset consists of payments from various customers made in different time periods and with
different amounts.
We produce 594643 records in total. Where 587443 are normal payments and 7200
fraudulent transactions.
We aim to produce a simulation that resembles a bank payment system. Our main
purpose is to generate a synthetic data set of commercial transactions that can be used for the
development and testing of different fraud detection techniques.
If we want to use the real original data for the development of fraud detection methods, it
often happens that is difficult to find diverse and enough cases of fraud. However this is not
the case of a simulated environment, where fraud can be injected following known patterns of
fraud and flagged for easy recognition and evaluation of the performance of the detectors.
Merchant This agent serves the customer with one category of merchandise
specified by the original data. It offers products or services according to the statistics
obtained from the specific zip code and time (week, day of the week and/or hour).
They are waiting for customers to request products and register the payments.
Customer This agent's main objective is to satisfy a need for one of the 16
categories and purchase goods or services from merchants. They possess a payment
method which in this case we will be generalized as a credit card.
5 Design Concepts
The basic principle of this model is the concept of commercial transactions. We can
observe an emergent social network from the relation between the customers and the
DEPARTMENT OF COMPUTER SCIENCE MANGALORE UNIVERSITY Page 14
Fraud Detection On Bank Payment
merchants. Each of the customers has the objective of purchasing articles from the merchants.
The merchant’s objective is to serve the customers and commit the payment that results into
the generation of a synthetic data set.
In our virtual environment the interaction between agents is always between merchant
and customer. Purchasing articles from another customer or selling articles to another
merchant is not included in our model. Customers can scout for the merchants in any radial
direction from their current position in the virtual world and search for a merchant that
matches its category selection. If no merchant is found then the transaction cannot take place,
and the step for this customer ends. The agents do not perform any specific learning
activities. Their behavior is given by probabilistic Markov models where the probabilities are
extracted from the real data set.
3. Details
Initialization
The simulation starts with a number of merchants that match the categories of what a
specific zip code offers, an initial number of customers and fraudsters.
Input Data
BankSim has different inputs needed in order to run a simulation. The input data
concerns the distributions of probabilities for each of the merchants, and the consumer pattern
behavior of the customers specified by gender and age. The items that can be purchased are
all grouped into a category using the statistic measures for the payments. For setting the
parameters, we use a parameter file that is loaded as the simulation starts, it contains zip
codes that we want to simulate and the malicious parameters. Some parameters can also be
set manually in the GUI.
The zip codes are queried against the API of the bank and we retrieve information
corresponding to the customers: quantity, age and gender distribution. We also query the
merchants and obtain sales distributions for each of the merchant categories.
Sub models
Figure 1 shows the different use cases of the agents including the misused cases for
the fraudsters. This model represents the different actions that an agent can take inside the
system.
DEPARTMENT OF COMPUTER SCIENCE MANGALORE UNIVERSITY Page 15
Fraud Detection On Bank Payment
Find Merchant
The first step in a simulation for a customer is to find a merchant, each agent
decides which category of service they will want to find, so the next step is to sense
the environment and find a merchant that provides the category selected. Next search
by the customer starts here, i.e. the customers move from merchant to merchant.
Buy/Sell Once a customer finds a merchant and after a merchant offers a product, a
transaction takes place and it stores the required information for the generation of the
synthetic data of transactions.
Steal card or info Fraudsters move around the environment of the simulation and
find customers to steal the physical card or just the important information of the
customer credit card. This information is stored for later use. In this misuse case we
aim to emulate the behavior of a criminal performing a cloning of a card or just
stealing the card.
Abuse purchasing This misuse case is performed by Fraudsters; they make
purchases of goods or services on physical merchants or internet merchants that hides
their physical presence.
Report/Block Card This use case is performed by Customers, when they realize
that abusive behavior is committed on their accounts; they report the case to the bank
and block the card for further abuse.
HARDWARE:-
SOFTWARE:-
Python is a general –purpose interpreted, interactive, object oriented, and high – level
programming language. It was created by Guido van Rossum 1985-1990. Like Perl, Python
Source Code is also available under the GNU General Public License (GPL). Python is a high
level, interpreted, interactive and object-oriented scripting language. Python is designed to be
highly readable. It uses English keyword frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other languages.
Python version 3 is widely used to implement the Bank payment simulation for fraud
detection. Its design philosophy emphasizes code reliability and its syntax allows
programmers to express concepts in fewer lines of codes than possible in language such as c+
+ or java. The language provides constructs intended to clear programs on both small and
large scale. Python support multiple programming paradigms, including object oriented,
imperative and functional programming or procedural styles. It features a dynamic type
system and automatic memory management and has a large and comprehensive standard
library. Python interpreter are available for many operating systems.
Data As we can see in the first rows below the dataset has 9 feature columns and a target
column. The feature columns are:
Step: This feature represents the day from the start of simulation. It has 180 steps
so simulation ran for virtually 6 months.
Customer: This feature represents the customer id
ZipCodeOrigin: The zip code of origin/source.
Merchant: The merchant's id
zipMerchant: The merchant's zip code
Age: Categorized age
0: <= 18,
1: 19-25,
2: 26-35,
3: 36-45,
4: 46:55,
5: 56:65,
6: > 65
U: Unknown
Gender: Gender for customer
E : Enterprise,
F: Female,
M: Male,
U: Unknown
Category: Category of the purchase. I won't write all categories here, we'll see
them later in the analysis.
Amount: Amount of the purchase
Fraud: Target variable which shows if the transaction fraudulent(1) or benign(0)
PANDAS:
Pandas are an open source, BSD- licensed library providing high –performance, easy-
to-use data structures and data analysis tools for the python programming language.
PIP:
PIP is a package management system used to install and manage software packages
written in Python. Many Packages can be found in the default source for packages and their
dependencies –Python package index (PyPi) pip is a recursive acronym that can stand for
either “Pip installs Packages “ or “Pip installs Python”.
import numpy as np
Numpy is the core library for scientific computing in python. It provides a high –
performance multidimensional array object, and tools for working with these arrays. If you
are already familiar with MATLAB, you might find the tutorial useful to get started with
Numpy.
from the minority class. Undersampling is reducing the number of instances in the majority
class by selecting random points from it to where it is equal with the minority class by
selecting. Random points from it to where it is equal with the minority class. Both operations
have some risks. Oversample will create copies or similar data points which sometimes
would not be helpful for the case of fraud detection sometimes would not be helpful for the
case of fraud detection because fraudulent transactions may vary. Undersampling means that
we lost data points thus information, we will perform an oversampled technique called
SMOTE. SMOTE will create new data points from minority class using the neighbor
instances so generate samples are not exact copies but they are similar to instances we have.
from [Link]-selection import train-test-split
It splits array or matrices into random train and test subset. The training set contains a
known output and the model learns on this data in order to be generalized to other data later
on. We have the test dataset (or subset) in order to test our model prediction on the subset.
from [Link] import confusion-matrix, classification-report
To compute confusion matrix to evaluate the accuracy of a classification. By
definition confusion matrix c is such that Cij, is equal to the number of observations known
to be in group, but predicted to be in group j. Thus in binary classification, the count of true
negative is C00. False negatives is C10, true positives is C1,1 and false positives I C0,1.
Accuracy is a ratio of correctly predicted observation to the total observation. Accuracy is the
most intuitive performance measure.
True Positive: The number of correct predictions that the occurrence is positive.
True Negative: The number of correct predictions that the occurrence is negative.
F1-Score is the weighted average of precision and recall. Therefore, this score takes both
false Negatives into account.F1-score is usually more useful than accuracy, especially if we
have an uneven class distribution.
Precision: when a positive value is predicted how often the prediction is correct.
Recall: when the actual value is positive, how often is the prediction correct?
Support: It is the number of actual occurrence of the class in the specified dataset.
Random Forest:
Random Forest is a meta- estimator that fits a number of decision tree on various sub-
samples of dataset and use average to improve the predictive accuracy of the model and
controls over- fitting. The sub sample size is always the same as the original input sample
size but the samples are drawn with replacement.
Advantages: Reduction is over fitting and random forest classifier is more accurate than
decision trees are most cases.
Disadvantages: Slow real time predictions, difficult to implement and complex algorithm.
Logistic Regression:
It is a machine learning algorithm for classification in this algorithm, the probabilities
describing the possible outcomes of a logistic function.
Advantages: Logistic Regression is designed for these classifications and is most useful for
understanding the influence of several independent variables on a single outcome variable.
Disadvantages: works only when the predicted variable is binary, assumes all predictors are
independent of each other and assumes data is free of missing values.
Naïve Bayes:
Naïve Bayes algorithm is based on Bayes theorem with the assumption of
independence between every pair of features. Naïve Bayes classifiers work well in many real-
world situations such as document classifications and spam filtering.
Advantages: This algorithm requires a small amount of training data to estimate the necessary
parameters. Naïve Bayes classifiers are extremely fast compared to more sophisticated
methods.
Stochastic Gradient Descent:
Stochastic Gradient Descent is a simple and very efficient approach to fit linear
models. It is particularly useful when the number of samples is very large. It supports
different loss functions and penalties for classification.
Advantages: Efficiency and ease of implementation.
Disadvantages: Requires a number of hyper- parameter and it is sensitive to feature scaling.
Decision Tree:
Given a data of attributes together with its classes, a decision tree produces a
sequence of rules that can be used to classify the data.
Advantage: Decision tree is simple to understand and visualize, require little data preparation
and can handle both numerical and categorical data.
Disadvantage: Decision tree can create complex trees that do not generalize well, and
decision trees can be unstable because small variations in the data might result in a
completely different tree being generated.
CHAPTER-4
EXPERIMENTS AND
RESULTS
4.1 EXPERIMENTS:
Fraudulent behavior can be seen across many different fields such as e-commerce,
healthcare, payment and banking systems. Fraud is a billion-dollar business and it is
increasing every year. The PwC global economic crime survey of 2018 [1] found that half (49
percent) of the 7,200 companies they surveyed had experienced fraud of some kind. Rules are
great for detecting some type of frauds but they can fire a lot of false positives or false
negatives in some cases because they have predefined threshold values. For example let's
think of a rule for denying a transaction which has an amount that is bigger than 10000
dollars for a specific user. If this user is an experienced fraudster, he/she may be aware of the
fact that the system would have a threshold and he/she can just make a transaction just below
the threshold value (9999 dollars).For these types of problems ML comes for help and
reduces the risk of frauds and the risk of business to lose money. With the combination of
rules and machine learning, detection of the fraud would be more precise and confident.
Python version 3 is widely used to implement the Bank fraud detection. Python is
widely used high-level, general purpose, interpreted programming language. Its design
philosophy emphasizes code reliability and its syntax allows programmers to express
concepts in fewer lines of codes than possible in language such as c++ or java. The language
provides constructs intended to clear programs on both small and large scale. Python support
multiple programming paradigms, including object oriented, imperative and functional
programming or procedural styles. It features a dynamic type system and automatic memory
management and has a large and comprehensive standard library. Python interpreter are
available for many operating systems. Using third party tools such as Pyintaller.
Undersampling means that we lost data points thus information. We will perform an
oversampled technique called SMOTE (Synthetic Minority Over-sampling Technique).
SMOTE will create new data points from minority class using the neighbor instances so
generated samples are not exact copies but they are similar to instances we have. Resulted
counts show that now we have exact number of class instances (1 and 0).
Then Pre- process the data and prepare for training. Then in the next module we use
prediction algorithms for predicting the fraudulent value. Then we used Machine Learning
Programming classifiers to do the accuracy of frauds. We used different kind of algorithms
such as K-NN, Random forest classification, Decision tree ,XGBoost classifier, Linear
Regression ,Stochastic gradient descent, Naïve Bayes to do the accuracy of the fraud. Then
we compute the confusion matrix to evaluate the accuracy of classification. A ROC curve is
created by plotting the true positive rate (TPR) against the false positive rate at various
threshold settings. The true positive rate is also known as sensitivity, recall or probability of
detection machine learning. The false-positive rate is also known as the fall-out or probability
of false alarm and can be calculated as we can also be thought of as a plot of the power as a
function of the type error of the decision rule. ROC analysis provides tools to select possibly
optimal models and to discard suboptimal ones independently from the cost context or the
class distribution. ROC analysis is related in a direct and natural way to cost /benefit analysis
of diagnostic decision making. Then at last visualization and also combined representation of
the fraud detail also done. I presented the classification report visualize displays the
Comparision of Accuracy of classification, precision, recall, F1 and support scores,
Combined graphical representation of Confusion Matrix for the model. In order to support
easier interpretation and problem detection.
BankSim dataset
We detect the fraudulent transactions from the BankSim dataset. This synthetically generated
dataset consists of payments from various customers made in different time periods and with
different amounts. In this part we will perform an Explaratory Data Analysis on the data and
try to gain some insight from it.
Again we can see in the histogram below the fraudulent transactions are less in count but
more in amount.
Our hypothesis for fraudsters choosing the categories which people spend more is
only partly correct, but as we can see in the table below we can say confidently say that a
fraudulent transaction will be much more (about four times or more) than average for that
category. Average amount spend it categories are similar; between 0-500 discarding the
outliers, except for the travel category which goes very high.
K-Neighbours Classifier
EXPLANATION:-
Step1: The first step is to import the K-Neighbors classifier class from the
[Link] library.
Step2: This class is initialized with one parameter n-neighbors. This is basically value for
the k.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our K-Neighbors classifier algorithm was able to classify
the test set with 0.98 accuracy in the particular BankSim dataset.
EXPLANATION:-
Step1: The first step is to import the Random Forest classifier class from the sklearn.
Ensemble library.
Step2: This class is initialized with n_ estimator=100, max_ depth=8, random_ state=42,
verbose = 1, class_ weight= ”balanced”.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our Random Forest classifier algorithm was able to classify
the test set with 0.98 accuracy in the particular BankSim dataset.
XGBoost Classifier
EXPLANATION:-
Step1: The first step is to import the XGBClassifier class from the xgBoost. Sklearn.
Step2: This class is initialized with n_ estimator=400, max_ depth=6, random_ state=42,
class_ weight=”balanced”.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our XGBClassifier algorithm was able to classify the test set
with 0.99 accuracy in the particular BankSim dataset.
Logistic Regression
EXPLANATION:-
Step1: The first step is to import the Logistic Regression Classifier class from the
Sklearn. Linear_ model.
Step2: This class is initialized with default parameters.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our Logistic Regression Classifier algorithm was able to
classify the test set with 0.91 accuracy in the particular BankSim dataset.
Naïve Bayes
EXPLANATION:-
Step1: The first step is to import the GaussianNBClassifier class from the Sklearn.
Naïve. Bayes.
Step2: This class is initialized with default parameters such as priors=none, var_
smoothing=1e.09.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our GaussianNBClassifier algorithm was able to classify the
test set with 0.89 accuracy in the particular BankSim dataset.
EXPLANATION:-
Step1: The first step is to import the SGDClassifier class from the Sklearn. Linear_
model.
Step2: This class is initialized with parameters such as loss=’modified_ huber’, ’shuffle=
true, random_ state=101.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our SGDClassifier algorithm was able to classify the test set
with 0.74 accuracy in the particular BankSim dataset.
Decision Tree
EXPLANATION:-
Step1: The first step is to import the DecissionTreeClassifier class from the Sklearn. tree.
Step2: This class is initialized with parameters such as max_ depth=p, random_
state=101, max_ features=None, min_ samples_ leaf=15.
Step3: we used to fit the model and make prediction on our test data.
Step4: Evaluating the algorithm, confusion matrix, precision, recall and f1 score are the
most commonly used metrices. The confusion_ matrix and classification_ report methods
of the [Link] can be used to calculate these metrices.
Step5: The result shows that our DecissionTreeClassifier algorithm was able to classify
the test set with 0.99 accuracy in the particular BankSim dataset.
CHAPTER-5 CONCLUSION
AND FUTURE WORKS
5.1 CONCLUSIONS-
Fraud detection on Bank Payment is a simulation of bank payments with the objective
to generate a synthetic transactional dataset that can be used for research into fraud detection.
The datasets generated with BankSim can aid academia, financial organizations and
governmental agencies to test their fraud detection methods or to compare the performance of
different methods under similar conditions using a common public available and standard
synthetic dataset for the test.
I presented the model for Fraud detection on Bank Payment, Which is based on the
ODD methodology. In order to better support our claim and answer our research question we
analyzed the type of data needed to generate and output as a CSV file and we evaluated and
verified our model.
In this Project I had tried to do fraud detection on a bank payment data and I have
achieved remarkable results with our classifiers. Since fraud datasets have an imbalance class
problem I had performed an oversampling technique called SMOTE and generated new
minority class.
We can argue that BankSim is ready to be used as a generator of synthetic data sets of
financial activity of a payment. Data sets generated by BankSim are used to implement fraud
detection scenarios and malicious behavior scenarios such as stolen or cloned credit cards or
unusual simultaneous activity of purchase in different physical locations.
For the future we plan several improvements of and additions to the current model.
Fraud detection on Bank Payment can be calibrated to improve the results presented and
increase the granularity and the coverage of codes that enrich the synthetic data set and make
it even more valuable as a realistic data set for fraud detection.
REFERENCES
1. P.J. Lin, B. Samadi, and Alan Cipolone. Development of a synthetic data set
generator for building and testing information discovery systems. In ITNG 2006.
Pages 707--712. IEEE, 2006. ISBN 0769524974.
2. Edgar Alonso Lopez-Rojas and Stefan Axelsson. Money Laundering Detection using
Synthetic Data. The 27th workshop of Swedish Artificial Intelligence Society (SAIS),
pages 33--40, 2012a.
3. Edgar Alonso Lopez-Rojas and Stefan Axelsson. Multi Agent Based Simulation
(MABS) of Financial Transactions for Anti Money Laundering (AML). The 17th
Nordic Conference on Secure IT Systems, pages 25-- 32, 2012b.
4. Edgar Alonso Lopez-Rojas, Stefan Axelsson, and Dan Gorton. RetSim: A Shoe Store
Agent-Based Simulation for Fraud Detection. The 25th European Modeling and
Simulation Symposium, 2013.
6. Lavion, Didier; et al. "PwC's Global Economic Crime and Fraud Survey 2018" (PDF).
[Link]. Retrieved 28 August 2018.
7. R.J. Bolton and D.J. Hand. Statistical fraud detection: A review. Statistical Science,
17(3):235--249, 2002.
9. Clifton Phua, Vincent Lee, Kate Smith, and Ross Gayler. A comprehensive survey of
data mining-based fraud detection research. Arxiv preprint arXiv: 1009.6119, 2010.
10. SJ Alam and Armando Geller. Networks in agent-based social simulation. Agent-
based models of geographical systems, pages 77--79, 2012.
11. Edgar Alonso Lopez-Rojas, Stefan Axelsson, and Dan Gorton. RetSim: A Shoe Store
Agent-Based Simulation for Fraud Detection. The 25th European Modeling and
Simulation Symposium, 2013.
12. [Link]
13. [Link]
14. [Link]
15. [Link]
221653343_Outlier_detection_by_active_learning.
16. [Link]
17. [Link]
Generator-for-Lin-Samadi/144a9a4cefdf4f382a82693d51484ad85da3ac6.1
18. [Link]
19. [Link]
validation-in-python-r/.
20. [Link]
21. [Link]
fraud-detection-research/.