# Tunisian Fraud Detection — Zindi Competition
> **Leaderboard rank: #203** | Stacking ensemble of 5 models | Final RMSE: 6.73
## Overview
This project was built for the **Zindi Africa Tunisian Fraud Detection Challenge** — a regression competition to predict fraudulent transaction values from anonymised financial data.
The solution uses a **stacking ensemble** of five models combined via a Ridge meta-learner, with log-transformation applied to the target variable to handle severe skewness.
---
## Results
| Model | RMSE |
|---|---|
| LightGBM | 6.7819 |
| XGBoost | 6.7863 |
| CatBoost | 6.8481 |
| ExtraTrees | 8.1691 |
| **Stacked Ensemble (final)** | **6.7318** |
**Zindi leaderboard rank: #203**
---
## Approach
### Target Engineering
The fraud value target was heavily right-skewed. Applied `np.log1p` transformation before training and `np.expm1` to reverse predictions — this stabilised training and improved generalisation.
### Feature Engineering
- Row-level statistical features: sum, mean, standard deviation, and zero-count across all numerical columns
- Variance threshold filtering to remove low-information features
- Median imputation for missing values
### Modelling
- Trained 5 base models: LightGBM, XGBoost, CatBoost, ExtraTrees, Ridge
- Used **5-fold cross-validation** with early stopping on tree-based models
- Out-of-fold predictions from base models fed into a **Ridge meta-learner** as second-level features
- Final prediction is the meta-learner output inverse-transformed back to original scale
### Visualisations
- Target distribution before and after log-transformation
- Correlation heatmap of engineered features
- Feature importance ranking from LightGBM
---
## Tech Stack
| Category | Libraries |
|---|---|
| Data processing | pandas, NumPy, scikit-learn |
| Models | LightGBM, XGBoost, CatBoost, scikit-learn (ExtraTrees, Ridge) |
| Visualisation | Matplotlib, Seaborn |
| Environment | Google Colab |
---
## How to Run
1. Open the `.py` f …