GithubHelp home page GithubHelp logo

Comments (3)

jdramsey avatar jdramsey commented on September 26, 2024 1

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.

kenneth-lee-ch avatar kenneth-lee-ch commented on September 26, 2024

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.

kenneth-lee-ch avatar kenneth-lee-ch commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.