I have a dataset in which the columns are the variables X,Y,Z,W,A,B. I would like to evaluate $P(Y|do(X=x))$. In the package DoWhy for Python, there is the example:
import dowhy.api
import dowhy.datasets
data = dowhy.datasets.linear_dataset(beta=5,
num_common_causes=1,
num_instruments = 0,
num_samples=1000,
treatment_is_binary=True)
# data['df'] is just a regular pandas.DataFrame
data['df'].causal.do(x='v0', # name of treatment variable
variable_types={'v0': 'b', 'y': 'c', 'W0': 'c'},
outcome='y',
common_causes=['W0']).groupby('v0').mean().plot(y='y', kind='bar')
With the following description:
The do method in the causal namespace generates a random sample from $P(outcome|do(X=x))$ of the same length as your data set, and returns this outcome as a new DataFrame. You can continue to perform the usual DataFrame operations with this sample, and so you can compute statistics and create plots for causal outcomes!
I was not able to understand however how this performs the do-calculus since what I wanted was a probability distribution, as described by Pearl himself, and not a dataframe as returned by the function; nor was I able to set $X=x$ in the model, only insert the variable. So, in my example, how could I use the dowhy
package to give me $P(Y|do(X=x))$?