Skip to main content

Configurable causal DAG simulator for synthetic mixed-type data and CI test benchmarks

Project description

dagsampler

[!IMPORTANT] This repository is archived. dagsampler has moved to the constraint-based-causal-discovery-suite umbrella, where it lives at dagsampler/.

The PyPI package name dagsampler is unchanged — pip install dagsampler continues to work, with future releases (0.2.0+) published from the suite repo. This archive is kept read-only for historical reference; the v0.1.0 source remains here at the last commit before the move.

PyPI version Python versions License: MIT Documentation

Configurable causal DAG simulator for synthetic mixed-type data and CI test benchmarks.

Documentation · Changelog

What it provides

  • CausalDataGenerator class for configurable simulation
  • Support for custom and random DAGs
  • Mixed continuous/binary/categorical nodes (configurable categorical cardinality)
  • Structural forms: linear, polynomial, interaction, sigmoid, cos, sin, stratum_means
  • Optional element-wise post_transform (tanh, sin, cos, exp_neg_abs, sqrt_abs, relu, sign)
  • Cross-type mechanisms:
    • continuous -> categorical (categorical_model.name = "threshold")
    • categorical -> continuous (functional_form.name = "stratum_means", including mixed-parent cases with metric_weights)
  • Noise models:
    • additive (gaussian, student_t, gamma, exponential, laplace, cauchy, uniform)
    • multiplicative (gaussian, student_t, gamma, exponential)
    • heteroskedastic (abs_first_parent, abs_parent_plus_const, mean_abs_plus_const)
  • Random weight sampling controls (including exclusion band around zero)
  • force_uniform_marginals for balanced exogenous binary / categorical draws
  • Template helpers (chain_config, fork_config, collider_config, independence_config)
  • Reproducibility via seed_structure and seed_data (or single seed)
  • Optional d-separation CI oracle output (store_ci_oracle=true)

Installation

From PyPI:

pip install dagsampler

Or with uv:

uv venv
source .venv/bin/activate
uv pip install dagsampler

From GitHub (latest main):

uv pip install "dagsampler @ git+https://github.com/averinpa/dagsampler.git"

Quick start (Python API)

from dagsampler import CausalDataGenerator

config = {
    "simulation_params": {"n_samples": 200, "seed": 42},
    "graph_params": {
        "type": "custom",
        "nodes": ["X", "Y", "Z1"],
        "edges": [["X", "Z1"], ["Y", "Z1"]],
    },
}

result = CausalDataGenerator(config).simulate()
data = result["data"]
dag = result["dag"]
params = result["parametrization"]

CLI

The package exposes dagsampler-generate.

dagsampler-generate \
  --config config.json \
  --output dataset.csv \
  --params-out params.json \
  --edges-out edges.json

config.json must contain the same structure used by CausalDataGenerator.

Learn more

Development

uv pip install -e ".[dev]"
pytest -q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dagsampler-0.2.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagsampler-0.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file dagsampler-0.2.0.tar.gz.

File metadata

  • Download URL: dagsampler-0.2.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dagsampler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5e725da8ef650822cab5eba7338b59396c7f8bc30505ae72271ca0feecf1b0c3
MD5 2d257199c741f122dc6b34992448d969
BLAKE2b-256 a2983da100a6d46a872ffd66729bfa93a770a0fb8add3c5e05fb0d5b3d6e3934

See more details on using hashes here.

Provenance

The following attestation bundles were made for dagsampler-0.2.0.tar.gz:

Publisher: release.yml on averinpa/constraint-based-causal-discovery-suite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dagsampler-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dagsampler-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dagsampler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63ff14a22b4116fe1ce1dcd39b6f476eef468608a0ac19bf890ee9fa73d9e48a
MD5 02879954c27d1548b0011f8fe97286c0
BLAKE2b-256 44724926aee2d0177fb658f7f53f192b6672accf3f958c6e5ba3848f88a91dfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for dagsampler-0.2.0-py3-none-any.whl:

Publisher: release.yml on averinpa/constraint-based-causal-discovery-suite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page