Diffusion Ordered Temporal Structure (DOTS)
This repository accompanies the paper "Causal Ordering for Structure Learning from Time Series" published in Transactions on Machine Learning Research (link to the paper).
See also: Time Series Causal Discovery Benchmark (used to run experiments).
Reproducing the paper? Use the
tmlr-2025release. It contains the exact code and conda environment used for the paper's results. Themainbranch holds the actively maintaineddots-causalPython package, which may change over time.
Installation
pip install dots-causal
or, from a clone of this repository:
pip install -e .
Requirement: R with mgcv
The final pruning step of DOTS (CAM pruning) runs in R. You need:
-
R installed, with
Rscripton yourPATH(CRAN). -
The
mgcvR package:Rscript -e 'install.packages("mgcv", repos = "https://cloud.r-project.org")'
If R or mgcv is missing, DOTS.fit raises dots_causal.RNotFoundError with instructions.
Alternatively, conda can install Python, R and mgcv together. From the repository root:
conda env create -f environment.yml
conda activate dots
A GPU is used automatically when PyTorch detects CUDA; otherwise DOTS runs on CPU.
Quick start
DOTS takes lagged data: one column per variable per lag
(e.g. X1_lag0, X2_lag0, X1_lag1, X2_lag1, ...), with variables ordered within each lag.
import pandas as pd
from dots_causal import DOTS
data_lagged = pd.read_csv("data/samples_lagged.csv") # columns: X1_lag0, X2_lag0, X3_lag0, X1_lag1, ...
nb_vars = 3
nb_nodes = data_lagged.shape[1]
nb_lags = nb_nodes // nb_vars
model = DOTS(nb_nodes)
adj = model.fit(data_lagged.to_numpy(), nb_timesteps=nb_lags, nb_variables=nb_vars)
adj_df = pd.DataFrame(adj, columns=data_lagged.columns, index=data_lagged.columns)
adj[i, j] == 1 means an estimated edge from node i to node j.
Evaluating against a known graph
from dots_causal import perform_eval, read_json
graphs_true = read_json("data/graphs_true.json")
print(perform_eval(graphs_true, adj_df, ["X1", "X2", "X3"]))
Demo
From the repository root, run sh setup-run.sh to create the conda environment and run the demo in one step, or after installing:
python demo.py
There is also an interactive notebook demo.
Replicating Experiments
You can use the TSCD Benchmark to fully replicate our results in an end-to-end manner.
Cite Us
@article{sanchez2025causal,
title={Causal Ordering for Structure Learning from Time Series},
author={Pedro Sanchez and Damian Machlanski and Steven McDonagh and Sotirios A. Tsaftaris},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2025},
url={https://openreview.net/forum?id=hWuTzqggSd}}
Metadata
Release files for dots-causal 0.1.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 |
|---|---|---|---|---|
| dots_causal-0.1.0.tar.gz | 26.5 kB | With provenance | Details for dots_causal-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dots_causal-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dots_causal-0.1.0-py3-none-any.whl |
Total release size: 53.1 kB
Release files / dots_causal-0.1.0.tar.gz
| Download URL | dots_causal-0.1.0.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a3859764fce4d7ee7cc98729472d63e94c08837ac0f1059cec7f68bfc6a6014
|
|
BLAKE2b-256 checksum How to use checksums |
63be5dbb6c25b60010ca9782c7d1f321a4dd8271e520ca368b4a1fa87146710b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / dots_causal-0.1.0-py3-none-any.whl
| Download URL | dots_causal-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6978959f676a40e28afe07572ba6aea48f1abdb5a3ac5903fb334cb5831d46eb
|
|
BLAKE2b-256 checksum How to use checksums |
7bb3cae49e22203e259b6be8539d3e9dcff55fdba8fc0b81d27101f5d830edea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for dots-causal 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for dots_causal-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA 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.