py-why / causal-learn

Causal Discovery in Python. It also includes (conditional) independence tests and score functions.
https://causal-learn.readthedocs.io/en/latest/
MIT License
1.04k stars 174 forks source link

Understanding the FCI outputs (graph vs. printed edges) #180

Open mozolcer opened 2 months ago

mozolcer commented 2 months ago

I apologize if this is a naive question, but I want to ask. In my PAG resulting from FCI, I see that X4 --> X5 relationship is observed in the graph. But, the printed relationships between edges and nodes as a result of running FCI algorithm, does not include the same path that is in the PAG graph. How should I interpret this? Thank you.

from causallearn.search.ConstraintBased.FCI import fci
from causallearn.utils.GraphUtils import GraphUtils
g, edges = fci(df.to_numpy())
pdy = GraphUtils.to_pydot(g )

Edit: Updated PAG, g.graph, and edges. This time FCI outputs X1 --> X5 and X2 --> X3. But in the PAG, we can see X4 --> X5, X2 --> X5, X6 --> X5, etc. as well.

Screenshot 2024-04-28 223323

g.graph:

image

edges:

image
kunwuz commented 2 months ago

Thanks for your interest. Could you please share the complete g.graph and edges?

mozolcer commented 2 months ago

Thanks for your interest. Could you please share the complete g.graph and edges?

I couldn't reproduce the same the graph, so I updated the post with the new graph, corresponding g.graph and edges. Thank you

kunwuz commented 2 months ago

Thanks. It seems that the returned graph is consistent with the visualization. Maybe the printed information is not complete, let us check this soon.