Comments (3)
This is interesting, if I may interject. First of all, this isn't a legal PAG; the tail endpoints at X4 shouldn't be there in a PAG, or at least not both of them, so maybe this was obtained using background knowledge...? Second, the recursion error doesn't occur in Tetrad, even though it's also using a reachability method. Third, for a latent variable model, the right test is m-separation, not d-separation, but you should laugh at anyone who says that since they are the same algorithm (just differently interpreted).
from causal-learn.
I found a recursive behavior in is_dconnected_to
. Suppose we have the following graph D
:
X4->X1 o-o X2<->X5 ; X4->X2
If you call is_dconnected_to(X1, X5, [], D)
, this will make the function to loop forever.
from causal-learn.
I currently add a list prevent_recursive_ls
to the function is_dconnected_to
to bypass the pair of edge and node that have been previously visited as a workaround to mitigate the issue as shown below:
def is_dconnected_to(node1: Node, node2: Node, z: List[Node], graph: Graph):
if node1 == node2:
return True
edgenode_deque = deque([])
prevent_recursive_ls = [] # MODIFIED HERE
for edge in graph.get_node_edges(node1):
if edge.get_distal_node(node1) == node2:
return True
edgenode_deque.append((edge, node1))
while len(edgenode_deque) > 0:
edge, node_a = edgenode_deque.pop()
node_b = edge.get_distal_node(node_a)
for edge2 in graph.get_node_edges(node_b):
node_c = edge2.get_distal_node(node_b)
# node_a - node_b - node_c
if node_c == node_a:
continue
if reachable(edge, edge2, node_a, z, graph):
if node_c == node2:
return True
else:
if (edge2, node_b) not in prevent_recursive_ls: # MODIFIED HERE
edgenode_deque.append((edge2, node_b))
prevent_recursive_ls.append((edge2, node_b)) # MODIFIED HERE
return False
from causal-learn.
Related Issues (20)
- Using FCI with true graph known, specifying latent variables and background knowledge? HOT 8
- does this codebase support some recent causal discovery methods like, notears, dag-gnn,and so on HOT 2
- A potential Bug in GES.py HOT 1
- Null Hypothesis in Conditoinal Independence Tests HOT 2
- How to construct a causallearn.graph.Graph object from an numpy array? HOT 2
- Boostrap Utilities HOT 1
- Background knowledge not used correctly? HOT 1
- Implementation for CCI? HOT 1
- How to estimate the causal effect? HOT 1
- Different results with Tetrad and causal-learn implementations. HOT 6
- numpy version HOT 1
- Understanding the FCI outputs (graph vs. printed edges) HOT 3
- Handling Data with Interventions HOT 4
- array must not contain infs or NaNs HOT 2
- use of deprecated `np.mat` HOT 3
- IndexError: tuple index out of range - From LocalScoreFunction.py HOT 1
- Key error FCI HOT 1
- Causal Discovery Algorithms For Time Series Data HOT 2
- Implementation of DAGMA
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from causal-learn.