Datasets:
File size: 9,460 Bytes
d632223 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | # Data Card: `fraudlab.synth` synthetic transaction data
Datasheet-style documentation for the generator in `src/fraudlab/synth/` (version 0.1.0). Descriptive statistics for the `small` preset are in [`DATA_CARD_STATS.md`](DATA_CARD_STATS.md), regenerated by `experiments/data_card_stats.py`.
> **This is synthetic data.** No real transactions, customers or institutions were used to build, fit or calibrate the generator. Its distributions are stylised from qualitative descriptions in the published literature (see [`../literature/REVIEW.md`](../literature/REVIEW.md)). Findings on this data are evidence about *mechanisms*, not about any real payment system.
## Motivation
- **Purpose:** controlled experiments on fraud-detection models where the fraud mechanism, its timing (drift), label latency and relational structure are known and adjustable. Real data can't offer that (REVIEW §9, gap G9).
- **Created by:** the `fraud-synth-bench` project, Apache-2.0.
- **Not intended for:** estimating real-world fraud prevalence or losses, benchmarking vendor products, or training production models.
## Composition
| File | Grain | Key columns |
|---|---|---|
| `transactions.parquet` | one row per transaction | `tx_id`, `timestamp`, `account_id`, `merchant_id` (null for transfers), `counterparty_id` (null for card payments), `device_id` (null for card-present), `amount`, `mcc`, `channel` (pos / online / transfer), `country` |
| `labels.parquet` | one row per transaction | `is_fraud` (ground truth), `observed_label` (0 if never detected), `label_available_at` (null unless observed), `scenario`, `fraud_event_id` |
| `accounts.parquet` | one row per account | `opened_at`, `home_country`, `segment`, `account_role` |
| `merchants.parquet` | one row per merchant | `mcc`, `country`, `opened_at` |
| `edges.parquet` | one row per (src, dst, type) | `pays` (account→merchant), `transfers` (account→account), `uses_device` (account→device), with `first_seen`, `last_seen`, `n_tx` |
| `manifest.json` | per dataset | generator version, preset, seed, all parameters, content hash, summary stats, library versions |
**Ground-truth-only columns.** `labels.is_fraud`, `labels.scenario`, `labels.fraud_event_id` and `accounts.account_role` reveal the answer. They exist for evaluation and analysis, and **must never be used as model features**. Models may use `observed_label` only where `label_available_at ≤` the training cutoff. The aggregated `edges` table spans the whole timeline, so time-respecting graph features must be built from `transactions` with a cutoff (Phase 4 does this).
**Presets.**
| Preset | Accounts | Days | ≈ Transactions | Used for |
|---|---|---|---|---|
| `tiny` | 2,000 | 30 | 20k | tests, `make quick` |
| `small` | 20,000 | 30 | 200k | RQ1, RQ3, RQ5 |
| `small_long` | 8,000 | 90 | 200k | RQ2, RQ4 |
| `full` | 200,000 | 30 | 2M | documented and tested, not in the paper |
On an M4 MacBook Air, `small` generates in about 0.2 s with a peak RSS of about 0.24 GB. `full` takes about 4 s with a peak RSS of about 1.2 GB.
## Collection process (simulation)
**Legitimate behaviour** (`world.py`):
- Account activity is heterogeneous: rate ~ Gamma(1.5) with mean `tx_per_account_day`. 3% of accounts open during the window.
- Amounts are log-normal: an account-level location from the segment (standard / premium / student) plus noise, a category offset, and σ = 0.8.
- Time of day follows a von Mises distribution (κ = 2.5) around each account's preferred hour (about N(14h, 3.5h)), with 10% uniform activity.
- 65% of card payments go to one of five habitual merchants. The rest go to merchants drawn by Zipf-distributed popularity.
- 5% of legitimate transactions are P2P transfers to one of three fixed contacts.
- Card-present payments have no customer device. Online payments and transfers carry one.
**Legitimate look-alikes, scaled by `noise`** (default 0.4, set by the D014 difficulty check). They exist so that no single raw field separates the classes:
- trips abroad (10% × noise of accounts, 2–7 days);
- devices shared within a household (15% × noise);
- switching to a new phone mid-window (10% × noise);
- one-off logins from a fresh device (2% × noise of online transactions);
- unusually large purchases (1% × noise, 4–15× the usual amount).
**Fraud** comes from eight injectors (`scenarios/`). Each has a docstring citing the pattern it imitates:
| Scenario | Mechanism | Main signal | Structure |
|---|---|---|---|
| `card_testing` | 5–15 micro-charges at uniformly chosen online merchants in about 10 min; sometimes a large purchase follows | tiny amounts, sub-minute gaps | attacker device pool |
| `account_takeover` | 2–6 high-value online purchases within 2 days from an attacker device, often abroad and at night | new device, amount ≫ norm | attacker device pool |
| `velocity_abuse` | 8–25 purchases of $20–150 in 1–2 h at 1–3 merchants of one category | count per hour | individual |
| `friendly_fraud` | the customer's own normal-looking purchase, later disputed | almost none (by design) | individual |
| `bust_out` | an established account spends 3–10× its norm for 1–3 days, then goes dark | change against own history | individual (sequence) |
| `mule_network` | victims → 5–12 young mule accounts → one collector, within hours | transfers, shared devices, fan-in | **ring** |
| `merchant_collusion` | a new merchant charges 5–20 stolen cards round amounts | new merchant with no legitimate customers | **ring** |
| `synthetic_identity` | 3–8 accounts opened in the window, sharing 1–2 devices, buying resellable goods | young accounts, shared devices | **ring** |
**Fraud budget.** Within each drift segment, fraud transactions = `fraud_rate` × legitimate volume / (1 − `fraud_rate`). This is split across the active scenarios in proportion to their weights. Each injector generates whole events until its budget is met, then trims the time-ordered tail of the last event. The realised rate matches the target to within rounding (bust-out accounts going dark removes a few legitimate transactions afterwards).
**Drift.** A drift schedule is a list of segments over [0, 1] of the timeline, each with its own scenario weights. `DRIFT_RQ2` switches from {card testing, ATO, velocity} to {bust-out, synthetic identity, mule network} at 60%. The legitimate behaviour doesn't drift.
**Labels.** Each fraud event is detected with probability `detection_prob` (0.95). The delay is drawn once per event from Uniform(7, 30) days, plus up to 2 days of per-transaction jitter. For friendly fraud it's multiplied by 1.5, since disputes are filed late. Undetected fraud keeps `observed_label = 0` forever.
**Determinism.** Every component uses its own named RNG stream (`numpy.random.default_rng([seed, crc32(name)])`). The output is a pure function of the config, and adding a scenario doesn't change legitimate traffic. `content_hash` is a SHA-256 over column names, dtypes and values of all tables. It doesn't depend on parquet writer metadata. Same seed, same hash: this is tested, and also checked across write and load.
## Validation (`tests/test_synth.py`)
- Determinism: same seed gives the same hash, a different seed a different hash, and write → load preserves the hash.
- Fraud rate within 5% (relative) of the target, at 0.1%, 0.5% and 1%.
- Schema, temporal ordering, and the null structure of devices, merchants and counterparties.
- Label-delay bounds, friendly-fraud delay > other fraud, detection rate.
- The drift schedule switches the scenario set at the right time. Ring share 0 and 1 give disjoint scenario sets.
- The noise knob adds look-alikes: card-present payments abroad, shared devices, devices per account.
- **One signature test per injector.** Each passes on seeds 0–4.
## Known limitations and differences from real data
1. **Not calibrated to real data.** Distribution parameters are stylised. Real data has heavier tails, many more merchant categories, and seasonality (weekly or monthly cycles, holidays) that the generator doesn't model.
2. **Fraud is more mechanistic than in reality.** Each scenario has a clean signature, and in practice fraudsters mix tactics. Most scenarios are easier to detect than real fraud, except `friendly_fraud`, which is close to undetectable by design. Absolute AUPRC values shouldn't be compared with published numbers on real data. Only *relative* comparisons under controlled conditions are meaningful.
3. **Few events for ring scenarios.** At `small` with a 0.5% fraud rate, ring scenarios contribute only about 4–8 events each (about 120 transactions). Per-scenario results therefore have high variance, and results are reported over 5 seeds.
4. **No adaptive adversary.** Drift is scheduled, not a reaction to the deployed model, and there's no feedback loop (FUTURE_WORK, G10).
5. **Legitimate behaviour is stationary.** There are no customer life events or holiday spikes, and only fraud drifts.
6. **Single currency, abstract countries** (`C00`–`C11`). There are no real geographies, merchants or identifiers, and therefore no PII.
7. **The edge table is aggregated over the whole timeline.** Using it directly as a feature source leaks future information.
## Maintenance
Versioned with the package (`generator_version` in each manifest). Any change that alters the output for a given config must bump the version and be noted in `docs/DECISIONS.md`.
|