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 the the original paper and the paper that introduced this GPU implementation:
@article{joy2026triopt,
title={TriOpt: A Scalable Algorithm for Linear Causal Discovery},
author={Joy, Rafat Ashraf and Zheleva, Elena},
journal={arXiv preprint arXiv:2605.17465},
year={2026}
}
@article{zheng2018dags,
title={Dags with no tears: Continuous optimization for structure learning},
author={Zheng, Xun and Aragam, Bryon and Ravikumar, Pradeep K and Xing, Eric P},
journal={Advances in neural information processing systems},
volume={31},
year={2018}
}
Metadata
Release files for notears-pytorch 0.4.0
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 |
|---|---|---|---|---|
| notears_pytorch-0.4.0.tar.gz | 4.6 kB | Without provenance | Details for notears_pytorch-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| notears_pytorch-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for notears_pytorch-0.4.0-py3-none-any.whl |
Total release size: 9.3 kB
Release files / notears_pytorch-0.4.0.tar.gz
| Download URL | notears_pytorch-0.4.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d1e9d7f205dd8f0077804a877282f60271c376bd96fdb3893719cd40d0bb269
|
|
BLAKE2b-256 checksum How to use checksums |
17f0193e20a49e4283b2fb0f5d0a67f574a7c04ee45c3ffcfb96ee18931a8f1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / notears_pytorch-0.4.0-py3-none-any.whl
| Download URL | notears_pytorch-0.4.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15ac31eaa725a3e25098e4073c4df95bea60f6690587dfef233690b0ad43bc0a
|
|
BLAKE2b-256 checksum How to use checksums |
ef21434fa4f61d675d53b88fe25cadd12b054b42a84cb224f210dea3e4a8fa7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for notears-pytorch 0.4.0
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.