Skip to content

Detect unusual credit card transactions with unsupervised anomaly detection. compared three methods (z-score, isolation forest, dbscan) and explained trade-offs.

License

Notifications You must be signed in to change notification settings

userenigmatic/transaction-anomaly-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

transaction anomaly detection

problem

detect unusual card transactions that may be fraud or money laundering.
fraud is very rare (appr 0.17% of transactions).
goal was to test anomaly detection methods and compare them.

data

dataset: credit card fraud detection (europe, 2013).
284,807 transactions, 492 frauds.
features: pca components v1–v28, plus time, amount.
label: class (0 normal, 1 fraud).

methods

  • z-score baseline
  • isolation forest
  • dbscan

all methods trained unsupervised, labels used only for evaluation.

results

summary table:

method precision recall f1
zscore 0.01 0.90 0.02
isolation forest 0.15 0.44 0.23
dbscan 0.00 0.24 0.01

chart of precision vs recall is in /docs/precision_recall_bar.png.

conclusion:

  • zscore finds almost all fraud but too many false alerts.
  • isolation forest is more balanced.
  • dbscan performs poorly here.

what to discuss in interview

  • fraud is highly imbalanced, so accuracy is not useful.
  • precision vs recall trade-off → false positives waste time, false negatives miss fraud.
  • why anomaly detection? good when labels are scarce.
  • why isolation forest worked best here.
  • real world: need feature engineering (velocity, geography, peer comparison).
  • real world: alerts must be manageable volume for investigators.

how to run

  1. clone repo
  2. install requirements
    pip install -r requirements.txt

About

Detect unusual credit card transactions with unsupervised anomaly detection. compared three methods (z-score, isolation forest, dbscan) and explained trade-offs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published