Skip to main content

Code style: black CircleCI unit-tests Checked with mypy codecov

PyWhy-Graphs

pywhy-graphs is a Python graph library that extends networkx with the notion of a MixedEdgeGraph to implement a light-weight API for causal graphical structures that contain mixed-edges and contain causal graph traversal algorithms.

Note: The API is subject to change without deprecation cycles due to the current work-in-progress MixedEdgeGraph class in networkx. For more information, follow the PR at https://github.com/networkx/networkx/pull/5947

Why?

Representation of causal graphical models in Python are severely lacking.

PyWhy-Graphs implements a graphical API layer for ADMG, CPDAG and PAG. For causal DAGs, we recommend using the networkx.DiGraph class and ensuring acylicity via networkx.is_directed_acyclic_graph function.

Existing packages that aim to represent causal graphs either break from the networkX API, or only implement a subset of the relevant causal graphs. By keeping in-line with the robust NetworkX API, we aim to ensure a consistent user experience and a gentle introduction to causal graphical models. A MixedEdgeGraph instance is a composition of networkx graphs and has a similar API, with the additional notion of an "edge type", which specifies what edge type subgraph any function should operate over. For example:

# adds a directed edge from x to y
G.add_edge('x', 'y', edge_type='directed')

# adds a bidirected edge from x to y
G.add_edge('x', 'y', edge_type='bidirected')

Moreover, sampling from causal models is non-trivial, but a requirement for benchmarking many causal algorithms in discovery, ID, estimation and more. We aim to provide simulation modules that are easily connected with causal graphs to provide a simple robust API for modeling causal graphs and then simulating data.

Documentation

See the development version documentation.

Or see stable version documentation

Installation

Installation is best done via pip or conda. For developers, they can also install from source using pip. See installation page for full details.

Dependencies

We aim to provide a very light-weight dependency structure. Minimally, pywhy-graphs requires:

* Python (>=3.8)
* numpy
* scipy
* networkx

Additional functionality may be required when running unit-tests and documentation.

User Installation

If you already have a working installation of numpy, scipy and networkx, the easiest way to install pywhy-graphs is using pip:

# doesn't work until we make an official release :p
pip install -U pywhy-graphs

To install the package from github, clone the repository and then cd into the directory. You can then use poetry to install:

poetry install

# for vizualizing graph functionality
poetry install --extras viz

# if you would like an editable install of dodiscover for dev purposes
pip install -e .

pip install https://api.github.com/repos/py-why/pywhy-graphs/zipball/main

Contributing

Pywhy-Graphs is always looking for new contributors to help make the package better, whether it is algorithms, documentation, examples of graph usage, and more! Contributing to Pywhy-Graphs will be rewarding because you will contribute to a much needed package for causal inference.

See our contributing guide for more details.

Metadata

Release files for pywhy-graphs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywhy-graphs 0.1.0
File Size Uploaded
pywhy_graphs-0.1.0.tar.gz 106.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pywhy-graphs 0.1.0
File Interpreter ABI Platform
pywhy_graphs-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 245.2 kB

Release files / pywhy_graphs-0.1.0.tar.gz

Download URL pywhy_graphs-0.1.0.tar.gz
Size 106.4 kB
Tags Source
SHA-256 checksum
How to use checksums
175107f9dce19aba21ed962bc0cf5ebfec55528dee790d0cf89be1e905c5cb2c
BLAKE2b-256 checksum
How to use checksums
232858a207ec5df8fc8515cffc49c9512a0803e8cbd1703888c76221133a7439
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / pywhy_graphs-0.1.0-py3-none-any.whl

Download URL pywhy_graphs-0.1.0-py3-none-any.whl
Size 138.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7957bed5dbce6619712cad174b922b9f793de2e641d2aa6d7b71a780302620c
BLAKE2b-256 checksum
How to use checksums
a07861bb6bc594d616b98220efad9f25231d7915d562e12d431d215cef4fecfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page