Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a feature that allows exporting the CausalNex generated graphs to DAGitty? #124

Closed
ukm5 opened this issue Aug 2, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ukm5
Copy link

ukm5 commented Aug 2, 2021

Description

The data generated graphs in CausalNex using NOTEARS algorithm is a good place to start working on novel causal inference problems. However, as the problem at hand like in my field of Healthcare gets complicated and subjective, it is often necessary to modify the DAGs using the expertise of clinical experts and doctors. This requires moving the graph from a code-based tool like CausalNex or Networkx to a GUI based tool like DAGitty. A function to export the graph to a format that is DAGitty friendly would allow easier collaboration and moving of graphs between tools.

Context

This would facilitate better collaboration across engineers and clinical experts in my field. I am certain this would be a valuable asset to other fields where a data-generated graph is often first step towards developing a Bayesian Network.

Possible Implementation

A function that could be called on the Structured Graph class that output the graph in code format that is in a DAG format and could be copied and pasted in an email or chat and sent to the clinical collaborators. Also, a similar format that could be imported back into CausalNex.

@oentaryorj oentaryorj added the enhancement New feature or request label Aug 3, 2021
@oentaryorj
Copy link
Contributor

oentaryorj commented Aug 27, 2021

Thanks for raising this. Currently, providing an interoperability support for DAGitty is not part of our roadmap. However, assuming that DAGitty supports dot language (cf. this manual), we can easily export a StructureModel object into a .dot file using write_dot function from networkx. Below is a simple example of how this can be done:

import networkx as nx

from causalnex.structure import StructureModel

# Create a model
sm = StructureModel()
sm.add_edges_from([
    ('A', 'C'),
    ('B', 'C')
])
# Save the model into pygraphviz's dot format
nx.drawing.nx_pydot.write_dot(sm, 'graph.dot')

Please let us know if this helps. Thanks again.

@oentaryorj
Copy link
Contributor

Closing this for now. Feel free to re-open the issue should you still find some difficulties.

@oentaryorj oentaryorj self-assigned this Sep 7, 2021
@qbphilip qbphilip mentioned this issue Nov 10, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants