Configurable causal DAG simulator for synthetic mixed-type data and CI test benchmarks
Project description
dagsampler
[!IMPORTANT] This repository is archived.
dagsamplerhas moved to the constraint-based-causal-discovery-suite umbrella, where it lives atdagsampler/.The PyPI package name
dagsampleris unchanged —pip install dagsamplercontinues 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.
Configurable causal DAG simulator for synthetic mixed-type data and CI test benchmarks.
What it provides
CausalDataGeneratorclass for configurable simulation- Support for
customandrandomDAGs - 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 withmetric_weights)
- continuous -> categorical (
- 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)
- additive (
- Random weight sampling controls (including exclusion band around zero)
force_uniform_marginalsfor balanced exogenous binary / categorical draws- Template helpers (
chain_config,fork_config,collider_config,independence_config) - Reproducibility via
seed_structureandseed_data(or singleseed) - 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
- Documentation — full reference for every config option, mechanism, and noise model.
- Tutorial — narrative walkthrough.
- How-to guides — task-focused recipes.
- Explanation — model formulations and design rationale.
- API reference — every public function and class.
examples/— runnable notebooks.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3b7d6c9f1f92b7e8701100b82225c663f1709d557ef7cf208764c342ab816fe
|
|
| MD5 |
37a1701068a3810655d87e4d906d41dd
|
|
| BLAKE2b-256 |
c6242cda42de8ece66eeacd95744f5cf636a2d090ed292fc8af5eb267571f03e
|
Provenance
The following attestation bundles were made for dagsampler-0.3.0.tar.gz:
Publisher:
release.yml on averinpa/constraint-based-causal-discovery-suite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagsampler-0.3.0.tar.gz -
Subject digest:
d3b7d6c9f1f92b7e8701100b82225c663f1709d557ef7cf208764c342ab816fe - Sigstore transparency entry: 1740240459
- Sigstore integration time:
-
Permalink:
averinpa/constraint-based-causal-discovery-suite@1bfb41e3cc903419e042c418dc187a8420493f7f -
Branch / Tag:
refs/tags/dagsampler-v0.3.0 - Owner: https://github.com/averinpa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bfb41e3cc903419e042c418dc187a8420493f7f -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d17db87f43bf328ea15cf3dea6618ae89a489df3dcdd53d692861c13df58614b
|
|
| MD5 |
cf82869c24d0b3a9ffd8035567e520d4
|
|
| BLAKE2b-256 |
501df54430ac8a5e4593746ad4057b39ab86fba125afbf8e4242e40e14506eaa
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagsampler-0.3.0-py3-none-any.whl -
Subject digest:
d17db87f43bf328ea15cf3dea6618ae89a489df3dcdd53d692861c13df58614b - Sigstore transparency entry: 1740240465
- Sigstore integration time:
-
Permalink:
averinpa/constraint-based-causal-discovery-suite@1bfb41e3cc903419e042c418dc187a8420493f7f -
Branch / Tag:
refs/tags/dagsampler-v0.3.0 - Owner: https://github.com/averinpa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bfb41e3cc903419e042c418dc187a8420493f7f -
Trigger Event:
push
-
Statement type: