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.
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.
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
Two classification approaches are compared:
A class-weighted Logistic Regression model provides a strong and interpretable baseline for the classification task.
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.
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.
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 |
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/.
git clone https://github.com/hritika20002/ml-experiment-tracker.git
cd ml-experiment-trackerpip install -r requirements.txtpython src/train.pypython src/plots.pyThis 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
Language: Python
Data: Pandas · NumPy
Machine Learning: scikit-learn
Models: Logistic Regression · Random Forest
Evaluation: Precision · Recall · F1-score · ROC-AUC
Hritika Sharma
Computer Science Graduate · AI & Data Developer