diff --git a/causallearn/search/ConstraintBased/FCI.py b/causallearn/search/ConstraintBased/FCI.py index 8a936c8c..cae3d4d8 100644 --- a/causallearn/search/ConstraintBased/FCI.py +++ b/causallearn/search/ConstraintBased/FCI.py @@ -829,7 +829,8 @@ def _contains_all(set_a: Set[Node], set_b: Set[Node]): def fci(dataset: ndarray, independence_test_method: str=fisherz, alpha: float = 0.05, depth: int = -1, - max_path_length: int = -1, verbose: bool = False, background_knowledge: BackgroundKnowledge | None = None, show_progress: bool = True, + max_path_length: int = -1, verbose: bool = False, background_knowledge: BackgroundKnowledge | None = None, + show_progress: bool = True, node_names = None, **kwargs) -> Tuple[Graph, List[Edge]]: """ Perform Fast Causal Inference (FCI) algorithm for causal discovery @@ -884,8 +885,10 @@ def fci(dataset: ndarray, independence_test_method: str=fisherz, alpha: float = nodes = [] + if node_names is None: + node_names = [f"X{i + 1}" for i in range(dataset.shape[1])] for i in range(dataset.shape[1]): - node = GraphNode(f"X{i + 1}") + node = GraphNode(node_names[i]) node.add_attribute("id", i) nodes.append(node) diff --git a/causallearn/utils/PCUtils/BackgroundKnowledge.py b/causallearn/utils/PCUtils/BackgroundKnowledge.py index 4c6bca0d..19248d48 100644 --- a/causallearn/utils/PCUtils/BackgroundKnowledge.py +++ b/causallearn/utils/PCUtils/BackgroundKnowledge.py @@ -165,7 +165,7 @@ def is_forbidden(self, node1: Node, node2: Node) -> bool: # then check in tier_map if self.tier_value_map.keys().__contains__(node1) and self.tier_value_map.keys().__contains__(node2): - if self.tier_value_map.get(node1) >= self.tier_value_map.get(node2): + if self.tier_value_map.get(node1) > self.tier_value_map.get(node2): # Allow orientation within the same tier return True return False