The problem
Credit-card fraud is a textbook imbalanced problem: 492 frauds hide among 284,807 legitimate transactions, so a model that predicts "legitimate" every time scores 99.83% accuracy and catches nothing. Most student builds report that accuracy and stop. This project does the real work: an XGBoost classifier with class-weighted loss, tuned on area under the precision–recall curve, with the operating threshold chosen explicitly from the precision–recall trade-off — because every false positive blocks a genuine customer. The demo streams transactions, scores each in milliseconds, and breaks down the top contributing anonymized features (V14, V17, V12 — the same components fraud literature flags) for every decision. Built with standard tools (Python, XGBoost, scikit-learn), the full methodology is viva-ready.
How it works
- The ULB credit-card dataset (284,807 transactions, 30 features: Time, Amount, V1–V28 PCA components) is loaded with a stratified train/test split.
- Features are scaled; the extreme imbalance is handled with XGBoost class weights instead of naive oversampling.
- The model is trained with early stopping, tuned by cross-validated AUPRC — never by accuracy.
- The precision–recall curve on validation data sets the operating threshold: 0.91 recall at 0.94 precision is the design target.
- Held-out transactions are scored once: confusion matrix, PR curve and per-threshold tables go into the report.
- The web demo streams transactions through the saved model, rendering risk scores with feature-level evidence per decision.
Tech stack:
- Python 3, XGBoost
- scikit-learn (metrics, splits)
- NumPy, pandas, Matplotlib
- Jupyter Notebook (training & evaluation)
- HTML5 canvas + JavaScript (screening demo)
- ULB credit-card fraud dataset (Kaggle)
Dataset & model details
- Dataset: Kaggle "Credit Card Fraud Detection" (Machine Learning Group, ULB Brussels) — 284,807 transactions over 2 days in Sep 2013, 492 frauds (0.172%); features Time, Amount, V1–V28 (PCA-anonymized for confidentiality).
- Task: Binary classification under extreme imbalance; input = 30 features, output = fraud probability in [0, 1].
- Model: XGBoost binary classifier, max_depth 6, scale_pos_weight ≈ 577, early stopping; threshold selected from the validation precision–recall curve.
- Metrics: AUPRC, recall@precision, F1 — 0.91 recall / 0.94 precision is the design target for the built-to-order training run, stated honestly and never claimed as measured.
| Parameter | Value |
|---|---|
| Transactions | 284,807 (492 frauds, 0.172%) |
| Features | 30 (Time, Amount, V1–V28) |
| Recall (fraud) | 0.91 (design target, not a measured claim) |
| Precision | 0.94 (design target, not a measured claim) |
| Scoring latency | Approximately 9 ms per transaction on CPU (expected) |
| Demo | Single-file web app, runs offline after download |
Project features
- [Imbalance-aware XGBoost] Class-weighted gradient boosting (scale_pos_weight ≈ 577) so the 0.172% fraud minority is actually learned, not ignored.
- [AUPRC-tuned, not accuracy-tuned] Model selection on area under the precision–recall curve — the correct metric when the positive class is this rare.
- [Threshold from the PR curve] The operating point is chosen explicitly to trade fraud recall against false alarms, with the trade-off documented.
- [Live screening demo] A transaction stream scored in real time; click any transaction for its risk gauge and top contributing features.
- [Risk evidence per transaction] Each score decomposes into the driving V-components, amount and time signals — auditable, not a black box.
- [Fraud-pattern visualizations] PCA-space scatter and hour-of-day fraud distribution showing where frauds separate from legitimate traffic.
- [Retraining playbook] The report documents how to retrain on fresh labels as fraud patterns drift — the operational reality of this task.
What is included
- Complete training & evaluation Jupyter notebook (imbalance handling, PR tuning)
- Tuned XGBoost model file with inference code
- Live transaction-screening web demo with risk evidence
- Confusion matrix, PR-curve analysis and threshold tables
- Project report PDF (imbalance theory, methodology, honest evaluation)
- PPT presentation for final review
- Viva Q&A preparation document (AUPRC vs accuracy, class weights, thresholding, drift)
Limitations & prerequisites
- 0.91 recall / 0.94 precision are design targets for the training run, stated honestly — the report documents the actual achieved figures after training.
- Features V1–V28 are PCA-anonymized, so the model learns statistical shape, not human-readable transaction semantics.
- Fraud tactics drift over time; a model trained on 2013 data needs scheduled retraining on fresh labels — the report covers this explicitly.
- The demo stream is illustrative; connecting to a real payment gateway is out of scope.
- Blocking decisions carry business cost — the threshold analysis exists precisely because false positives block real customers.
Frequently Asked Questions
Which dataset is used?
The ULB credit-card fraud dataset on Kaggle — 284,807 real European card transactions with 492 confirmed frauds. It is the standard public benchmark for this task; features are PCA-anonymized to protect cardholder privacy.
Why not just report accuracy?
Because 99.83% accuracy is achieved by predicting "legitimate" always and catching zero frauds. The project tunes and reports AUPRC, recall and precision instead — the metrics that actually measure fraud-catching ability.
How does the model handle only 0.172% frauds?
XGBoost class weights make each fraud ~577× more important in the loss, so the minority class is learned rather than ignored. The notebook compares this against resampling alternatives.
What does the risk evidence show?
For each transaction, the top contributing features (e.g. V14 deep in the fraud tail, night-time hour, amount z-score) — so a fraud analyst can audit why a transaction was blocked.
Will it work on new fraud tricks?
Only after retraining on fresh labels — fraud drifts, and the report's retraining playbook covers exactly how a production team keeps the model current.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It demonstrates the single most important lesson in applied ML: choosing the right metric for an imbalanced problem. 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 (metrics, splits)
- NumPy, pandas, Matplotlib
- Jupyter Notebook (training & evaluation)
- HTML5 canvas + JavaScript (screening demo)
- ULB credit-card fraud dataset (Kaggle)
Dataset & model details
- Dataset: Kaggle "Credit Card Fraud Detection" (Machine Learning Group, ULB Brussels) — 284,807 transactions over 2 days in Sep 2013, 492 frauds (0.172%); features Time, Amount, V1–V28 (PCA-anonymized for confidentiality).
- Task: Binary classification under extreme imbalance; input = 30 features, output = fraud probability in [0, 1].
- Model: XGBoost binary classifier, max_depth 6, scale_pos_weight ≈ 577, early stopping; threshold selected from the validation precision–recall curve.
- Metrics: AUPRC, recall@precision, F1 — 0.91 recall / 0.94 precision is the design target for the built-to-order training run, stated honestly and never claimed as measured.
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.