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

Open this example in Ground →

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.

First eight generated rows
timestampamount_usdmerchant_categorychannelstateis_fraud
2025-04-09T17:36:34Z344.96grocerycard_presentMIfalse
2025-02-21T00:07:47Z1978.7electronicsonlineCAtrue
2025-06-19T12:14:40Z962.87othercard_presentPAfalse
2025-03-13T18:53:16Z999.29online_retailcard_presentNCfalse
2025-06-01T09:39:15Z256online_retailonlineNYfalse
2025-02-05T10:15:44Z1133.03grocerycard_presentWAfalse
2025-02-27T09:26:54Z1270.08restaurantscard_presentMNfalse
2025-04-09T12:21:04Z198.66otheronlineILfalse

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

  1. Load the JSONL or CSV and confirm that is_fraud is interpreted as a boolean.
  2. Inspect the observed label counts by channel below; finite samples do not have exact probability quotas.
  3. Use the fixture to check stratified splitting, confusion-matrix code and handling of a small positive class.
  4. 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: uuid
  • timestamp: date
  • amount_usd: number
  • merchant: faker
  • merchant_category: category
  • card_issuer: faker
  • card_last4: faker
  • channel: category
  • city: faker
  • state: faker
  • is_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.