Skip to main content

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) 

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)

Source distribution for ddcd 0.0.1
File Size Uploaded
ddcd-0.0.1.tar.gz 24.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ddcd 0.0.1
File Interpreter ABI Platform
ddcd-0.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page