You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I would like to add background knowledge to the pc algorithm using the BackgroundKnowledge class. However, I noticed that some v-structures are orientated wrongly when using it. I provide a minimal example below, where background knowledge about a forbidden edge makes pc orient a v-structure that does not exist in the true DAG/CPDAG:
fromcausallearn.search.ConstraintBased.PCimportpcfromcausallearn.utils.PCUtils.BackgroundKnowledgeimportBackgroundKnowledgeimportnetworkxasnximportnumpyasnp# True DAG is X -> Y -> Z, true CPDAG is X - Y - Zdag=nx.DiGraph()
dag.add_edge(0, 1)
dag.add_edge(1, 2)
# Run PC without background knowledgecg_without_background_knowledge=pc(np.zeros((1,3)), 0.05, "d_separation", true_dag=dag)
nodes=cg_without_background_knowledge.G.get_nodes()
# Passes because output is X - Y - Zassertcg_without_background_knowledge.G.is_undirected_from_to(nodes[0], nodes[1])
# Passes because output is X - Y - Zassertcg_without_background_knowledge.G.is_undirected_from_to(nodes[1], nodes[2])
# Run PC with background knowledge of forbidden edge between X and Zbk=BackgroundKnowledge().add_forbidden_by_node(nodes[0], nodes[2]).add_forbidden_by_node(nodes[2], nodes[0])
cg_with_background_knowledge=pc(np.zeros((1,3)), 0.05, "d_separation", true_dag=dag, background_knowledge=bk)
nodes=cg_with_background_knowledge.G.get_nodes()
# Fails because output is X -> Y <- Zassertcg_with_background_knowledge.G.is_undirected_from_to(nodes[0], nodes[1])
# Fails because output is X -> Y <- Zassertcg_with_background_knowledge.G.is_undirected_from_to(nodes[1], nodes[2])
I would be very happy to hear some inputs from you on how to use BackgroundKnowledge in pc while ensuring that such erroneous orientations do not arise. Note, that my question is different from #171 and #219, as my issue is about orientations rather than the skeleton search. Thank you for your effort!
The text was updated successfully, but these errors were encountered:
Hi! I would like to add background knowledge to the
pc
algorithm using theBackgroundKnowledge
class. However, I noticed that some v-structures are orientated wrongly when using it. I provide a minimal example below, where background knowledge about a forbidden edge makes pc orient a v-structure that does not exist in the true DAG/CPDAG:I would be very happy to hear some inputs from you on how to use
BackgroundKnowledge
inpc
while ensuring that such erroneous orientations do not arise. Note, that my question is different from #171 and #219, as my issue is about orientations rather than the skeleton search. Thank you for your effort!The text was updated successfully, but these errors were encountered: