A PyTorch implementation of the NOTEARS algorithm for causal discovery.
Project description
This package provides a continuous optimization approach to learning DAGs (Directed Acyclic Graphs) from data, harnessing the power of GPUs to accelerate the learning process.
Note: The original NOTEARS Linear implementation is CPU only.
📦 Installation
You can install this package directly from PyPi:
pip install notears-pytorch
🚀 Usage
Below is a basic example of how to use the linear NOTEARS algorithm.
from notears_pytorch import notears_linear
# 2. Run optimization
# Returns a binary adjacency matrix where B[i, j] = 1 implies i -> j
adj_matrix = notears_linear(X, lambda1=0.1, w_threshold=0.3)
print("Estimated Adjacency Matrix:")
print(adj_matrix)
📚 API Description
notears_linear
notears_linear(X, lambda1=0.1, rho_init=1.0, alpha_init=0.0,
outer_iter=50, inner_iter=100, init_lr=1e-2,
h_tol=1e-8, w_threshold=0.3, use_gpu=False)
Arguments:
X(np.ndarray): Input data matrix of shape (n_samples, n_features).lambda1(float): L1 regularization strength for sparsity.rho_init(float): Initial penalty parameter for the augmented Lagrangian.alpha_init(float): Initial value for the Lagrange multiplier.outer_iter(int): Number of outer optimization iterations.inner_iter(int): Number of inner Adam optimizer iterations per sub-problem.init_lr(float): Initial learning rate for Adam optimizer.h_tol(float): Tolerance for the acyclicity constraint.w_threshold(float): Threshold for pruning weak edges in the adjacency matrix.use_gpu(bool): IfTrue, computation is performed on GPU (if available).
Returns:
np.ndarray: Estimated binary adjacency matrix of shape (n_features, n_features), where entry[i, j] = 1indicates a directed edge from nodeito nodej.
Description: This function runs the linear NOTEARS algorithm to estimate the structure of a directed acyclic graph (DAG) from observational data. It uses continuous optimization and supports GPU acceleration for faster computation.
📄 Citation
If you use this implementation in your research, please cite this GitHub repository and the original paper:
Zheng, X., Aragam, B., Ravikumar, P. K., & Xing, E. P. (2018). DAGs with NO TEARS: Continuous Optimization for Structure Learning. Advances in Neural Information Processing Systems.
Project details
Release history Release notifications | RSS feed
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 notears_pytorch-0.2.0.tar.gz.
File metadata
- Download URL: notears_pytorch-0.2.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f1ea04371f53b984f9bee7e610965227f9319f73661bbd1c44bce2a26cf89d
|
|
| MD5 |
42cd756db4d94c7a8393b03b0ad8c9bd
|
|
| BLAKE2b-256 |
872f7b8ddf17927f5db74f4b2229976c12472694a4852f00fe4205cf63d27595
|
File details
Details for the file notears_pytorch-0.2.0-py3-none-any.whl.
File metadata
- Download URL: notears_pytorch-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ab9246909205e7237e4f6ac6a872a1a21dfd4e7ddb6516aaa3fad60094a328
|
|
| MD5 |
e2271638b9ddaf863cabced5dcaaaf88
|
|
| BLAKE2b-256 |
4844d2aa1d24955995cafb40ae42242bcadabf970645fa66ff8a53a166bdf9a9
|