Credit Card Fraud Detection App built with Streamlit, FastAPI, and Docker

Language Framework Framework Framework hosted Docker build reposize

An end-to-end Machine Learning Project

Problem Statement

Credit card fraud is an inclusive term for fraud committed using a payment card, such as a credit card or debit card. The purpose may be to obtain goods or services or to make payment to another account, which is controlled by a criminal.

This Streamlit App utilizes a Machine Learning model served as an API with FastAPI framework in order to detect fraudulent credit card transactions based on the following criteria: hours, type of transaction, amount, balance before and after transaction, etc.

The machine learning model used for this web application was deployed as an API using the FastAPI framework and then accessed through a frontend interface with Streamlit.

Data Preparation

Publicly accessible datasets on financial services are scarce, particularly in the newly growing field of mobile money transfers. Many scholars, like us who conduct research in the field of fraud detection, value financial datasets. Because financial transactions are inherently private, there are no publicly accessible datasets, which contributes to the problem.

A synthetic dataset generated using the simulator called PaySim was used as the dataset for building the model used in this project. PaySim uses aggregated data from the private dataset to generate a synthetic dataset that resembles the normal operation of transactions and injects malicious behavior to later evaluate the performance of fraud detection methods.

Dataset Link

Modelling

In this project, 2 different classification algorithms were tested namely:

  • Logistic Regression
  • Random Forest

The final model used for the API was the Random Forest Classifier model which had an accuracy score of 0.99 and an F1 score of 0.86.

Preview

Streamlit App Demo

streamlit-streamlit_app-2024-07-19-03-07-80.webm

How to run API and Streamlit App on Google Colab:

💻 Running the API on Google Colab

To run a demo or carry out testing with the API it's best to do that with Google Colab. To run/test the API on Google Colab do the following:

  1. Clone the repository to your Google Colab Instance.