Causal-Networkx is a Python graph library that extends networkx to implement causal graphical structures.
Causal-networkx does not directly subclass networkx graphs because they inherently do not support mixed edge graphs. Moreover, there are certain "graph algorithms" in networkx that would not work with mixed edge graphs. However, for the purposes of causal inference, only certain graph semantics are needed. Thus we have a lightweight library for causal graph representations that leverage the robustness and efficiency of networkx.
Representation of causal inference models in Python are severely lacking. Moreover, sampling from causal models is non-trivial. However, sampling from simulations is a requirement to benchmark different structural learning, causal ID, or other causal related algorithms.
This package aims at serving as a framework for representing causal models and sampling from causal models.
causal-networkx
interfaces with other popular Python packages, such as networkx
for graphical representations.
See the development version documentation.
Or see stable version documentation
Installation is best done via pip
or conda
. For developers, they can also install from source using pip
. See installation page for full details.
Minimally, causal-networkx requires:
* Python (>=3.8)
* NumPy
* SciPy
* Networkx
* Pandas
For extra functionality, see the extra-requirements.txt
for additional
packages that one might install.
If you already have a working installation of numpy, scipy and networkx, the easiest way to install causal-networkx is using pip
:
# doesn't work until we make an official release :p
pip install -U causal-networkx
To install the package from github, clone the repository and then cd
into the directory:
pip install -e .
Currently, selection bias representation is not implemented in the graphs and corresponding algorithms. However, I believe it is technically feasible based on the design of how we use networkx.
The roadmap currently is to integrate the next phases of causal ID, estimation, refutation and experimental design with the py-why organization and its package "dowhy".