| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A Python library for discovering causal networks from time series data using Optimal Causation Entropy (oCSE).
See our Quick Start colab notebook:
CausationEntropy implements state-of-the-art information-theoretic methods for causal discovery from multivariate time series. The library provides robust algorithms for identifying causal relationships. This library is dedicated to maintaining the intellectual legacy of the oCSE method developed by Erik Bollt.
See our SIAM News article.
Given time series data, CausationEntropy finds which variables cause changes in other variables by:
pip install causationentropygit clone https://github.com/Center-For-Complex-Systems-Science/causationentropy.git
cd causationentropy
pip install -e .python -m pytest causationentropy/tests/ --cov=causationentropyWith overage loally:
python -m pytest causationentropy/tests/ --cov=causationentropy --cov-report=xml --cov-report=term-missing -vGet the relationships as a Pandas data frame:
import pandas as pd
from causationentropy import discover_network
from causationentropy.graph import network_to_dataframe
# Load your time series data (variables as columns, time as rows)
data = pd.read_csv('data.csv')
# Discover causal network
network = discover_network(data, method='standard', max_lag=5)
df = network_to_dataframe(network)
df.head()Plot the causal network:
from causationentropy import discover_network
from causationentropy.core.plotting import plot_causal_network
# Load your time series data (variables as columns, time as rows)
data = pd.read_csv('data.csv')
# Discover causal network
network = discover_network(data, method='standard', max_lag=5)
fig, ax = plot_causal_network(network, save_path="network.png")Note: Application of this algorithm without optimizations is computationally intensive. When running this algorithm, please be patient. Optimizations of the algorithm are planned for a later release that leverage singular value decomposition and KD-Trees. However, these optimizations are not part of the original algorithm. Adding additional lags also contributes to additional performance degradations.
from causationentropy import discover_network
# Configure discovery parameters
network = discover_network(
data,
method='standard', # 'standard', 'alternative', base lines: 'information_lasso', or 'lasso'
information='gaussian', # 'gaussian', 'knn', 'kde', 'geometric_knn', or 'poisson'
max_lag=5, # Maximum time lag to consider
alpha_forward=0.05, # Forward selection significance
alpha_backward=0.05, # Backward elimination significance
n_shuffles=200 # Permutation test iterations
)from causationentropy.datasets import synthetic
from causationentropy import discover_network
rho = 0.7
# Generate synthetic causal time series
data, true_network = synthetic.linear_stochastic_gaussian_process(
rho,
n=5,
)
# Discover network
discovered = discover_network(data)The algorithm uses conditional mutual information to quantify causal relationships:
$$I(X; Y | Z) = H(X | Z) + H(Y | Z) - H(X, Y | Z)$$
This measures how much variable X tells us about variable Y, beyond what we already know from conditioning set Z.
Causal Discovery Rule: Variable X causes Y if knowing X(t) significantly improves prediction of Y(t+1), even when controlling for all other relevant variables.
The algorithm implements a two-phase approach:
📚 Read the full documentation on ReadTheDocs
Build documentation locally:
cd docs/
make html
# Open docs/_build/html/index.htmlWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
If you use this library in your research, please cite:
@misc{slote2025causationentropy,
author = {Slote, Kevin and Fish, Jeremie and Bollt, Erik},
title = {CausationEntropy: A Python Library for Causal Discovery},
url = {https://github.com/Center-For-Complex-Systems-Science/causationentropy},
doi = {10.5281/zenodo.17047565}
}This project is licensed under the MIT License - see the LICENSE file for details.
This work builds upon fundamental research in information theory, causal inference, and time series analysis. Special thanks to the open-source scientific Python community.
Generative AI was used to help with doc strings, documentation, and unit tests.
| Back | FazBrowse Home | New Git URL |