Skip to content

Nishu1717/Finance-Risk-Fraud-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Credit Card Fraud Detection: A Cost-Benefit Optimization Approach

Author: Nisarg Patel
Date: 3rd January 2026

📌 Executive Summary

This project tackles the critical financial challenge of credit card fraud detection using advanced machine learning techniques (XGBoost) and Explainable AI (SHAP). Applied to a dataset of 1,000,000+ real-world credit card transactions, this solution implements a business-centric Cost-Benefit Analysis to optimize decision thresholds, achieving 96% fraud recall and an estimated $917,000 reduction in total business cost compared to a default classifier.

🏢 The Business Problem

Credit card fraud results in billions of dollars in losses annually. Financial institutions face two competing risks:

  1. Fraud Loss: Direct financial loss from unauthorized transactions (False Negatives).
  2. Customer Friction (False Positives): Blocking legitimate transactions leads to lost revenue (interchange fees) and customer churn.

A model optimized solely for technical accuracy may fail to maximize profitability — especially at a fraud prevalence of only ~0.57%, where accuracy is a misleading metric. The business requires a solution that continuously balances these costs to find the optimal operating point.

🚀 The Solution

We developed a comprehensive data pipeline and predictive model:

  • Data Preprocessing: Handling severe class imbalance (0.57% fraud rate) and extensive feature engineering (13 engineered features including velocity checks, time-based patterns, behavioral profiling).
  • Modeling: Training an XGBoost Classifier optimized for Area Under the Precision-Recall Curve (AUPRC) — the correct metric for highly imbalanced fraud data.
  • Explainability: Utilizing SHAP (SHapley Additive exPlanations) to provide transparency for every fraud prediction, enabling compliance and trust.
  • Optimization: Implementing a custom Threshold Optimization Strategy based on the financial weight of False Negatives vs. False Positives, sweeping thresholds to identify the minimum-cost operating point.

📊 Key Results

  • Fraud Detection: Achieved 96% recall on the fraud class, ensuring the vast majority of fraudulent transactions are flagged before losses occur.
  • Financial Impact: The cost-sensitive threshold of 0.54 reduced total projected business costs by an estimated $917,000 compared to default classification.
  • Key Determinants: SHAP analysis identified transaction velocity and time-based behavioral features as the primary drivers of fraud predictions across 13 engineered features.

🛠️ Tech Stack

  • Python: Core logic and analysis.
  • Pandas & NumPy: Data manipulation and vectorization.
  • XGBoost: Gradient boosted decision trees for high-performance classification.
  • SHAP: Model interpretability.
  • Matplotlib & Seaborn: Professional visualization.

📂 Repository Structure

📂 Repository Structure

/data             # For dataset
/notebooks        # Jupyter notebooks with full analysis and outputs
/visualizations   # High-resolution charts and model metric plots
/docs             # Project documentation including BRD

Dataset Information

The datasets used in this project (fraudTrain.csv and fraudTest.csv) are sourced from the Sparkov Data Generation project on Kaggle. Due to their large size, they are not hosted directly in this repository's main view but are required for the analysis.

Source

File Structure

  • fraudTrain.csv: Training data
  • fraudTest.csv: Testing data

Please download these files and place them in the data/ directory to run the notebook locally.

🚀 Getting Started

  1. Clone this repository.
  2. Install dependencies: pip install -r requirements.txt
  3. Download data (see Source section above)
  4. Run the notebook in /notebooks.

About

An end-to-end XGBoost fraud detection system optimized for financial cost-benefit analysis ($917k savings) using SHAP for model interpretability.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages