Built to order

Credit Card Fraud Detection using Machine Learning

This project builds a machine-learning fraud scorer for credit card transactions, trained on the public Kaggle dataset of 284,807 European card transactions with only 0.172% frauds. It tackles the extreme class imbalance head-on with SMOTE and cost-aware XGBoost, evaluates on precision-recall (never accuracy), and ships with a web demo that scores any transaction with an explanation of its risk signals. The imbalance methodology and threshold policy are fully documented for the viva. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.

Credit Card Fraud Detection using Machine Learning — project thumbnail preview
More project photos (2)

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

  1. The 284,807 transactions are loaded (V1–V28 PCA features, Time, Amount, Class); Amount is log-scaled and Time is converted to hours.
  2. Data is split with stratification and time-awareness: the test fold preserves the natural 0.172% fraud rate.
  3. SMOTE oversampling is applied to the training fold only, combined with XGBoost's scale_pos_weight.
  4. An XGBoost classifier (300 trees, max depth 6) is trained with stratified 5-fold cross-validation.
  5. 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.
  6. Validation-fold analysis sets the policy thresholds: ≥0.80 auto-block, 0.50–0.80 step-up authentication, <0.50 clear.
  7. 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.

Download abstract (PDF)

Related guides

All guides
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Illustration of Whisper speech-to-text showing sound waves flowing into a neural network and emerging as transcribed text with timestamps and speaker labels.B.E./B.Tech Computer Science and AI/ML students adding speech-to-text to projects — voice assistants, meeting transcription, accessibility tools

Whisper for Speech-to-Text in Student Projects

Whisper transcribes speech in dozens of languages with no training required. This guide covers how it works, choosing among model sizes, running it locally with faster-whisper, handling hour-long audio, timestamps and speaker diarization, multilingual quirks, and honest evaluation with word error rate.

Read guide
Get a quotation