Skip to content

Error in the tutorial of "Finding optimal adjustment sets" #1360

@NianzuMa

Description

@NianzuMa

Describe the bug
The following error appears using DoWhy 0.10.1, since the URL of tutorial of "Finding optimal adjustment sets" is for v0.10.1.

I am following the tutorial of Finding optimal adjustment sets and try to reproduce the result.

I found that this tutorial might not be updated along with the changes of the DoWhy code.
The example code reports error.

There are the some issues of the example code:

  1. When I run the following code, it report the following error message:

code:

ident_eff = AutoIdentifier(
    estimand_type=EstimandType.NONPARAMETRIC_ATE,
    backdoor_adjustment=BackdoorAdjustment.BACKDOOR_EFFICIENT,
)
print(
    ident_eff.identify_effect(
        graph=G, treatment_name=treatment_name, outcome_name=outcome_name, conditional_node_names=conditional_node_names
    )
)

Error message:

Traceback (most recent call last):
  File "/home/server/user1/Bayesian_Network_Causal_Effect_Estimation_Methods/3_DoWhy/DoWhy_get_conditioning_set/v_0-10_1.py", line 72, in <module>
    ident_eff.identify_effect(
  File "/users/7/user1/anaconda3/envs/dowhy_0_10_1/lib/python3.11/site-packages/dowhy/causal_identifier/auto_identifier.py", line 92, in identify_effect
    estimand = identify_effect_auto(
               ^^^^^^^^^^^^^^^^^^^^^
  File "/users/7/user1/anaconda3/envs/dowhy_0_10_1/lib/python3.11/site-packages/dowhy/causal_identifier/auto_identifier.py", line 168, in identify_effect_auto
    return identify_ate_effect(
           ^^^^^^^^^^^^^^^^^^^^
  File "/users/7/user1/anaconda3/envs/dowhy_0_10_1/lib/python3.11/site-packages/dowhy/causal_identifier/auto_identifier.py", line 258, in identify_ate_effect
    frontdoor_variables_names = identify_frontdoor(graph, treatment_name, outcome_name)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/7/user1/anaconda3/envs/dowhy_0_10_1/lib/python3.11/site-packages/dowhy/causal_identifier/auto_identifier.py", line 767, in identify_frontdoor
    cond1 = graph.check_valid_frontdoor_set(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/7/user1/anaconda3/envs/dowhy_0_10_1/lib/python3.11/site-packages/dowhy/causal_graph.py", line 461, in check_valid_frontdoor_set
    dseparated = nx.algorithms.d_separated(new_graph, set(nodes1), set(nodes2), set(candidate_nodes))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'networkx.algorithms' has no attribute 'd_separated'. Did you mean: 'd_separation'?
  1. Another theoretical question:

I have an discrete network, all nodes are variables with discrete data.

I use the following method to construct the network:

for node_name in node_name_list:
    has_parent = bool(list(networkx_directed_graph.predecessors(node_name)))
    if not has_parent:
        causal_model.set_causal_mechanism(node_name, gcm.EmpiricalDistribution())
    else:
        causal_model.set_causal_mechanism(node_name, gcm.ClassifierFCM(gcm.ml.create_logistic_regression_classifier()))
    #endif
#endfor

Following the tutorial of "Finding optimal adjustment sets",
Does the "optimal backdoor set" the features used by logistic regression to build classifier?

Thank you very much for your answer.

Steps to reproduce the behavior
Follow the code of the first example

Version information:

  • DoWhy version 0.10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions