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"), with an opt-in standardized (design-A) threshold mode (threshold_standardized) that discretizes a unit-variance linear-Gaussian latent at equal-probability cutpoints
    • categorical -> continuous (functional_form.name = "stratum_means", including mixed-parent cases with metric_weights)
  • Opt-in spread-controlled softmax/logistic weights (softmax_weight_mode = "spread") for a detectable, balance-preserving logit contrast (default "gaussian" preserves legacy behaviour)
  • 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.3.0.tar.gz (29.8 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.3.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagsampler-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d3b7d6c9f1f92b7e8701100b82225c663f1709d557ef7cf208764c342ab816fe
MD5 37a1701068a3810655d87e4d906d41dd
BLAKE2b-256 c6242cda42de8ece66eeacd95744f5cf636a2d090ed292fc8af5eb267571f03e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dagsampler-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: dagsampler-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d17db87f43bf328ea15cf3dea6618ae89a489df3dcdd53d692861c13df58614b
MD5 cf82869c24d0b3a9ffd8035567e520d4
BLAKE2b-256 501df54430ac8a5e4593746ad4057b39ab86fba125afbf8e4242e40e14506eaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for dagsampler-0.3.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