Skip to content

Commit ed4cb7f

Browse files
authored
[ENH] Consistent extension sampling of CPDAG, PDAG and DAG (#102)
* Add sampling a consistent extension of a CPDAG/PDAG * Also enable conversion from DAG to CPDAG --------- Signed-off-by: Adam Li <adam2392@gmail.com>
1 parent 9c6a556 commit ed4cb7f

File tree

13 files changed

+630
-7
lines changed

13 files changed

+630
-7
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ jobs:
158158
if: "matrix.os == 'ubuntu'"
159159
shell: bash
160160
run: |
161+
sudo apt-get update
161162
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
162163
163164
- name: Run pytest # headless via Xvfb on linux

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ To install the package from github, clone the repository and then `cd` into the
7676

7777
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.
7878

79-
See our [contributing guide](https://github.com/py-why/pywhy-graphs/CONTRIBUTING.md) for more details.
79+
See our [contributing guide](https://github.com/py-why/pywhy-graphs/blob/main/CONTRIBUTING.md) for more details.
8080

8181
# Citing
8282

doc/api.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ causal graph operations.
6464
is_semi_directed_path
6565
all_semi_directed_paths
6666

67+
:mod:`pywhy_graphs.algorithms`: Algorithms for dealing with CPDAGs
68+
==================================================================
69+
With Markov equivalence classes of DAGs in a Markovian SCM setting, we obtain
70+
a potentially directed acyclic graph (PDAG), which may be completed (CPDAG).
71+
We may want to generate a consistent DAG extension (i.e. Markov equivalent) of a CPDAG
72+
then we may use some of the algorithms described here. Or perhaps one may want to
73+
convert a DAG to its corresponding CPDAG.
74+
75+
.. currentmodule:: pywhy_graphs.algorithms
76+
77+
.. autosummary::
78+
:toctree: generated/
79+
80+
pdag_to_dag
81+
dag_to_cpdag
82+
pdag_to_cpdag
83+
order_edges
84+
label_edges
85+
86+
6787
Conversions between other package's causal graphs
6888
=================================================
6989
Other packages, such as `causal-learn <https://github.com/cmu-phil/causal-learn>`_,

doc/installation.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Installation
22
============
33

4-
**pywhy-graphs** supports Python >= 3.8.
4+
**pywhy-graphs** closely follows the NetworkX dependencies and thus supports Python >= 3.9.
55

6-
## Installing with ``pip``
6+
Installing with ``pip``
7+
-----------------------
78

89
**pywhy-graphs** is available [on PyPI](https://pypi.org/project/pywhy-graphs/). Just run
910

@@ -12,7 +13,8 @@ Installation
1213
# or if you use poetry which is recommended
1314
poetry add pywhy-graphs
1415

15-
## Installing from source
16+
Installing from source
17+
----------------------
1618

1719
To install **pywhy-graphs** from source, first clone [the repository](https://github.com/py-why/pywhy-graphs):
1820

doc/references.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ @article{bareinboim_causal_2016
1717
pages = {7345--7352}
1818
}
1919

20+
@article{chickering2002learning,
21+
title = {Learning equivalence classes of Bayesian-network structures},
22+
author = {Chickering, David Maxwell},
23+
journal = {The Journal of Machine Learning Research},
24+
volume = {2},
25+
pages = {445--498},
26+
year = {2002},
27+
publisher = {JMLR}
28+
}
29+
2030
@article{Colombo2012,
2131
author = {Diego Colombo and Marloes H. Maathuis and Markus Kalisch and Thomas S. Richardson},
2232
title = {{Learning high-dimensional directed acyclic graphs with latent and selection variables}},

doc/whats_new/v0.2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Changelog
3030
- |Feature| Implement and test functions to convert a PAG to MAG, by `Aryan Roy`_ (:pr:`93`)
3131
- |API| Remove support for Python 3.8 by `Adam Li`_ (:pr:`99`)
3232
- |Feature| Implement a suite of functions for finding and checking semi-directed paths on a mixed-edge graph, by `Adam Li`_ (:pr:`101`)
33+
- |Feature| Implement functions for converting between a DAG and PDAG and CPDAG for generating consistent extensions of a CPDAG for example. These functions are :func:`pywhy_graphs.algorithms.pdag_to_cpdag`, :func:`pywhy_graphs.algorithms.pdag_to_dag` and :func:`pywhy_graphs.algorithms.dag_to_cpdag`, by `Adam Li`_ (:pr:`102`)
3334

3435
Code and Documentation Contributors
3536
-----------------------------------

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude_dirs = ["tests"]
77

88
[tool.black]
99
line-length = 100
10-
target-version = ['py38']
10+
target-version = ['py39']
1111
include = '\.pyi?$'
1212
extend-exclude = '''
1313
(
@@ -102,10 +102,10 @@ readme = "README.md"
102102
classifiers = [
103103
'Development Status :: 4 - Beta',
104104
'License :: OSI Approved :: MIT License',
105-
'Programming Language :: Python :: 3.8',
106105
'Programming Language :: Python :: 3.9',
107106
'Programming Language :: Python :: 3.10',
108-
'Programming Language :: Python :: 3.11'
107+
'Programming Language :: Python :: 3.11',
108+
'Programming Language :: Python :: 3.12'
109109
]
110110
keywords = ['causality', 'graphs', 'causal-inference', 'graphical-model']
111111

pywhy_graphs/algorithms/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from .cpdag import * # noqa: F403
12
from .cyclic import * # noqa: F403
23
from .generic import * # noqa: F403
34
from .multidomain import * # noqa: F403

0 commit comments

Comments
 (0)