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); base distribution selectable via dist (gaussian default, student_t, laplace, uniform, gamma, exponential)
    • shape / tail-shape (skew_first_parent, skew_tanh_first_parent, skew_mean_parents) — a parent drives the noise skewness with mean and variance held fixed (a higher-moment edge)
  • 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.4.0.tar.gz (34.2 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.4.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagsampler-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7cef8d5362542f795d992ea4e7f7e045b49490531069136dc6f5955d3b11b05e
MD5 2422f1f43edb0400650f3d4f8dc85810
BLAKE2b-256 412cda9e69f9014f1e8c4957fb2d52cc801c2ef2f926b8585760665d854c4905

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dagsampler-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3452de62da004680f65b6347372e2024d0a99faf2e1e726c6ef5bf2224f2c0cd
MD5 e3338372b06f1a90b48d9cb40c619f56
BLAKE2b-256 64afba515b0e907620d53608dc43cbc82e9dd0ca8a43aaad73d30cbdeba042d9

See more details on using hashes here.

Provenance

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