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

How to efficiently assign forbidden edges by nodes? #142

Open
kenneth-lee-ch opened this issue Oct 11, 2023 · 1 comment
Open

How to efficiently assign forbidden edges by nodes? #142

kenneth-lee-ch opened this issue Oct 11, 2023 · 1 comment

Comments

@kenneth-lee-ch
Copy link
Contributor

I currently use the following code to add forbidden edges, but it's taking so long when the adjacency matrix (in the example below named partial_order) is large for adding background knowledge, is there any way to make this more efficient in the causal-learn package?

import numpy as np
nodenames = final_df.columns
bk= BackgroundKnowledge()
position_matrix = np.argwhere(partial_order == 1)
for coordinate in position_matrix:
   x, y = coordinate 
   node1 = nodenames[x]
   node2 = nodenames[y]
   bk.add_forbidden_by_node(GraphNode(node2), GraphNode(node1))
@kunwuz
Copy link
Collaborator

kunwuz commented Oct 12, 2023

Hi, this improved version of BackGroundKnowledge might be helpful, which is proposed and implemented by @verae98. Also a related issue: #90

Not sure if the solution is 100% free of issues, but that could be great to try. Let me know if you have any better ideas, or would like to contribute perhaps by incorporating that solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants