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 .
DOTS is pure Python; no R installation is needed. Versions up to 0.2.0 ran the final pruning
step (CAM pruning with generalised additive models) in R with mgcv. It is now a Python port of
the same computation, which made the same keep/drop decisions as R in all our comparisons
(see CHANGELOG.md).
A GPU is used automatically when PyTorch detects CUDA; otherwise DOTS runs on CPU.
Quick start
Pass your time series as it is (one column per variable, rows in time order) and choose how many past time steps to consider:
import pandas as pd
from dots_causal import DOTS
data = pd.read_csv("data/samples.csv") # columns: X1, X2, X3
graph = DOTS(max_lag=1, random_state=0).fit(data)
graph is a pandas DataFrame over the lagged variables (X1_lag0, X2_lag0, X3_lag0, X1_lag1, ...,
where lag0 is the current time step and lag1 the previous one).
graph.loc[cause, effect] == 1 means an estimated edge, e.g. graph.loc["X1_lag1", "X2_lag0"]
is an effect of X1 on X2 one time step later. NumPy arrays work too (variables are then named X1, X2, ...).
random_state is optional and makes runs reproducible.
Options
| Parameter | Default | Meaning |
|---|---|---|
max_lag |
1 |
Number of past time steps considered as causes. |
voting_threshold |
0.0 |
DOTS combines several causal orderings by voting. A candidate edge must agree with more than this fraction of them (before pruning). 0.0 = any ordering (as in the paper); higher = sparser. |
n_orderings |
10 |
How many diffusion time steps are used to compute orderings (n_orderings + 1 orderings with the defaults). |
normalize |
True |
Standardise each variable to zero mean and unit variance before training. |
allow_instantaneous |
False |
Also allow edges within the same time step. |
pruning_cutoff |
0.001 |
Significance level of the final pruning step: a candidate parent is kept if its p-value is below this. Higher = more edges. |
random_state |
None |
Seed for reproducible results. |
Training settings (epochs, batch_size, learning_rate, ...) are listed in help(DOTS).
To see the lagged data DOTS works with, use dots_causal.make_lagged(data, max_lag).
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, graph))
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.3.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.3.0.tar.gz | 37.6 kB | With provenance | Details for dots_causal-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dots_causal-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for dots_causal-0.3.0-py3-none-any.whl |
Total release size: 71.3 kB
Release files / dots_causal-0.3.0.tar.gz
| Download URL | dots_causal-0.3.0.tar.gz |
|---|---|
| Size | 37.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd4af9257d464baf55413f5ca3922eaa162f0920ac2cd31ebd99b3377d857629
|
|
BLAKE2b-256 checksum How to use checksums |
7253e30741c6b1b7f2bad29ee7bc7db8183ab606e20b8291512c2e05a7c59691
|
| 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 29, 2026.
Transparency logRelease files / dots_causal-0.3.0-py3-none-any.whl
| Download URL | dots_causal-0.3.0-py3-none-any.whl |
|---|---|
| Size | 33.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c6bc844e4aec43e256eba0623adff850168d7142d7c84a0a16de8d6aee0a83d
|
|
BLAKE2b-256 checksum How to use checksums |
3a01d882c5dd683e3dc78c66bb00f69cb0b00ba9dbbf90be82abf64111428cf4
|
| 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 29, 2026.
Transparency logSecurity for dots-causal 0.3.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.3.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 29, 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.