Generate transactions with rare fraud labels
This worked example generates 10,000 synthetic transactions with a rare boolean label. It sets fraud probability to 2% for card-present transactions and 4% online, then reports the counts actually generated. Use it to exercise class-sensitive evaluation code and ingestion pipelines.
By the Ground team · 10,000 rows · 11 columns · Seed 31337
The same specification, row count and seed, in your own editable copy. Sign in to save it; preview is free and normal credits apply to exports.
Download the actual output
No signup required. All records are synthetic. The manifest contains file sizes and SHA-256 checksums so you can verify your copy.
Start with a clear request
This request describes the intent. The downloadable specification records the exact settings used to generate the files.
Create 10,000 synthetic US card transactions with transaction ID, timestamp, amount, merchant, category, channel, city and state. Use a long-tailed amount from $1 to $4,000. Make about 45% online. Set fraud probability to 2% for card-present transactions and 4% online, and make merchant categories depend on channel.
Inspect the first eight rows
These are the first rows of the downloadable files. CSV preserves decimal formatting; JSONL carries native numbers, booleans and nulls.
| timestamp | amount_usd | merchant_category | channel | state | is_fraud |
|---|---|---|---|---|---|
| 2025-04-09T17:36:34Z | 344.96 | grocery | card_present | MI | false |
| 2025-02-21T00:07:47Z | 1978.7 | electronics | online | CA | true |
| 2025-06-19T12:14:40Z | 962.87 | other | card_present | PA | false |
| 2025-03-13T18:53:16Z | 999.29 | online_retail | card_present | NC | false |
| 2025-06-01T09:39:15Z | 256 | online_retail | online | NY | false |
| 2025-02-05T10:15:44Z | 1133.03 | grocery | card_present | WA | false |
| 2025-02-27T09:26:54Z | 1270.08 | restaurants | card_present | MN | false |
| 2025-04-09T12:21:04Z | 198.66 | other | online | IL | false |
Check the measured output
These counts are calculated from the full downloadable dataset. Probability settings describe sampling rates, so observed percentages can differ.
- Fraud labels, all channels
- 294 / 10,000 (2.94%)
- Fraud labels: card_present
- 127 / 5,522 (2.30%)
- Fraud labels: online
- 167 / 4,478 (3.73%)
Use it in your workflow
- Load the JSONL or CSV and confirm that is_fraud is interpreted as a boolean.
- Inspect the observed label counts by channel below; finite samples do not have exact probability quotas.
- Use the fixture to check stratified splitting, confusion-matrix code and handling of a small positive class.
- For a real fraud model, fit to suitable training data and evaluate on a representative real holdout. This fixture alone cannot establish model utility.
Understand the schema
transaction_id: uuidtimestamp: dateamount_usd: numbermerchant: fakermerchant_category: categorycard_issuer: fakercard_last4: fakerchannel: categorycity: fakerstate: fakeris_fraud: boolean
Verify the download yourself
Download the verification script. It uses Python's standard library to download the files, verify their checksums, count records and check unique identifiers. No account or extra package is required.
curl -fsS https://useground.dev/examples/verify-example.py -o verify-example.py python3 verify-example.py rare-event-transactions
Recreate the dataset through the API
With a Ground account and API key, send the downloaded specification in the spec field to create a dataset. Then start an export with the returned dataset ID. This uses normal export credits (10 for one export of this rule-based example). See the API reference for job polling and download.
# Requires curl and jq. Set GROUND_API_KEY to your own API key.
curl -fsS https://useground.dev/examples/rare-event-transactions/spec.json -o spec.json
jq '{spec: .}' spec.json > request.json
curl -fsS https://useground.dev/api/datasets -H "Authorization: Bearer $GROUND_API_KEY" -H "Content-Type: application/json" --data-binary @request.json
# Replace DATASET_ID with the id returned above.
curl -fsS https://useground.dev/api/jobs -H "Authorization: Bearer $GROUND_API_KEY" -H "Content-Type: application/json" -d '{"datasetId":"DATASET_ID","format":"jsonl"}'The files were regenerated and checked against the specification before publication. Keep the downloaded fixture when you need exact long-term output: future engine versions can change generated values. The manifest records the seed and an engine-source fingerprint.
Limitations
The labels follow our specified simulation, not verified fraud behavior. Amount has no explicit dependence on the label in this example. There are no customer histories, repeated-card behavior or time sequences. Do not interpret the output as a fraud benchmark or evidence of improved model accuracy.
Build your own version
Open this example in Ground to adapt this exact specification, or use the API and Python SDK. Read the workflow guide and Ground versus a Faker script to choose an approach.