Skip to content

Anomaly Injection

Ravi Kiran Pagidi edited this page Jun 20, 2026 · 2 revisions

Anomaly Injection

Great Generator creates clean relationship-safe data by default. Anomaly injection is separate and opt-in.

data = generate_domain(
    "ecommerce",
    anomalies={
        "null_rate": 0.02,
        "duplicate_rate": 0.01,
        "orphan_fk_rate": 0.001,
        "late_arrival_rate": 0.02,
        "outlier_rate": 0.005,
        "invalid_status_rate": 0.01,
    },
)

Supported anomaly types include:

  • nulls
  • duplicates
  • invalid values
  • outliers
  • late-arriving records
  • out-of-order records
  • broken references / orphan foreign keys
  • negative amounts
  • skew

Keeping anomalies separate from realistic base generation matters. It lets users decide whether they want clean demo data or intentionally messy data for data-quality testing.

Labeled anomaly ground truth

Use return_labels=True when you want an answer key for every planted defect.

data = generate_domain(
    "ecommerce",
    anomalies={"null_rate": 0.02, "invalid_status_rate": 0.005},
    return_labels=True,
)

labels = data["_anomaly_labels"]

The label table includes:

  • table
  • row_index
  • primary_key
  • primary_key_value
  • column
  • anomaly_type
  • original_value
  • corrupted_value

This is useful for data-quality demos, anomaly detection benchmarks, and QA tests.

Clone this wiki locally