The Credit Card Fraud Detection project is an end-to-end Machine Learning pipeline designed to identify fraudulent credit card transactions. Credit card fraud is a massive problem in the Fintech, Banking, and Payments industries (e.g., Paytm, PhonePe, Razorpay). This project tackles the inherent high-stakes class imbalance problem, where fraudulent transactions are extremely rare compared to normal transactions.
As digital transactions grow, so do sophisticated fraudulent activities. This project provides a foundational blueprint for:
StandardScaler), and Evaluation Metrics.SMOTE for oversampling, RandomUnderSampler).nbformat, nbconvert): For interactive data analysis, EDA, and Predictive Analysis.download_data.py: An automated script to fetch the raw dataset securely from GitHub.main.py: The core pipeline script that handles data loading, preprocessing, model training, and saves evaluation visualizations to the output/ folder.create_notebook.py: A script that generates the Jupyter Notebook programmatically.Analysis.ipynb: A comprehensive, fully executed notebook that contains Descriptive Analysis, Interactive EDA, Data Preprocessing, and Predictive Analysis step-by-step.requirements.txt: List of all Python dependencies.output/: Directory where all generated plots (EDA & Evaluation Curves) are saved.Make sure you have Python 3.8+ installed.
Clone or download the repository, then install the required packages:
pip install -r requirements.txt
Run the data acquisition script to fetch the creditcard.csv dataset.
python download_data.py
The dataset will be downloaded into a dynamically created
data/folder.
Execute the full, end-to-end training and evaluation script:
python main.py
You will see precision, recall, and F1-score outputs in the terminal. ROC-AUC curves, Precision-Recall curves, and Feature Importance plots will be saved in the
output/directory.
To view the detailed Descriptive Analysis, Exploratory Data Analysis (EDA), and Predictive Modeling interactively:
Analysis.ipynb in VS Code, JupyterLab, or your preferred IDE to view the executed results.python create_notebook.py and execute the cells.We trained and evaluated three distinct approaches to handling fraud:
class_weight='balanced' within the ensemble to penalize misclassifications of the minority class heavily.In fraud detection, standard “Accuracy” is misleading because 99.8% of transactions are normal. Instead, we focus on: