Machine Learning: Online Payments Fraud Detection.
Online payment systems have made ease for humans to make transactions. But at the same time, there are so many frauds that are happening around, especially on the credit card. That is why Online payment fraud detection is important, especially to products and services that customers have never buyed for. Let's get into the step-by-step procedure for the task of online payment fraud detection with machine learning with Python.
To identify online payment fraud with machine learning we need to train the machine learning model for classifying fraudulent and non-fraudulent payments. for this, we need a dataset containing information about online payment fraud, so that we can understand what type of transactions lead to fraud.
Steps:
The first step is we need to import the libraries that will be needed to load the dataset and do the analysis part.

Then we need to import the dataset through the pandas library and then display the library.
By the dataset, we can see that different categories has been divided.
step: represents a unit of time where 1 step equals 1-hour.
type: type of online transaction.
amount: the amount of the transaction.
nameOrig: customer starting the transaction.
oldbalanceOrg: balance before the transaction.
newbalanceOrig: balance after the transaction.
nameDest: recipient of the transaction.
oldbalanceDest: initial balance of the recipient before the transaction.
newbalanceDest: the new balance of the recipient after the transaction.
isFraud: fraud transaction.

Check the dataset whether there are any null values present in the dataset or not. and sum it up to see the results.

value_counts will give you the unique values from the original Series as the index and the count of each unique value as the corresponding values.
By the value counts you can see that there are sub-divisions that are
Cash_out, Payment, Cash_in, Transfer and debit.

Through the values count, the dataset it into a different form which is transaction and quantity.

Plotting it through the library which is plotly. express

Now, checking the correlation and then doing the sort_values which gives the isFraud total amount.

Now, using the map command to divide the variety of different categories.

importing the train_test_split for dividing the dataset into the two forms

Now, dividing the total dataset into 2 categories x and y.

Now, with the help of train_test_split getting the X_train, x_test, y_train_y_test.

Finally, the most important part is to make the model using an Algorithm here we are using the algorithm DecisionTreeClassifier.
Then fitting the model with the X_train and y_train.

Getting the score of the model through the model.score

Now, we are doing the prediction of the new features. giving the new features and and model will predict it with the new features.

Thanks for reading,
Mohammed MuqafamUddin
Comments
Join the discussionNo comments yet. Be the first to comment.