class_docstr: Implements methods for finding optimal (efficient) backdoor sets.
class_docstr_tok: ["Implements","methods","for","finding","optimal","(","efficient",")","backdoor","sets","."]
docstr: :param graph: nx.DiGraph
      A causal graph.
  :param costs: list
      A list with non-negative costs associated with variables in the graph. Only used
      for estimatand_type='non-parametric-ate' and method_name='efficient-mincost-adjustment'. If
      not costs are provided by the user, and method_name='efficient-mincost-adjustment', costs
      are assumed to be equal to one for all variables in the graph. The structure of the list should
      be of the form [(node, {"cost": x}) for node in nodes].
  :param conditional_node_names: list
      A list with variables that are used to determine treatment. If none are
      provided, it is assumed that the intervention sets the treatment to a constant.
docstr_tok: [":","param","graph",":","nx.DiGraph","A","causal","graph",".",":","param","costs",":","list","A","list","with","non-negative","costs","associated","with","variables","in","the","graph",".","Only","used","for","estimatand_type='non-parametric-ate","'","and","method_name='efficient-mincost-adjustment","'",".","If","not","costs","are","provided","by","the","user",",","and","method_name='efficient-mincost-adjustment","'",",","costs","are","assumed","to","be","equal","to","one","for","all","variables","in","the","graph",".","The","structure","of","the","list","should","be","of","the","form","[","(","node",",","{","``","cost","''",":","x","}",")","for","node","in","nodes","]",".",":","param","conditional_node_names",":","list","A","list","with","variables","that","are","used","to","determine","treatment",".","If","none","are","provided",",","it","is","assumed","that","the","intervention","sets","the","treatment","to","a","constant","."]
code: def __init__(
      self,
      graph: nx.DiGraph,
      action_nodes: List[str],
      outcome_nodes: List[str],
      observed_nodes: List[str],
      conditional_node_names=None,
      costs=None,
  ):
      """
      :param graph: nx.DiGraph
          A causal graph.
      :param costs: list
          A list with non-negative costs associated with variables in the graph. Only used
          for estimatand_type='non-parametric-ate' and method_name='efficient-mincost-adjustment'. If
          not costs are provided by the user, and method_name='efficient-mincost-adjustment', costs
          are assumed to be equal to one for all variables in the graph. The structure of the list should
          be of the form [(node, {"cost": x}) for node in nodes].
      :param conditional_node_names: list
          A list with variables that are used to determine treatment. If none are
          provided, it is assumed that the intervention sets the treatment to a constant.
      """
      assert (
          len(action_nodes) == 1
      ), "The methods for computing efficient backdoor sets are only valid for one dimensional treatments"
      assert (
          len(outcome_nodes) == 1
      ), "The methods for computing efficient backdoor sets are only valid for one dimensional outcomes"
      self.graph = graph
      if costs is None:
          # If no costs are passed, use uniform costs
          costs = [(node, {"cost": 1}) for node in self.graph.nodes]
      assert all(
          [tup["cost"] > 0 for _, tup in costs]
      ), "All costs must be positive"
      self.graph.add_nodes_from(costs)
      self.observed_nodes = set(
          [
              node
              for node in self.graph.nodes
              if node in set(observed_nodes)
          ]
      )
      if conditional_node_names is None:
          conditional_node_names = []
      assert set(conditional_node_names).issubset(
          self.observed_nodes
      ), "Some conditional variables are not marked as observed"
      self.conditional_node_names = conditional_node_names
  
      self.treatment_name = action_nodes[0]
      self.outcome_name = outcome_nodes[0]
  
file_path: dowhy/dowhy/causal_identifier/efficient_backdoor.py
imports: from typing import List
  import networkx
  import numpy
label_desc: Use image node_id 1 to create a new EfficientBackdoor object  with example: obj = EfficientBackdoor(graph, action_nodes, outcome_nodes, observed_nodes, conditional_node_names, costs)