Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💳 Credit Card Fraud Detection — ML Experiment Tracker

An end-to-end machine learning project for detecting fraudulent credit card transactions while tracking and comparing model experiments in a structured, reproducible workflow.

The project focuses on one of the major challenges in fraud detection: extreme class imbalance, where fraudulent transactions represent only a very small portion of the dataset.


🎯 Project Objective

Accuracy alone can be misleading when working with highly imbalanced datasets.

A model that predicts every transaction as legitimate could achieve very high accuracy while detecting zero fraudulent transactions.

This project therefore focuses on metrics such as:

  • Precision
  • Recall
  • F1-score
  • ROC-AUC

with particular attention to the trade-off between detecting fraudulent transactions and generating false positives.


📊 Dataset

The project uses the Kaggle Credit Card Fraud Detection Dataset.

  • 284,807 transactions
  • Fraudulent transactions represent approximately 0.17% of the dataset
  • Highly imbalanced binary classification problem

The target variable identifies transactions as either:

0 → Legitimate transaction
1 → Fraudulent transaction

🧠 Models

Two classification approaches are compared:

Logistic Regression

A class-weighted Logistic Regression model provides a strong and interpretable baseline for the classification task.

Random Forest

A class-weighted Random Forest model is used to capture more complex relationships between features.

Using class weighting helps the models account for the large difference between legitimate and fraudulent transaction frequencies.


🔬 Experiment Workflow

Dataset
   ↓
Data Preparation
   ↓
Train/Test Split
   ↓
Class-Weighted Training
   ↓
Logistic Regression ──┐
                      ├──→ Evaluation
Random Forest ─────────┘
                            ↓
                    Experiment Results
                            ↓
                     Model Comparison
                            ↓
                    Visualization

The workflow is designed to make experiments easier to reproduce and compare.


📈 Evaluation Metrics

Because of the severe class imbalance, model performance is evaluated using several metrics rather than accuracy alone.

Metric Purpose
Precision Measures how many predicted fraud cases were actually fraudulent
Recall Measures how many actual fraud cases were detected
F1-score Balances precision and recall
ROC-AUC Evaluates ranking performance across classification thresholds

📁 Project Structure

ml-experiment-tracker/
│
├── src/
│   ├── train.py
│   └── plots.py
│
├── results/
│   └── plots/
│
├── requirements.txt
├── .gitignore
└── README.md

train.py handles model training and evaluation, while plots.py generates visual comparisons of experiment results.

Generated visualizations are stored under results/plots/.


🚀 Running the Project

1. Clone the repository

git clone https://github.com/hritika20002/ml-experiment-tracker.git
cd ml-experiment-tracker

2. Install dependencies

pip install -r requirements.txt

3. Run model training

python src/train.py

4. Generate visualizations

python src/plots.py

💡 What I Learned

This project helped me develop practical experience with:

  • Building reproducible machine learning workflows
  • Working with highly imbalanced datasets
  • Comparing multiple classification algorithms
  • Applying class weighting during model training
  • Evaluating models beyond simple accuracy
  • Understanding precision–recall trade-offs
  • Structuring ML experiments and results
  • Creating model-performance visualizations

🛠️ Tech Stack

Language: Python

Data: Pandas · NumPy

Machine Learning: scikit-learn

Models: Logistic Regression · Random Forest

Evaluation: Precision · Recall · F1-score · ROC-AUC


👩‍💻 Author

Hritika Sharma

Computer Science Graduate · AI & Data Developer

Portfolio · LinkedIn

About

End-to-end credit card fraud detection pipeline for tracking ML experiments, comparing models, and evaluating performance on highly imbalanced data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages