py-why / dowhy

DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.
https://www.pywhy.org/dowhy
MIT License
6.88k stars 916 forks source link

Remove use of CausalModel from notebooks and test files #1220

Open rahulbshrestha opened 4 days ago

rahulbshrestha commented 4 days ago

This PR addresses this issue. Since CausalModel is deprecated, it should be removed from tutorials and test cases.

rahulbshrestha commented 4 days ago

@bloebp I did it for one file, could you please let me know if this is fine?

The only thing is when I tried to compare the variables for identify_effect for before and after, it seems to be different? e.g if I do

from dowhy.causal_identifier import identify_effect
identification_1 = identify_effect(nx_graph, action_nodes=causes, outcome_nodes=outcomes, observed_nodes=list(graph.get_all_nodes(include_unobserved=False)))

model = CausalModel(df, causes, outcomes, common_causes=common_causes),
nx_graph = model._graph._graph
identification_2 = model.identify_effect(proceed_when_unidentifiable=True)

identification_1 == identification_2

The output is False, any idea why? I can dig into this a bit more too.

amit-sharma commented 1 day ago

thanks for starting this @rahulbshrestha In what way does the two identification objects differ? One difference I see is that you may need to use nx_graph as input to CausalModel too (causalmodel accepts a nx graph as graph)

rahulbshrestha commented 15 hours ago

@amit-sharma I investigated this a bit more and found the difference between both:

identification_1.identifierreturns None

identification_2.identifier returns <dowhy.causal_identifier.auto_identifier.AutoIdentifier at 0x2876e2690>

Is this an intended design choice or a bug?