Skip to content

About

This repository contains a fraud-detection workflow built around the IEEE-CIS / Vesta e-commerce fraud dataset. It includes a model-training notebook, a Streamlit app for live prediction, the raw CSV inputs, and the saved model artifacts needed to run inference.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Fraud Detection System

This repository contains a fraud-detection workflow built around the IEEE-CIS / Vesta e-commerce fraud dataset. It includes a model-training notebook, a Streamlit app for live prediction, the raw CSV inputs, and the saved model artifacts needed to run inference.

Project Overview

The training pipeline uses a hybrid machine-learning approach:

  • Missing values are filled with -999.
  • Categorical features are label-encoded.
  • Features are scaled with StandardScaler.
  • KMeans is used as an additional engineered feature.
  • Class imbalance is handled with SMOTE.
  • Multiple models are trained and compared, including Logistic Regression, Decision Tree, Random Forest, Optuna-tuned XGBoost, and LightGBM.

The notebook evaluates models with F1 score, ROC-AUC, confusion matrix, and classification report, then saves the inference artifacts used by the app.

Files In This Folder

  • app.py - Streamlit web app for live fraud prediction.
  • Fraud-Detection.ipynb - End-to-end training and evaluation notebook.
  • transaction.csv - Main transaction dataset.
  • identity.csv - Identity metadata joined with the transaction data.
  • xgb_model.pkl - Saved XGBoost model used by the app.
  • lgbm_model.pkl - Saved LightGBM model used by the app.
  • scaler.pkl - Saved scaler used during preprocessing.
  • kmeans.pkl - Saved KMeans clustering model used as a hybrid feature.

What The App Does

The Streamlit app in app.py provides:

  • An introduction page describing the fraud-detection problem, dataset, and pipeline.
  • A live prediction demo where users enter transaction details and select either the XGBoost or LightGBM model.
  • A probability-based risk view with fraud probability, confidence, and a visual risk meter.

Requirements

Install the project dependencies from requirements.txt:

pip install -r requirements.txt

If you want to work with the notebook, also make sure Jupyter is installed:

pip install notebook ipykernel

How To Run

1. Set up a virtual environment

python -m venv .venv
.venv\\Scripts\\activate

2. Install dependencies

pip install -r requirements.txt

3. Launch the Streamlit app

streamlit run app.py

The app expects xgb_model.pkl, lgbm_model.pkl, scaler.pkl, and kmeans.pkl to be in the same folder as app.py.

4. Open the notebook

Run Fraud-Detection.ipynb in Jupyter or VS Code to inspect the full training pipeline, reproduce the model comparisons, and regenerate the saved artifacts if needed.

Data Notes

  • The dataset is highly imbalanced, with fraud representing a small fraction of transactions.
  • transaction.csv is large, so some editors may not preview it fully.
  • The app is designed for interactive demonstration, not for production risk scoring without further validation and monitoring.

Troubleshooting

  • If the app shows missing model-file errors, confirm the .pkl files are in the project root.
  • If package import errors appear, verify the virtual environment is activated and all dependencies are installed.
  • If the notebook fails on memory-heavy operations, reduce the dataset size for local experimentation or run it in an environment with more RAM.

About

This repository contains a fraud-detection workflow built around the IEEE-CIS / Vesta e-commerce fraud dataset. It includes a model-training notebook, a Streamlit app for live prediction, the raw CSV inputs, and the saved model artifacts needed to run inference.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages