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
7.1k stars 934 forks source link

The direction of the graph's edges seems not right #859

Open lx2m17 opened 1 year ago

lx2m17 commented 1 year ago

Hi guys, I found a wrong place in the example notebook code, the direction of the edges seems put wrong place in the for loops line, can anyone check and fix it? (File path: docs/source/example_notebooks/dowhy_causal_discovery_example.ipynb)

image

amit-sharma commented 1 year ago

Thanks for spotting this @lx2m17. Would you like to correct this and issue a pull request?

rahulbshrestha commented 6 months ago

Hey, I checked out this bug and figured out it is not an actual issue.

When I run the make_graph function from the image above for the given adjacency matrix, the causal graph is:

graph_dot = make_graph(model.adjacency_matrix_, labels=labels)

image

And here's the result when running make_dot from causallearn with the same adjacency matrix:

from causallearn.search.FCMBased.lingam.utils import make_dot
make_dot(model.adjacency_matrix_, labels=labels)
image

Both of them are the same i.e the edges are in the correct direction.

rahulbshrestha commented 6 months ago

Side note: I found the use of variable confusing at this one part since its used for both Lingam and CausalModel so I've renamed one of it and created a PR.