← Back

Data science project, 2021 capstone reworked in 2026

Fraud detection: deciding which transactions to review

A fraud model flags suspicious transactions for investigation. This project explores how the alert threshold changes the review workload, fraud caught and false alarms, using public datasets and illustrative operating costs.

Data
284,807 card transactions and 1,000,000 synthetic bank account applications
Methods
Logistic regression, XGBoost, time-ordered testing, cost-based thresholds
Scope
Offline analysis using public data and illustrative operating assumptions
Code
Python, pandas and scikit-learn

The decision this project explores

A fraud model flags suspicious transactions for investigation. Flag too many and the review team spends its time on genuine transactions. Flag too few and more fraud goes undetected.

This project revisits my data science capstone to explore that trade-off. The 2026 rework was developed with AI assistance and compares models and alert thresholds using public datasets. An interactive tool lets readers explore those choices using illustrative costs and review capacity.

The threshold is the score at or above which a transaction is flagged. Raising it usually reduces the review workload, but can also let more fraud pass. The workflow below illustrates that decision; this project evaluates it offline.

  1. Transaction
  2. Model assigns a score
  3. Threshold determines an alert
  4. Flagged transaction goes for review
Illustrative review workflow

Preparing the data

The card dataset was already anonymised and structured. The preparation work focused on understanding its distributions, transforming model inputs and keeping evaluation data separate.

2021 capstone. I inspected data types, non-null counts, summary statistics and class balance. The notebook found no missing values. I then examined feature distributions, scaled transaction amounts and applied a Yeo-Johnson transformation to address skewness in features that included negative values.

2026 rework. The pipeline sorts card transactions by time before splitting them. For bank applications, it separates earlier and later months, scales numerical inputs and encodes categorical fields such as employment status, housing status and device operating system. These preprocessing steps are fitted on training data and reused on validation and test data.

The examples below show how those choices are implemented. The original capstone and the rework use different preparation recipes.

Preparation choices in the source code
StageInput or findingPreparationWhy it matters
2021 capstoneSkewed numerical features, including negative valuesScale Amount, then fit a Yeo-Johnson transform on the training data and apply it to test data.Address skewness while supporting negative values.
2026 card reworkTransaction amounts and anonymised numerical featuresFor logistic regression, apply log1p to Amount and standardise it; standardise the other numerical inputs.Compress the amount scale and put linear-model inputs on comparable scales.
2026 bank application reworkCategorical fields alongside numerical inputsOne-hot encode categories, allow unseen categories at evaluation, and standardise numerical inputs.Create model-ready inputs without learning categories or scaling from test data.
2026 evaluationTime and month fieldsUse them to split earlier and later records, then exclude them and the fraud label from model inputs.Evaluate on later records and keep the answer out of the features.
See the categorical preprocessing code
ColumnTransformer([
    ("numeric", StandardScaler(), numeric),
    ("category", OneHotEncoder(handle_unknown="ignore"), CATEGORICAL),
])

Excerpt from the 2026 bank application pipeline. The preprocessor is fitted inside the model pipeline on training data.

Fewer alerts, more missed frauds

The 2026 rework sorts the transactions by time: the first 70% for training, the next 15% for choosing models and thresholds, and the final 15% for a single, untouched test. That last slice holds 42,722 transactions and 52 frauds, so every figure below carries some uncertainty.

The comparison below runs the original capstone method and the 2026 rework on the same later transactions. It compares both a different model and a different alert threshold; it does not isolate the effect of changing the threshold alone.

The resulting trade-off is visible in the review workload and missed frauds. Used the 2021 way, with the default cut, the method raised 1,196 alerts in about six hours to catch 45 of the 52 frauds. With the threshold chosen on the validation data against review costs and capacity, the rework raised 64 alerts and caught 39. That is 95% fewer alerts, and 6 more frauds missed, a trade a fraud team can now see and choose deliberately.

2021 method, default 0.5 cut vs 2026 rework, chosen threshold

2021 method, default 0.5 cut2026 rework, chosen threshold
Alerts (per day)1,196 (4,814.3)64 (257.6)
Frauds caught of the test total (recall range)45 of 52 (76.9%–94.2%)39 of 52 (63.5%–86.5%)
Frauds missed713
False alarms1,15125
Precision (95% range)3.8% (3.3%–4.2%)60.9% (50.7%–72.7%)
False alarms per fraud caught25.60.6
Net benefit in EUR under the assumed costs−€4,515.02€3,046.83
AlertsFalse alarms
  • 2021 method, default 0.5 cut
  • 2026 rework, chosen threshold
Show the data
Metric2021 method, default 0.5 cut2026 rework, chosen threshold
Alerts1,19664
False alarms1,15125

Choose the threshold yourself

Use the slider to change the alert threshold for the 2026 model. Watch how the number of alerts, false alarms and frauds caught changes.

Where to set the threshold is a business decision, not a modelling one. It depends on what a review costs, how much of a caught fraud is recovered, how much a false alarm annoys a genuine customer, and how many cases the team can handle in a day.

The figures below are the final test period. The costs start at illustrative assumptions, not measured company costs. The saved 2026 choice was selected on earlier validation data. The tool’s best threshold is calculated on this displayed test period with hindsight, so it is an exploration aid rather than a new validated recommendation.

Threshold explorer

Assumed business values, not measured from transactions.

ThresholdAlerts (per day)Frauds caught of 52False alarmsPrecisionNet benefit
2026 choice (0.927463)64 (257.6)392560.9%€3,046.83
Default 0.5 cut (0.500000)314 (1,264.1)4127313.1%€1,310.01

Extending the analysis to bank applications

The card data has anonymised features, which limits how much can be explained about a flag. The bank application analysis asks two additional questions: which recorded features does the model rely on, and do genuine applicants in different age groups face different false-alarm rates?

For this analysis, the 2026 rework uses Feedzai’s Bank Account Fraud dataset, published at NeurIPS 2022: one million synthetic but realistic bank account applications over eight months, about 1% fraud, with readable features.

The 2026 rework trains on months 0 to 4, chooses settings on month 5 and evaluates on months 6 and 7. This problem is harder: at a 5% false-alarm rate, the best model catches 54% of fraudulent applications, flagging 58 of every 1,000. The features that matter most are the kind a product team can act on: the applicant’s device, housing status, whether the home phone number is valid, existing products with the bank and session behaviour.

Bank account fraud results

Test applications: 205,011 · Frauds: 2,878 · Fraud rate: 1.4%

ModelROC-AUC (95% range)Precision-recall area (95% range)
Logistic regression, class weights0.876 (0.869 to 0.883)0.153 (0.142 to 0.165)
XGBoost, class weights0.890 (0.885 to 0.897)0.188 (0.175 to 0.201)
False-alarm operating pointShare of frauds caught (95% range)Alerts per 1,000 applications
1%26.1% (24.4%–27.6%)14.6
5%54.0% (52.2%–55.8%)58.3

Feature importance

Device operating systemHousing statusValid home phone numberHas other cards with the bankStayed logged in (keep-alive session)Internal credit risk scoreUses a free email providerName matches email addressMonths at previous addressProposed credit limit
How much the model's precision-recall area drops when each feature is shuffled
Show the data
FeatureDrop in precision-recall areaStandard deviation
Device operating system0.03590.0031
Housing status0.03370.0032
Valid home phone number0.02190.0009
Has other cards with the bank0.01810.0020
Stayed logged in (keep-alive session)0.01660.0026
Internal credit risk score0.01460.0012
Uses a free email provider0.01290.0014
Name matches email address0.01110.0027
Months at previous address0.01040.0032
Proposed credit limit0.01010.0017

Who gets flagged

A fraud model also decides which genuine customers get stopped. At the same 5% operating point, legitimate applicants aged 50 and over were flagged 12.3% of the time, against 3.8% for those under 50: 3.3 times as often.

Age is one of the inputs, and other inputs can stand in for it. I would not ship this without a product decision on how much disparity is acceptable, a test of the model without age and its closest proxies, and monitoring of flag rates by group after launch.

False-positive rate by age

Under 503.8%50 and over12.3%
Legitimate applicants flagged. 50 and over vs under 50: 3.3 times.
AgeApplicantsLegitimate applicantsRecall
Under 50171,232169,34346.5%
50 and over33,77932,79068.3%
Show the data
AgeFalse-positive rateLegitimate applicantsRecall
Under 503.8%169,34346.5%
50 and over12.3%32,79068.3%

How the original capstone was checked

My data science capstone in 2021 asked a standard question: can a model flag fraudulent card transactions? The data is a public set of 284,807 European card transactions from two days in 2013, of which 492, or 0.17%, are fraud.

I compared logistic regression, decision trees, random forests and XGBoost, with and without balancing techniques for the rare fraud class, and chose logistic regression trained with SMOTE, which creates synthetic fraud examples. The notebook reported strong results on the held-out test set.

In 2026 the original notebook was reproduced. The reproduction matches every reported metric to within 0.001, so the comparisons start from what I actually did. Only the threshold the notebook picked from the test set differs slightly, because library versions have changed.

As reported in 2021 vs reproduced in 2026

2021 reported2026 reproduced
Test accuracy97.7%97.7%
Test ROC-AUC computed on yes/no predictions0.9310.931
Test sensitivity88.5%88.5%
Test specificity97.7%97.7%
Validation precision7.9%7.9%

Measured properly on the same test set

ROC-AUC from scores0.967
Precision-recall area0.603
Alerts1,405
Frauds caught of the test total85 of 96
False alarms1,320
Precision6.1%
False alarms per fraud caught15.5

What the original evaluation missed

Looking at it again, the evaluation told a better story than the model deserved:

  • Precision was never in the conclusion. At the default cut, the model flagged 1,405 test transactions to catch 85 frauds: 6% precision, or 15.5 false alarms for every fraud caught. A review team would spend most of its day on genuine customers.
  • The “ROC-AUC” was computed on yes/no predictions, not on the model’s scores, so it was really a balanced accuracy. Measured properly, ROC-AUC was 0.97 and the precision-recall area, the more telling measure for rare events, was 0.60.
  • The decision threshold was chosen on the test set, which quietly uses the answers the test is meant to hide.
  • The split ignored time. Transactions were shuffled before splitting, so the model was tested on moments it had already seen around. Fraud changes over time; an honest test trains on the past and tests on the future.

On the time-ordered test, the precision-recall area is 0.750 for the original method and 0.756 for XGBoost with class weights, with overlapping uncertainty ranges. This measures how well the models rank fraud above genuine transactions; the earlier workload comparison also depends on the chosen alert thresholds.

Precision against recall

0.00.00.50.51.01.0RecallPrecision
  • 2021 capstone method
  • XGBoost, class weights
Show the data
ModelPrecision-recall area95% range
Logistic regression, class weights0.6900.555 to 0.847
Logistic regression with SMOTE0.7070.567 to 0.851
XGBoost, class weights0.7560.645 to 0.866
2021 capstone method0.7500.626 to 0.866

What I would tell a product team

  • Ask for precision and alerts per day, not accuracy. At 0.17% fraud, a model that flags nothing is 99.8% accurate.
  • Test on the future, not a shuffle of the past. A time-ordered split is the closest thing to launch day.
  • Treat the threshold as a product setting. The same model can lose money or save it depending on where the line is drawn, and the right line moves with review costs and team capacity.
  • Check who carries the cost of false alarms before launch, not after a complaint.

Data and method notes

  • Card transactions: Credit Card Fraud Detection, ULB Machine Learning Group and Worldline, via OpenML (dataset 1597); Open Database License with Database Contents License. Dal Pozzolo and others, 2015.
  • Bank account applications: Bank Account Fraud Dataset Suite (base variant), Feedzai, via Kaggle; non-commercial licence; synthetic data generated from real applications. Jesus and others, NeurIPS 2022. Only aggregate results are shown here.
  • Labels: “2021 capstone (reproduced)” is my original coursework method; “2026 rework” is everything added since. Uncertainty ranges are 95% bootstrap intervals on the test data.
  • Assumed values in the threshold tool (review cost, recovery share, false-alarm cost, daily capacity) are illustrative, not taken from any company.
  • Reproducibility: The 2026 pipeline checks source files against registered checksums and runs preparation, modelling and report generation through a repeatable Python workflow.
  • Code and attribution: The 2021 capstone is my own coursework. The 2026 rework, its pipeline and its tests were built with AI assistance.