Financial fraud detection is a high-impact machine learning problem due to severe class imbalance and business risk trade-offs.
This project analyzes 284,000+ transaction records to build and evaluate fraud detection models while prioritizing precision–recall performance over raw accuracy.
The objective is to detect fraudulent transactions effectively while minimizing false positives that increase investigation costs.
- Source: Credit Card Fraud Detection Dataset (ULB)
- Transactions: 284,807
- Fraud Cases: 492 (~0.17%)
- Features:
- V1–V28 (PCA-transformed features)
- Time
- Amount
- Class (Target variable: 1 = Fraud, 0 = Legitimate)
Dataset not included in repository due to size.
- Extreme class imbalance
- Fraud cases represent less than 1% of data
- Accuracy is not a reliable metric
- Business cost of false negatives vs false positives
- Stratified train-test split
- Feature scaling for
TimeandAmount - Class imbalance handling using class weights
- Used
class_weight="balanced" - Evaluated using:
- Precision
- Recall
- ROC-AUC
- PR-AUC
Logistic regression provided a strong baseline with interpretable decision boundaries.
- Implemented ensemble learning
- Handled non-linear relationships
- Extracted feature importance
- Performed threshold tuning for recall optimization
Random Forest demonstrated improved precision-recall balance compared to the baseline model.
Models were evaluated using:
- ROC Curve
- Precision-Recall Curve
- Confusion Matrix
- ROC-AUC Score
- PR-AUC Score
Given the severe imbalance, PR-AUC was prioritized over accuracy.
In fraud detection systems:
- False Negatives (missed fraud) lead to financial loss.
- False Positives increase operational investigation costs.
By adjusting probability thresholds, the system can be tuned depending on business risk appetite.
The Random Forest model offered better recall-precision balance, making it suitable for high-risk transaction environments.
- Python
- Pandas & NumPy
- Scikit-learn
- Matplotlib & Seaborn
- Jupyter Notebook
This project demonstrates:
- Handling extreme class imbalance
- Building and comparing classification models
- Evaluating models using precision-recall metrics
- Applying threshold tuning
- Framing machine learning results in business context