Causal Structure Learning via Diffusion Denoising Objectives
Understanding causal dependencies in observational data is critical for informing decision-making. These relationships are often modeled as Bayesian Networks (BNs) and Directed Acyclic Graphs (DAGs). Existing methods, such as NOTEARS and DAG-GNN, often face issues with scalability and stability in high-dimensional data, especially when there is a feature-sample imbalance. Here, we show that the denoising score matching objective of diffusion models could smooth the gradients for faster, more stable convergence. We also propose an adaptive k-hop acyclicity constraint that improves runtime over existing solutions that require matrix inversion. We name this framework Denoising Diffusion Causal Discovery (DDCD). Unlike generative diffusion models, DDCD utilizes the reverse denoising process to infer a parameterized causal structure rather than to generate data. We demonstrate the competitive performance of DDCDs on synthetic benchmarking data. We also show that our methods are practically useful by conducting qualitative analyses on two real-world examples.
Get started
Installation
pip install ddcd
Example
import ddcd
from castle.datasets import IIDSimulation, DAG
# an unwanted behavior from castle
torch.set_default_dtype(torch.float)
# Generating synthetic data
dag_adj = DAG.scale_free(
n_nodes = 100, n_edges = 1000,
weight_range = (0.5, 1.5), seed=42
)
X = IIDSimulation(
W=dag_adj,
n=2000, method='linear',
sem_type='gauss', noise_scale=1
).X
# Training
model = ddcd.DDCD_Linear_Trainer(X, device='cuda')
model.train(5000)
w = model.get_adj()
A = (np.abs(w) > 0.3)
Metadata
Release files for ddcd 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ddcd-0.0.1.tar.gz | 24.4 kB | Without provenance | Details for ddcd-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ddcd-0.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for ddcd-0.0.1-py2.py3-none-any.whl |
Total release size: 64.1 kB
Release files / ddcd-0.0.1.tar.gz
| Download URL | ddcd-0.0.1.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78065fc7f6b614918303b53577515673454967ab8d0ba2fab78971c5e58f4ffd
|
|
BLAKE2b-256 checksum How to use checksums |
eb04d13b2595a4431258945a4f946b6c7cff4f99ad00905e0625688576309861
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Release files / ddcd-0.0.1-py2.py3-none-any.whl
| Download URL | ddcd-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 39.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5f1ef7bc00898a87ea2ac5558d6ca35098ee56a42e35ee0f1ee07d60c6896af6
|
|
BLAKE2b-256 checksum How to use checksums |
699d99c6df5ec5bc4bfb99c33991a57cf0b83c4d57fe6a65a0c931fa7b8cb155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Security for ddcd 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.