Develop Online Payments Fraud Detection system using Artificial Intelligence
Every year, billions of Rupees are lost due to online fraud, causing huge losses for users and the financial industry. This kind of illicit activity is perhaps the most common and the one that causes most concerns in the finance world. In recent years great attention has been paid to the search for techniques to avoid this significant loss of money. In this project, we will build an application named as “Online Payments Fraud Detection system using Artificial Intelligence” by using an imbalanced dataset that contains transactions. Application the Online Payments Fraud Detection system about to detect fraud while customer pay online for shopping. It specifically is very risky to basically kind of buy item and literally really pay online there definitely for all intents and purposes so we will build this application to detect fraud in advance. In this application we use machine learning techniques for detection of fraud customer in a subtle way.
Table of Content:
-
Introduction
-
Aim and Objective
-
Install and Import
-
Dataset
-
Data Analysis
-
Pre-processing
- Pycaret
- Model Selection
- Model Training
- Model Saving
- Development
- app.py
- Procfile
- stepup.sh
Introduction :
In modern day’s Online Transaction plays an important role in every person’s daily activity. Customer purchases their needs with their online transitions. Banks and financial institutes consider denying the applications of customers to avoid the risk of defaulters. Risk is the rise of debt on the customer who fails to make the billing payment for some period. The purpose of the project is how to reduce the defaulters among the list of customers, and make a background check on whether to provide the loan or not and to find the promising customers. These predictive models would benefit the lending institutions and to the customers as it would make them more aware of their potential defaulting rate. The dataset is unbalanced so the focus was on the precision and recall more than the accuracy metrics. After comparison with 13 models and random forest is the best model based on the False Negative value of confusion metrics.
Aim and Objective:
The problem is to classify the defaulters and non-defaulters on the credit payment of the customers. This project is helpful for solving the real problem by using various classification techniques. Moreover, any user can access GUI and add their gender, education, marital status and payment details to check next month in which category they fall (defaulter or non-defaulter). The core objectives: Find whether the customer could pay back his next credit amount or not and Identify some potential customers for the bank who can settle their credit balance. The steps followed to manage these goals:
- Selection of dataset
- Display some graphical information and visualize the features.
- Check Null values in the dataset
- Data pre-processing using one-hot encoding and remove extra parameters
- Train with classifiers
- Evaluate the model with test data
- Compare the accuracy, precision and recall finding the optimal model.
- Created a Graphical User Interface to check with real time customer data and predict defaulter for their next month payment
Install & Import :
Code:
Dataset:
This dataset is presently only one of four on Kaggle with information on the rising risk of digital financial fraud, emphasizing the difficulty in obtaining such data. The main technical challenge it poses to predicting fraud is the highly imbalanced distribution between positive and negative classes in 6 million rows of data. Another stumbling block to the utility of this data stems from the possible discrepancies in its description [1], [2], [3]. The goal of this analysis is to solve both these issues by a detailed data exploration and cleaning followed by choosing a suitable machine-learning algorithm to deal with the skew. I show that an optimal solution based on feature-engineering and extreme gradient-boosted decision trees yields an enhanced predictive power of 0.997, as measured by the area under the precision-recall curve. Crucially, these results were obtained without artificial balancing of the data making this approach suitable to real-world applications
You can downlaod the dataset form Click here


Data Analysis:
print("Number of records:\t\t",data.shape[0])


- The first step is data preprocessing. Data preprocessing used to convert the raw data into a clean data set.
- ID column dropped as its unnecessary for our modeling.
- Numeric attributes converted to nominal.
- One hot encoding which is a process by which categorical variables converted into a dummy form that provided to algorithms to do a better job in prediction. One hot encoder used to perform linearization of data.
- For change of categorical data into numeric form we use factorize function form pandas
- 1 for CASH_OUT
- 2 for CASH_IN
- 3 for PAYMENT
- 4 for TRANSFER
- 0 for DEBIT




Pycaret:
- For Normalization with z score we use built in funcition from pycaret
- For Feature Seleciton we use built in funcition from pycaret
- In pycaret the be defalut training size is * 0.7 * left dataset is for testing

Model Selection:


Model Training:

Performance Metric:

Confusion Matrix:


Saving Model:
fDevelopment:
app.py
Procfile:
Make a text file with name Procfile and write this code in it
web: sh setup.sh && streamlit run app.py
Setup.sh
also make this file add this code
mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml
After this all the data upload on github and it connect with Heroku you code will deploy on could



