2024Securing Finances

Fraud Detection

A fraud detection model trained on real e-commerce transactions from Vesta Corporation that hit 91% ROC-AUC, mostly thanks to careful feature engineering.

E-commerce sites process millions of transactions a day, and fraud detection has to catch the bad ones without annoying real customers. The tricky part is keeping false positives low, where a legitimate purchase gets flagged, while still catching actual fraud.

I used Vesta's dataset from the IEEE-CIS Fraud Detection competition, merging transaction and identity data into 400+ features. From there it was preprocessing, PCA to shrink the feature space, and gradient boosting models that can cope with heavily imbalanced data.

01

Data Integration & Preprocessing

Joined the transaction and identity tables on TransactionID. Filled missing values with clear placeholders (-999 for numbers, '-999' for categories), dropped TransactionAmt outliers more than 3σ out, downcast numeric columns to save memory, and label-encoded the categoricals.

02

Feature Engineering & Dimensionality Reduction

Engineered 15+ features from email domain suffixes, operating systems, browsers, and device details. PCA squeezed the 339 V-columns down to 9 principal components while keeping 90% of the variance, and day-of-week and hour-of-day features helped catch timing patterns.

03

Model Development & Validation

Trained XGBoost and LightGBM with stratified cross-validation and tuned the learning rate (0.05), max depth (6), and early stopping (10 rounds). With classes this imbalanced, I looked at AUC-ROC, precision, recall, and F1 instead of plain accuracy. The final model hit 91% ROC-AUC with a solid precision-recall balance on validation.

Reached 91% ROC-AUC on the IEEE-CIS dataset, mostly from feature engineering like email domain extraction, device fingerprinting, and time-based patterns.

Built a preprocessing pipeline with PCA (keeping 90% of the variance), z-score outlier removal, and data type downcasting to keep memory in check.

Compared XGBoost and LightGBM with cross-validation and hyperparameter tuning, and both held up well on the heavily imbalanced data.

The hard part wasn't picking a model. Once the data was honest, feature engineering and handling class imbalance mattered way more than swapping XGBoost for LightGBM.