dowhy icon indicating copy to clipboard operation
dowhy copied to clipboard

DoSampler: Fails when you Add a Graph to the Causal Model

Open cschiri opened this issue 5 years ago • 1 comments

Regards,

I noticed something that I do not understand at this stage:

The DoSampler works fine when you do not add a graph to your CausalModel object, but fails when you add a graph. To elaborate:

This model object, which I will name "a" and does not have a graph. It doesn't give you problems:

# Define causes, Outcomes and Common Causes
causes = ['v']
outcomes = ['y']
common_causes = ['x1',
                 'x4',
                 'x5',
                 'x6']

model = CausalModel(df, 
                    causes,
                    outcomes,
                    common_causes=common_causes)

This model object, which I will name "b", has a graph as an input. It gives you problems;

# Define causes, Outcomes and Common Causes
causes = ['v']
outcomes = ['y']
common_causes = ['x1',
                 'x4',
                 'x5',
                 'x6']
graph = "digraph {x1 -> y;v -> y;x6 -> y;x6 -> x5;x4 -> x5;}"

model = CausalModel(df, 
                    causes,
                    outcomes,
                    common_causes=common_causes,
                    graph=graph)

To be specific the model object formulation named "b" gives you problems when you try to create the interventional dataframe as follows:

interventional_df = sampler.do_sample(None)

It gives you the following "value error":

ValueError: Found array with 0 feature(s) (shape=(46, 0)) while a minimum of 1 is required.

Why is this so?

Best -C.

cschiri avatar Nov 11 '19 06:11 cschiri

@cschiri In the second example if x1, x4,x5,x6 are common causes, shouldn't they influence both v and y in the causal graph?

Tanmay-Kulkarni101 avatar May 29 '20 05:05 Tanmay-Kulkarni101