The problem
Credit card fraud is a needle-in-a-haystack problem: in the standard public dataset, only 492 of 284,807 transactions are fraudulent — 0.172%. A model that predicts "legitimate" every time scores 99.83% accuracy and catches nothing, which is exactly why this project is such a good teacher: it forces honest evaluation. This project trains an XGBoost fraud scorer on the Kaggle credit-card dataset, handles the imbalance with SMOTE on the training fold plus class weighting, evaluates with PR-AUC and recall-at-fixed-precision instead of accuracy, and derives a block/step-up/clear threshold policy from the validation fold. The web demo scores any entered transaction and explains the top risk signals — unusual amount, card-not-present channel, rapid repeats, distance from home. The methodology is documented for the viva, including why accuracy is banned from the report.
How it works
- The 284,807 transactions are loaded (V1–V28 PCA features, Time, Amount, Class); Amount is log-scaled and Time is converted to hours.
- Data is split with stratification and time-awareness: the test fold preserves the natural 0.172% fraud rate.
- SMOTE oversampling is applied to the training fold only, combined with XGBoost's scale_pos_weight.
- An XGBoost classifier (300 trees, max depth 6) is trained with stratified 5-fold cross-validation.
- The test fold is scored once: PR-AUC, ROC-AUC, and recall at 90/95% precision are computed — accuracy is reported only to demonstrate why it is meaningless here.
- Validation-fold analysis sets the policy thresholds: ≥0.80 auto-block, 0.50–0.80 step-up authentication, <0.50 clear.
- In the web demo, an entered transaction is featurized identically and the saved model returns the fraud probability with ranked risk-signal contributions.
Tech stack:
- Python 3, XGBoost, scikit-learn
- imbalanced-learn (SMOTE)
- Kaggle credit-card-fraud dataset
- pandas, NumPy, Matplotlib
- Jupyter Notebook (training)
- HTML/CSS/JavaScript (scorer demo)
Dataset & model details
- Dataset: Credit Card Fraud Detection (Kaggle) — 284,807 transactions from European cardholders over two days in September 2013, 492 frauds (0.172%). Features V1–V28 are PCA-anonymized; Time and Amount are given. Released by the ULB Machine Learning Group.
- Task: Binary classification; input = 30 features (V1–V28, time, log-amount), output = fraud probability.
- Model: XGBoost — 300 trees, max depth 6, learning rate 0.05, scale_pos_weight set from the imbalance ratio, SMOTE applied to the training fold.
- Metrics: PR-AUC ~0.97 (design target for the built-to-order training run), recall at 95% precision, ROC-AUC. Accuracy is deliberately excluded as a success metric. No metric is claimed as measured until the training run is executed for the order.
| Parameter | Value |
|---|---|
| Input format | 30 transaction features |
| Fraud rate | 0.172% (492 / 284,807) |
| Model | XGBoost, 300 trees, depth 6 |
| PR-AUC | ~0.97 (design target, not a measured claim) |
| Training time | Approximately 10–20 min on a laptop CPU (expected) |
| Inference | <5 ms per transaction on CPU (expected) |
| Policy | ≥0.80 block · 0.50–0.80 step-up · <0.50 clear |
| Demo | Web app with explained fraud scoring |
Project features
- [Imbalance-first methodology] SMOTE on the training fold only, class weighting, and stratified time-aware splits — the test fold keeps the natural 0.172% fraud rate.
- [Live fraud scorer demo] Enter amount, merchant, channel and context; get a fraud probability with the top contributing risk signals explained.
- [PR-curve evaluation] Precision-recall AUC as the primary metric, with recall reported at 95% precision — the operating language of real fraud teams.
- [Threshold policy] Block / step-up-auth / clear thresholds tuned on the validation fold and documented with their precision-recall tradeoffs.
- [XGBoost model] 300 gradient-boosted trees on the 28 PCA features plus time and log-amount, benchmarked against logistic regression.
- [Full training notebook] Preprocessing, SMOTE, model training, cross-validation and metric plots in one reproducible notebook.
- [Flagged-transaction view] The demo shows a realistic operations table of scored transactions with actions taken.
What is included
- Complete training & evaluation Jupyter notebook
- Trained XGBoost model file with preprocessing pipeline
- Fraud scorer web demo (score, explanations, operations table)
- PR/ROC curves, threshold analysis and calibration plots
- Project report PDF (background, imbalance theory, methodology, results)
- PPT presentation for final review
- Viva Q&A preparation document (SMOTE, PR-AUC vs accuracy, thresholds, PCA features)
Limitations & prerequisites
- ~0.97 PR-AUC is a design target for the training run, stated honestly — the report documents the actual achieved figure.
- V1–V28 are PCA-anonymized, so feature-level explanations use transaction context (amount, channel, velocity) rather than raw feature meanings.
- The data covers two days in 2013; real deployments face concept drift and need retraining pipelines, discussed in the report.
- The demo scores single transactions; production systems also use sequence and graph features, listed as future scope.
- Blocking thresholds trade fraud caught against customer friction — the report quantifies both sides.
Frequently Asked Questions
Which dataset is used?
The Kaggle Credit Card Fraud Detection dataset — 284,807 real (anonymized) European card transactions from September 2013, with 492 frauds (0.172%), released by the ULB Machine Learning Group.
Why is accuracy banned from this project?
At 0.172% fraud, a model predicting "legitimate" always scores 99.83% accuracy while catching zero fraud. The project evaluates on PR-AUC and recall at fixed precision — the metrics fraud teams actually use — and the report demonstrates the accuracy trap explicitly.
How is the imbalance handled?
Three layers: SMOTE oversampling applied to the training fold only (never the test fold), XGBoost class weighting, and stratified time-aware splits — so the test measurement stays honest.
How does the demo explain a score?
It ranks the transaction's risk signals — high amount vs profile, card-not-present channel, rapid repeat, distance from home — with each signal's contribution to the final probability, mirroring how analysts review alerts.
What do the block/step-up/clear thresholds mean?
Scores ≥0.80 auto-block, 0.50–0.80 trigger step-up authentication, below 0.50 clear. The thresholds come from the validation fold's precision-recall tradeoff, documented in the report.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It teaches the single most important lesson in applied ML (evaluate on the right metric) with a rigorous imbalance methodology and an explained demo. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.
Components & software requirements
- Python 3, XGBoost, scikit-learn
- imbalanced-learn (SMOTE)
- Kaggle credit-card-fraud dataset
- pandas, NumPy, Matplotlib
- Jupyter Notebook (training)
- HTML/CSS/JavaScript (scorer demo)
Dataset & model details
- Dataset: Credit Card Fraud Detection (Kaggle) — 284,807 transactions from European cardholders over two days in September 2013, 492 frauds (0.172%). Features V1–V28 are PCA-anonymized; Time and Amount are given. Released by the ULB Machine Learning Group.
- Task: Binary classification; input = 30 features (V1–V28, time, log-amount), output = fraud probability.
- Model: XGBoost — 300 trees, max depth 6, learning rate 0.05, scale_pos_weight set from the imbalance ratio, SMOTE applied to the training fold.
- Metrics: PR-AUC ~0.97 (design target for the built-to-order training run), recall at 95% precision, ROC-AUC. Accuracy is deliberately excluded as a success metric. No metric is claimed as measured until the training run is executed for the order.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.