class_docstr: This is an inference class for performing Causal Inference over Bayesian
  Networks or Structural Equation Models.
  
  Parameters
  ----------
  model: pgmpy.base.DAG | pgmpy.models.BayesianNetwork
      The model that we'll perform inference over.
  
  set_nodes: list[node:str] or None
      A list (or set/tuple) of nodes in the Bayesian Network which have been
      set to a specific value per the do-operator.
  
  Examples
  --------
  Create a small Bayesian Network.
  
  >>> from pgmpy.models import BayesianNetwork
  >>> game = BayesianNetwork([('X', 'A'),
  ...                         ('A', 'Y'),
  ...                         ('A', 'B')])
  
  Load the graph into the CausalInference object to make causal queries.
  
  >>> from pgmpy.inference.CausalInference import CausalInference
  >>> inference = CausalInference(game)
  >>> inference.get_all_backdoor_adjustment_sets(X="X", Y="Y")
  >>> inference.get_all_frontdoor_adjustment_sets(X="X", Y="Y")
  
  References
  ----------
  'Causality: Models, Reasoning, and Inference' - Judea Pearl (2000)
class_docstr_tok: ["This","is","an","inference","class","for","performing","Causal","Inference","over","Bayesian","Networks","or","Structural","Equation","Models",".","Parameters","--","--","--","--","--","model",":","pgmpy.base.DAG","|","pgmpy.models.BayesianNetwork","The","model","that","we","'ll","perform","inference","over",".","set_nodes",":","list","[","node",":","str","]","or","None","A","list","(","or","set\/tuple",")","of","nodes","in","the","Bayesian","Network","which","have","been","set","to","a","specific","value","per","the","do-operator",".","Examples","--","--","--","--","Create","a","small","Bayesian","Network",".",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","game","=","BayesianNetwork","(","[","(","'","X","'",",","'","A","'",")",",","...","(","'","A","'",",","'","Y","'",")",",","...","(","'","A","'",",","'","B","'",")","]",")","Load","the","graph","into","the","CausalInference","object","to","make","causal","queries",".",">",">",">","from","pgmpy.inference.CausalInference","import","CausalInference",">",">",">","inference","=","CausalInference","(","game",")",">",">",">","inference.get_all_backdoor_adjustment_sets","(","X=","''","X","''",",","Y=","''","Y","''",")",">",">",">","inference.get_all_frontdoor_adjustment_sets","(","X=","''","X","''",",","Y=","''","Y","''",")","References","--","--","--","--","--","'Causality",":","Models",",","Reasoning",",","and","Inference","'","-","Judea","Pearl","(","2000",")"]
docstr: Estimate the average treatment effect (ATE) of X on Y.
  
  Parameters
  ----------
  X: str (variable name)
      The cause/exposure variables.
  
  Y: str (variable name)
      The outcome variable
  
  data: pandas.DataFrame
      All observed data for this Bayesian Network.
  
  estimand_strategy: str or frozenset
      Either specify a specific backdoor adjustment set or a strategy.
      The available options are:
          smallest:
              Use the smallest estimand of observed variables
          all:
              Estimate the ATE from each identified estimand
  
  estimator_type: str
      The type of model to be used to estimate the ATE.
      All of the linear regression classes in statsmodels are available including:
          * GLS: generalized least squares for arbitrary covariance
          * OLS: ordinary least square of i.i.d. errors
          * WLS: weighted least squares for heteroskedastic error
      Specify them with their acronym (e.g. "OLS") or simple "linear" as an alias for OLS.
  
  **kwargs: dict
      Keyward arguments specific to the selected estimator.
      linear:
        missing: str
          Available options are "none", "drop", or "raise"
  
  Returns
  -------
  The average treatment effect: float
  
  Examples
  --------
  >>> import pandas as pd
  >>> game1 = BayesianNetwork([('X', 'A'),
  ...                          ('A', 'Y'),
  ...                          ('A', 'B')])
  >>> data = pd.DataFrame(np.random.randint(2, size=(1000, 4)), columns=['X', 'A', 'B', 'Y'])
  >>> inference = CausalInference(model=game1)
  >>> inference.estimate_ate("X", "Y", data=data, estimator_type="linear")
docstr_tok: ["Estimate","the","average","treatment","effect","(","ATE",")","of","X","on","Y.","Parameters","--","--","--","--","--","X",":","str","(","variable","name",")","The","cause\/exposure","variables",".","Y",":","str","(","variable","name",")","The","outcome","variable","data",":","pandas.DataFrame","All","observed","data","for","this","Bayesian","Network",".","estimand_strategy",":","str","or","frozenset","Either","specify","a","specific","backdoor","adjustment","set","or","a","strategy",".","The","available","options","are",":","smallest",":","Use","the","smallest","estimand","of","observed","variables","all",":","Estimate","the","ATE","from","each","identified","estimand","estimator_type",":","str","The","type","of","model","to","be","used","to","estimate","the","ATE",".","All","of","the","linear","regression","classes","in","statsmodels","are","available","including",":","*","GLS",":","generalized","least","squares","for","arbitrary","covariance","*","OLS",":","ordinary","least","square","of","i.i.d",".","errors","*","WLS",":","weighted","least","squares","for","heteroskedastic","error","Specify","them","with","their","acronym","(","e.g",".","``","OLS","''",")","or","simple","``","linear","''","as","an","alias","for","OLS",".","*","*","kwargs",":","dict","Keyward","arguments","specific","to","the","selected","estimator",".","linear",":","missing",":","str","Available","options","are","``","none","''",",","``","drop","''",",","or","``","raise","''","Returns","--","--","--","-","The","average","treatment","effect",":","float","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","game1","=","BayesianNetwork","(","[","(","'","X","'",",","'","A","'",")",",","...","(","'","A","'",",","'","Y","'",")",",","...","(","'","A","'",",","'","B","'",")","]",")",">",">",">","data","=","pd.DataFrame","(","np.random.randint","(","2",",","size=","(","1000",",","4",")",")",",","columns=","[","'","X","'",",","'","A","'",",","'","B","'",",","'","Y","'","]",")",">",">",">","inference","=","CausalInference","(","model=game1",")",">",">",">","inference.estimate_ate","(","``","X","''",",","``","Y","''",",","data=data",",","estimator_type=","''","linear","''",")"]
code: def estimate_ate(
      self,
      X,
      Y,
      data,
      estimand_strategy="smallest",
      estimator_type="linear",
      **kwargs,
  ):
      """
      Estimate the average treatment effect (ATE) of X on Y.
  
      Parameters
      ----------
      X: str (variable name)
          The cause/exposure variables.
  
      Y: str (variable name)
          The outcome variable
  
      data: pandas.DataFrame
          All observed data for this Bayesian Network.
  
      estimand_strategy: str or frozenset
          Either specify a specific backdoor adjustment set or a strategy.
          The available options are:
              smallest:
                  Use the smallest estimand of observed variables
              all:
                  Estimate the ATE from each identified estimand
  
      estimator_type: str
          The type of model to be used to estimate the ATE.
          All of the linear regression classes in statsmodels are available including:
              * GLS: generalized least squares for arbitrary covariance
              * OLS: ordinary least square of i.i.d. errors
              * WLS: weighted least squares for heteroskedastic error
          Specify them with their acronym (e.g. "OLS") or simple "linear" as an alias for OLS.
  
      **kwargs: dict
          Keyward arguments specific to the selected estimator.
          linear:
            missing: str
              Available options are "none", "drop", or "raise"
  
      Returns
      -------
      The average treatment effect: float
  
      Examples
      --------
      >>> import pandas as pd
      >>> game1 = BayesianNetwork([('X', 'A'),
      ...                          ('A', 'Y'),
      ...                          ('A', 'B')])
      >>> data = pd.DataFrame(np.random.randint(2, size=(1000, 4)), columns=['X', 'A', 'B', 'Y'])
      >>> inference = CausalInference(model=game1)
      >>> inference.estimate_ate("X", "Y", data=data, estimator_type="linear")
      """
      valid_estimators = ["linear"]
      try:
          assert estimator_type in valid_estimators
      except AssertionError:
          print(
              f"{estimator_type} if not a valid estimator_type.  Please select from {valid_estimators}"
          )
      all_simple_paths = nx.all_simple_paths(self.model, X, Y)
      all_path_effects = []
      for path in all_simple_paths:
          causal_effect = []
          for x1, x2 in zip(path, path[1:]):
              if isinstance(estimand_strategy, frozenset):
                  adjustment_set = frozenset({estimand_strategy})
                  assert self.is_valid_backdoor_adjustment_set(
                      x1, x2, Z=adjustment_set
                  )
              elif estimand_strategy in ["smallest", "all"]:
                  adjustment_sets = (
                      self.get_all_backdoor_adjustment_sets(x1, x2)
                  )
                  if estimand_strategy == "smallest":
                      adjustment_sets = frozenset(
                          {self._simple_decision(adjustment_sets)}
                      )
  
              if estimator_type == "linear":
                  self.estimator = LinearEstimator(self.model)
  
              ate = [
                  self.estimator.fit(
                      X=x1, Y=x2, Z=s, data=data, **kwargs
                  )._get_ate()
                  for s in adjustment_sets
              ]
              causal_effect.append(np.mean(ate))
          all_path_effects.append(np.prod(causal_effect))
      return np.sum(all_path_effects)
  
imports: from collections.abc import Iterable
  from itertools import chain, product
  import networkx
  import numpy
  from tqdm.auto import tqdm
  from pgmpy import config
  from pgmpy.estimators.LinearModel import LinearEstimator
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.models import BayesianNetwork
  from pgmpy.utils.sets import _powerset, _variable_or_iterable_to_set
label_desc: Use image node_id 8 for calling the CausalInference obj's underlying member method code with example usage: obj.estimate_ate(X, Y, data, estimand_strategy, estimator_type) and returns: np