--- license: mit library_name: sklearn pipeline_tag: tabular-classification tags: - fraud-detection - logistic-regression - baseline - tabular-classification datasets: - Marvinds/synthetic-bank-transactions metrics: - roc_auc - average_precision model-index: - name: fraud-baseline-logreg results: - task: type: tabular-classification dataset: name: Synthetic Bank Transactions type: Marvinds/synthetic-bank-transactions metrics: - type: average_precision value: 0.7203 name: PR-AUC (time-based test split) - type: roc_auc value: 0.9849 name: ROC-AUC (time-based test split) --- # fraud-baseline-logreg A deliberately simple **logistic-regression baseline** for fraud detection, trained on [Marvinds/synthetic-bank-transactions](https://huggingface.co/datasets/Marvinds/synthetic-bank-transactions). ## Why this project Every later experiment I run (gradient boosting, sequence models, graph features) needs a number to beat. A baseline that's transparent, quick to retrain and honestly evaluated is that number. Logistic regression fits the job: its coefficients show what the model learned, and that can be checked against the known fraud mechanism of the synthetic dataset. It also practises two habits from production fraud systems: - **time-based evaluation** (train on the past, test on the future), never a random split; - **PR-AUC and recall at a fixed precision** instead of accuracy, because accuracy is meaningless at a 0.6% fraud rate (predicting "never fraud" scores 99.4%). ## Results Time-based split: first 80% of transactions for training, last 20% (20,000 rows, 0.6% fraud) for testing. | Metric | Value | |---|---| | ROC-AUC | 0.9849 | | **PR-AUC** | **0.7203** | | Recall @ precision ≥ 0.5 | 0.7355 | | Recall @ precision ≥ 0.8 | 0.6281 | Strongest coefficients: `txn_count_24h` (+1.66) and `amount_vs_avg` (+1.61), which match the velocity and amount-spike pattern injected by the generator. Full list is in `metrics.json`. > These numbers come from synthetic data with a known generator. They show the pipeline works. > They are **not** a claim about real-world fraud performance. ## Features `log(amount)`, `amount_vs_avg`, `txn_count_24h`, `is_foreign`, `is_new_device`, `is_night` (00–04), plus one-hot `merchant_category` and `channel`. Standard-scaled, `class_weight="balanced"`. ## Usage ```python import hashlib, joblib, pandas as pd from huggingface_hub import hf_hub_download path = hf_hub_download("Marvinds/fraud-baseline-logreg", "model.joblib") expected = open(hf_hub_download("Marvinds/fraud-baseline-logreg", "model.joblib.sha256")).read().strip() assert hashlib.sha256(open(path, "rb").read()).hexdigest() == expected model = joblib.load(path) # pickle: only load files you trust ``` Input must have the feature columns listed above (see `features()` in `train.py`). Trained with scikit-learn 1.9.1. ## Reproduce ```bash uv run train.py --data path/to/transactions.csv --out model ``` ## Next experiments - [ ] HistGradientBoosting vs this baseline, same split - [ ] Probability calibration and threshold selection based on review-queue capacity - [ ] Performance under concept drift (dataset v2)