Skip to content

This project uses unsupervised clustering via DBSCAN to detect fraudulent transactions without any prior labeling. By leveraging Z-score standardization, PCA for visualization, and cluster evaluation metrics, we create an effective and interpretable anomaly detection pipeline.

Notifications You must be signed in to change notification settings

ShubhamS2005/FraudAnomalyDetection

Repository files navigation

💳 Anomaly Detection in Financial Transactions

🧠 A Machine Learning Approach using DBSCAN Clustering & PCA Visualization


📌 Project Overview

This project identifies fraudulent transactions using unsupervised clustering with DBSCAN.
Without needing labeled data, it detects frauds based on density anomalies, and evaluates them against real labels.

Visual inspection using PCA and metrics like Silhouette Score and Confusion Matrix validate the model.


🧠 Key Features

  • 📈 DBSCAN Clustering (Unsupervised Anomaly Detection)
  • 🧮 Z-score Standardization for feature scaling
  • 🧠 PCA Visualization (2D) of fraud and normal clusters
  • 📊 Silhouette Score + Confusion Matrix + Classification Report
  • 💾 Saved Model & Scaler for deployment use

📁 Dataset Info

  • 📍 Source: Kaggle – Credit Card Fraud Detection
  • 📦 Total Records: 284,807
  • ⚠️ Class Distribution: 0 = Normal, 1 = Fraud (~0.17%)
  • Features: 28 anonymized (V1–V28) , Time and Amount


⚙️ Libraries & Tools Used

Category Tools & Libraries
Programming Python 3.8+
Data Handling pandas, numpy
ML Algorithms scikit-learn (DBSCAN, PCA, StandardScaler)
Evaluation sklearn.metrics
Visualization matplotlib, seaborn
Model Saving joblib

🧪 Evaluation Metrics

  • Silhouette Score: Measures cluster compactness and separation.
  • 📉 Confusion Matrix: Evaluates predictions vs actual frauds.
  • 📋 Classification Report: Includes precision, recall, and F1-score.

📍 High precision: Most predicted anomalies were actual frauds.
⚠️ Moderate recall: Common in unsupervised anomaly detection, as some frauds may not appear as clear outliers.


How to run this Project

Clone the repository

git clone https://github.com/ShubhamS2005/FraudAnomalyDetection.git
cd anomaly-detection-dbscan

(Optional) Create a virtual environment

python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

Install dependencies

pip install -r requirements.txt

Run the Jupyter Notebook

jupyter notebook anomaly_detection.ipynb

Author

Developed by Shubham Srivastava
If you use or adapt this work, please consider citing or giving credit.

License

This project is currently under development and does not have a formal license.
A suitable open-source license (e.g., MIT, Apache 2.0) will be added upon final release.

About

This project uses unsupervised clustering via DBSCAN to detect fraudulent transactions without any prior labeling. By leveraging Z-score standardization, PCA for visualization, and cluster evaluation metrics, we create an effective and interpretable anomaly detection pipeline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •