Official implementation of
Causal Temporal Regime Structure Learning (AISTATS 2025)
Abdellah Rahmani, Pascal Frossard
CASTOR learns number of regimes, their indices and their corresponding causal graphs from multivariate time series (MTS) without any prior knowledge. It maximizes data log-likelihood via an Expectation–Maximization (EM) procedure, alternating between:
- E-step: regime learning
- M-step: learn regime-specific causal structures
Under Gaussian SEMs with equal error variances, both regime indices and their DAGs are identifiable up to label permutation.
CASTOR.py— core EM algorithm for regime discovery + causal graphsCASTOR_nonlinear.py— class that builds the NNs with training procedure used in our nonlinear settingscausal_structure.py— base class for structure models, which are an extension ofnetworkx.DiGraphdata_generation.py— synthetic SEM generatorsdynotears.py— baseline implementation used in our linear settinglinear_utils.py— helpers for linear SEMsMLP_lag.py— MLP-based lagged predictor (nonlinear), builds the Locally Connected layerstime_varying_weights.py— utilities for time-varying regimesutils.py— shared helpersCASTOR_tutorial.ipynb— end-to-end tutorial
# Clone
git clone https://github.com/arahmani/CASTOR.git
cd CASTOR
# (Recommended) create a fresh environment
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtIf you find this code useful, please cite the following paper:
@inproceedings{rahmanicausal,
title={Causal Temporal Regime Structure Learning},
author={Rahmani, Abdellah and Frossard, Pascal},
booktitle={The 28th International Conference on Artificial Intelligence and Statistics}
}