py-why / py-why/causal-learn

How to efficiently assign forbidden edges by nodes?

Open
#142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
274
PR merge metrics
No merged PRs in 30d

Description

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))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining BackgroundKnowledge.add_forbidden_by_node and the loop over np.argwhere(partial_order == 1). Compare the current approach with the package's existing background-knowledge APIs, then verify that large matrices produce the same forbidden edges with substantially better runtime.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.