class_docstr: Main class for storing the causal model state.
docstr: Initialize data and create a causal graph instance.
  
  Assigns treatment and outcome variables.
  Also checks and finds the common causes and instruments for treatment
  and outcome.
  
  At least one of graph, common_causes or instruments must be provided. If
  none of these variables are provided, then learn_graph() can be used later.
  
  :param data: a pandas dataframe containing treatment, outcome and other variables.
  :param treatment: name of the treatment variable
  :param outcome: name of the outcome variable
  :param graph: path to DOT file containing a DAG or a string containing a DAG specification in DOT format
  :param common_causes: names of common causes of treatment and _outcome. Only used when graph is None.
  :param instruments: names of instrumental variables for the effect of treatment on outcome. Only used when graph is None.
  :param effect_modifiers: names of variables that can modify the treatment effect. If not provided, then the causal graph is used to find the effect modifiers. Estimators will return multiple different estimates based on each value of effect_modifiers.
  :param estimand_type: the type of estimand requested (currently only "nonparametric-ate" is supported). In the future, may support other specific parametric forms of identification.
  :param proceed_when_unidentifiable: does the identification proceed by ignoring potential unobserved confounders. Binary flag.
  :param missing_nodes_as_confounders: Binary flag indicating whether variables in the dataframe that are not included in the causal graph, should be  automatically included as confounder nodes.
  :param identify_vars: Variable deciding whether to compute common causes, instruments and effect modifiers while initializing the class. identify_vars should be set to False when user is providing common_causes, instruments or effect modifiers on their own(otherwise the identify_vars code can override the user provided values). Also it does not make sense if no graph is given.
  :returns: an instance of CausalModel class
docstr_tok: ["Initialize","data","and","create","a","causal","graph","instance",".","Assigns","treatment","and","outcome","variables",".","Also","checks","and","finds","the","common","causes","and","instruments","for","treatment","and","outcome",".","At","least","one","of","graph",",","common_causes","or","instruments","must","be","provided",".","If","none","of","these","variables","are","provided",",","then","learn_graph","(",")","can","be","used","later",".",":","param","data",":","a","pandas","dataframe","containing","treatment",",","outcome","and","other","variables",".",":","param","treatment",":","name","of","the","treatment","variable",":","param","outcome",":","name","of","the","outcome","variable",":","param","graph",":","path","to","DOT","file","containing","a","DAG","or","a","string","containing","a","DAG","specification","in","DOT","format",":","param","common_causes",":","names","of","common","causes","of","treatment","and","_outcome",".","Only","used","when","graph","is","None",".",":","param","instruments",":","names","of","instrumental","variables","for","the","effect","of","treatment","on","outcome",".","Only","used","when","graph","is","None",".",":","param","effect_modifiers",":","names","of","variables","that","can","modify","the","treatment","effect",".","If","not","provided",",","then","the","causal","graph","is","used","to","find","the","effect","modifiers",".","Estimators","will","return","multiple","different","estimates","based","on","each","value","of","effect_modifiers",".",":","param","estimand_type",":","the","type","of","estimand","requested","(","currently","only","``","nonparametric-ate","''","is","supported",")",".","In","the","future",",","may","support","other","specific","parametric","forms","of","identification",".",":","param","proceed_when_unidentifiable",":","does","the","identification","proceed","by","ignoring","potential","unobserved","confounders",".","Binary","flag",".",":","param","missing_nodes_as_confounders",":","Binary","flag","indicating","whether","variables","in","the","dataframe","that","are","not","included","in","the","causal","graph",",","should","be","automatically","included","as","confounder","nodes",".",":","param","identify_vars",":","Variable","deciding","whether","to","compute","common","causes",",","instruments","and","effect","modifiers","while","initializing","the","class",".","identify_vars","should","be","set","to","False","when","user","is","providing","common_causes",",","instruments","or","effect","modifiers","on","their","own","(","otherwise","the","identify_vars","code","can","override","the","user","provided","values",")",".","Also","it","does","not","make","sense","if","no","graph","is","given",".",":","returns",":","an","instance","of","CausalModel","class"]
code: def __init__(
      self,
      data,
      treatment,
      outcome,
      graph=None,
      common_causes=None,
      instruments=None,
      effect_modifiers=None,
      estimand_type="nonparametric-ate",
      proceed_when_unidentifiable=False,
      missing_nodes_as_confounders=False,
      identify_vars=False,
      **kwargs,
  ):
      """Initialize data and create a causal graph instance.
  
      Assigns treatment and outcome variables.
      Also checks and finds the common causes and instruments for treatment
      and outcome.
  
      At least one of graph, common_causes or instruments must be provided. If
      none of these variables are provided, then learn_graph() can be used later.
  
      :param data: a pandas dataframe containing treatment, outcome and other variables.
      :param treatment: name of the treatment variable
      :param outcome: name of the outcome variable
      :param graph: path to DOT file containing a DAG or a string containing a DAG specification in DOT format
      :param common_causes: names of common causes of treatment and _outcome. Only used when graph is None.
      :param instruments: names of instrumental variables for the effect of treatment on outcome. Only used when graph is None.
      :param effect_modifiers: names of variables that can modify the treatment effect. If not provided, then the causal graph is used to find the effect modifiers. Estimators will return multiple different estimates based on each value of effect_modifiers.
      :param estimand_type: the type of estimand requested (currently only "nonparametric-ate" is supported). In the future, may support other specific parametric forms of identification.
      :param proceed_when_unidentifiable: does the identification proceed by ignoring potential unobserved confounders. Binary flag.
      :param missing_nodes_as_confounders: Binary flag indicating whether variables in the dataframe that are not included in the causal graph, should be  automatically included as confounder nodes.
      :param identify_vars: Variable deciding whether to compute common causes, instruments and effect modifiers while initializing the class. identify_vars should be set to False when user is providing common_causes, instruments or effect modifiers on their own(otherwise the identify_vars code can override the user provided values). Also it does not make sense if no graph is given.
      :returns: an instance of CausalModel class
  
      """
      self._data = data
      self._treatment = parse_state(treatment)
      self._outcome = parse_state(outcome)
      self._effect_modifiers = parse_state(effect_modifiers)
      self._estimand_type = estimand_type
      self._proceed_when_unidentifiable = proceed_when_unidentifiable
      self._missing_nodes_as_confounders = missing_nodes_as_confounders
      self.logger = logging.getLogger(__name__)
      self._estimator_cache = {}
  
      if graph is None:
          self.logger.warning(
              "Causal Graph not provided. DoWhy will construct a graph based on data inputs."
          )
          self._common_causes = parse_state(common_causes)
          self._instruments = parse_state(instruments)
          if common_causes is not None and instruments is not None:
              self._graph = CausalGraph(
                  self._treatment,
                  self._outcome,
                  common_cause_names=self._common_causes,
                  instrument_names=self._instruments,
                  effect_modifier_names=self._effect_modifiers,
                  observed_node_names=self._data.columns.tolist(),
              )
          elif common_causes is not None:
              self._graph = CausalGraph(
                  self._treatment,
                  self._outcome,
                  common_cause_names=self._common_causes,
                  effect_modifier_names=self._effect_modifiers,
                  observed_node_names=self._data.columns.tolist(),
              )
          elif instruments is not None:
              self._graph = CausalGraph(
                  self._treatment,
                  self._outcome,
                  instrument_names=self._instruments,
                  effect_modifier_names=self._effect_modifiers,
                  observed_node_names=self._data.columns.tolist(),
              )
          else:
              self.logger.warning(
                  "Relevant variables to build causal graph not provided. You may want to use the learn_graph() function to construct the causal graph."
              )
              self._graph = CausalGraph(
                  self._treatment,
                  self._outcome,
                  effect_modifier_names=self._effect_modifiers,
                  observed_node_names=self._data.columns.tolist(),
              )
      else:
          self.init_graph(graph=graph, identify_vars=identify_vars)
  
      self._other_variables = kwargs
      self.summary()
  
      # Emit a `UserWarning` if there are any unobserved graph variables and
      # and log a message highlighting data variables that are not part of the graph.
      graph_variable_names = set(
          self._graph.get_all_nodes(include_unobserved=True)
      )
      data_variable_names = set(self._data.columns)
      _warn_if_unobserved_graph_variables(
          graph_variable_names=graph_variable_names,
          data_variable_names=data_variable_names,
          logger=self.logger,
      )
      _warn_if_unused_data_variables(
          graph_variable_names=graph_variable_names,
          data_variable_names=data_variable_names,
          logger=self.logger,
      )
  
imports: import logging
  import typing
  import warnings
  from itertools import combinations
  from sympy import init_printing
  import dowhy.causal_estimators
  import dowhy.causal_refuters
  import dowhy.graph_learners
  from dowhy.causal_estimator import CausalEstimate, estimate_effect
  from dowhy.causal_graph import CausalGraph
  from dowhy.causal_identifier import AutoIdentifier, BackdoorAdjustment, IDIdentifier
  from dowhy.causal_identifier.identify_effect import EstimandType
  from dowhy.causal_refuters.graph_refuter import GraphRefuter
  from dowhy.utils.api import parse_state
label_desc: Use image node_id 1 to create a new CausalModel object  with example: obj = CausalModel(data, treatment, outcome, graph, common_causes, instruments, effect_modifiers, estimand_type, proceed_when_unidentifiable, missing_nodes_as_confounders, identify_vars)