3333 </a>
3434</p >
3535
36- ` y0 ` (pronounced "why not?") is Python code for causal inferencing .
36+ ` y0 ` (pronounced "why not?") is Python code for causal inference .
3737
3838## 💪 Getting Started
3939
40- > TODO show in a very small amount of space the ** MOST** useful thing your package can do.
41- Make it as short as possible! You have an entire set of docs for later.
40+ ### Representing Probability Expressions
41+
42+ ` y0 ` has a fully featured internal domain specific language for representing
43+ probability expressions:
44+
45+ ``` python
46+ from y0.dsl import P, A, B
47+
48+ # The probability of A given B
49+ expr_1 = P(A | B)
50+
51+ # The probability of A given not B
52+ expr_2 = P(A | ~ B)
53+
54+ # The joint probability of A and B
55+ expr_3 = P(A, B)
56+ ```
57+
58+ It can also be used to manipulate expressions:
59+
60+ ``` python
61+ from y0.dsl import P, A, B, Sum
62+
63+ P(A, B).marginalize(A) == P(A, B) / Sum[A](P(A, B))
64+ ```
65+
66+ DSL objects can be converted into strings with ` str() ` and parsed back
67+ using ` y0.parser.parse_y0() ` .
68+
69+ A full demo of the DSL can be found in this
70+ [ Jupyter Notebook] ( https://github.com/y0-causal-inference/y0/blob/main/notebooks/DSL%20Demo.ipynb )
71+
72+ ### Representing Causality
73+
74+ ` y0 ` has a notion of acyclic directed mixed graphs built on top of
75+ ` networkx ` that can be used to model causality:
76+
77+ ``` python
78+ from y0.graph import NxMixedGraph
79+ from y0.dsl import X, Y, Z1, Z2
80+
81+ # Example from:
82+ # J. Pearl and D. Mackenzie (2018)
83+ # The Book of Why: The New Science of Cause and Effect.
84+ # Basic Books, p. 240.
85+ napkin = NxMixedGraph.from_edges(
86+ directed = [
87+ (Z2, Z1),
88+ (Z1, X),
89+ (X, Y),
90+ ],
91+ undirected = [
92+ (Z2, X),
93+ (Z2, Y),
94+ ],
95+ )
96+ ```
97+
98+ ` y0 ` has many pre-written examples in ` y0.examples ` from Pearl, Shpitser,
99+ Bareinboim, and others.
100+
101+ ### do Calculus
102+
103+ ` y0 ` provides _ actual_ implementations of many algorithms that have remained
104+ unimplemented for the last 15 years of publications including:
105+
106+ | Algorithm | Reference |
107+ | -----------| -----------------------------------------------------------------------------|
108+ | ID | [ Shpitser and Pearl, 2006] ( https://dl.acm.org/doi/10.5555/1597348.1597382 ) |
109+ | IDC | [ Shpitser and Pearl, 2008] ( https://www.jmlr.org/papers/v9/shpitser08a.html ) |
110+
111+ Apply an algorithm to an ADMG and a causal query to generate an estimand
112+ represented in the DSL like:
113+
114+ ``` python
115+ from y0.dsl import P, X, Y
116+ from y0.examples import napkin
117+ from y0.algorithm.identify import Identification, identify
118+
119+ # TODO after ID* and IDC* are done, we'll update this interface
120+ query = Identification.from_expression(graph = napkin, query = P(Y @ X))
121+ estimand = identify(query)
122+ assert estimand == P(Y @ X)
123+ ```
42124
43125## ⬇️ Installation
44126
@@ -55,28 +137,20 @@ The most recent code and data can be installed directly from GitHub with:
55137$ pip install git+https://github.com/y0-causal-inference/y0.git
56138```
57139
58- To install in development mode, use the following:
59-
60- ``` bash
61- $ git clone git+https://github.com/y0-causal-inference/y0.git
62- $ cd y0
63- $ pip install -e .
64- ```
65-
66- ## ⚖️ License
67-
68- The code in this package is licensed under the [ BSD-3-Clause
69- license] ( https://github.com/y0-causal-inference/y0/blob/master/LICENSE ) .
70-
71- ## 🙏 Contributing
140+ ## 👐 Contributing
72141
73142Contributions, whether filing an issue, making a pull request, or forking, are appreciated. See
74143[ CONTRIBUTING.rst] ( https://github.com/y0-causal-inference/y0/blob/master/CONTRIBUTING.rst ) for more information on getting
75144involved.
76145
77- ## Acknowledgements
146+ 👋 Attribution
147+
148+ ### ⚖️ License
149+
150+ The code in this package is licensed under the [ BSD-3-Clause
151+ license] ( https://github.com/y0-causal-inference/y0/blob/master/LICENSE ) .
78152
79- ### Supporters
153+ ### 🙏 Supporters
80154
81155This project has been supported by several organizations (in alphabetical order):
82156
@@ -100,8 +174,21 @@ This package was created with [@audreyfeldroy](https://github.com/audreyfeldroy)
100174
101175## 🛠️ Development
102176
177+ <details >
178+ <summary >See developer instructions</summary >
179+
103180The final section of the README is for if you want to get involved by making a code contribution.
104181
182+ ### Developer Installation
183+
184+ To install in development mode, use the following:
185+
186+ ``` bash
187+ $ git clone git+https://github.com/y0-causal-inference/y0.git
188+ $ cd y0
189+ $ pip install -e .
190+ ```
191+
105192### ❓ Testing
106193
107194After cloning the repository and installing ` tox ` with ` pip install tox ` , the unit tests in the ` tests/ ` folder can be
@@ -133,3 +220,5 @@ This script does the following:
1332204 . Push to GitHub. You'll need to make a release going with the commit where the version was bumped.
1342215 . Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can
135222 use ` tox -e bumpversion minor ` after.
223+
224+ </details >
0 commit comments