y0
y0 copied to clipboard
DSL to natural language
Hi @cthoyt
I am developing a syllabus for a 2 hour workshop on causal reasoning, and I want to teach the participants how read causal and counterfactual notation.
For example:
| Causal Hierarchy Level | Probabilistic notation | $Y_0$ notation | English interpretation |
|---|---|---|---|
| Observation | $$P(Cancer=true| Smoking=true)$$ |
|
Given a subpopulation of people who smoke, what is the probability that they will get cancer? |
| Action | $$P(Cancer=true| do(Smoking=true))$$ |
|
In a world where everyone is required to smoke, what is the probability that they will get cancer? |
| Imagination | $$P(Cancer_{do(Smoking=true)}=true| Cancer=false, Smoking=false))$$ |
|
Given a subpopulation of people who do not smoke and do not have cancer, what is the probability that they would get cancer in a world where I forced them to smoke? |
I wonder if we could add a method to the DSL called to_english() that converted the probabilistic expression to its english language interpretation?
I don't think this needs to be the entire DSL, but just a function that operates on a probability object, correct? Therefore, I'd suggest if you implement, then to do it as an external function outside the class definition, so it could be used like:
from y0.dsl import probability_to_english, Variable, P
cancer = Variable("cancer")
smoking = Variable("smoking")
observation = P(+cancer | +smoking)
print(probability_to_english(observation))