class_docstr: A parent class for X-learner regressor classes.
  
  An X-learner estimates treatment effects with four machine learning models.
  
  Details of X-learner are available at Kunzel et al. (2018) (https://arxiv.org/abs/1706.03461).
class_docstr_tok: ["A","parent","class","for","X-learner","regressor","classes",".","An","X-learner","estimates","treatment","effects","with","four","machine","learning","models",".","Details","of","X-learner","are","available","at","Kunzel","et","al",".","(","2018",")","(","https",":","\/\/arxiv.org\/abs\/1706.03461",")","."]
docstr: Fit the treatment effect and outcome models of the R learner and predict treatment effects.
  
  Args:
      X (np.matrix or np.array or pd.Dataframe): a feature matrix
      treatment (np.array or pd.Series): a treatment vector
      y (np.array or pd.Series): an outcome vector
      p (np.ndarray or pd.Series or dict, optional): an array of propensity scores of float (0,1) in the
          single-treatment case; or, a dictionary of treatment groups that map to propensity vectors of
          float (0,1); if None will run ElasticNetPropensityModel() to generate the propensity scores.
      return_ci (bool): whether to return confidence intervals
      n_bootstraps (int): number of bootstrap iterations
      bootstrap_size (int): number of samples per bootstrap
      return_components (bool, optional): whether to return outcome for treatment and control seperately
      verbose (str): whether to output progress logs
  Returns:
      (numpy.ndarray): Predictions of treatment effects. Output dim: [n_samples, n_treatment]
          If return_ci, returns CATE [n_samples, n_treatment], LB [n_samples, n_treatment],
          UB [n_samples, n_treatment]
docstr_tok: ["Fit","the","treatment","effect","and","outcome","models","of","the","R","learner","and","predict","treatment","effects",".","Args",":","X","(","np.matrix","or","np.array","or","pd.Dataframe",")",":","a","feature","matrix","treatment","(","np.array","or","pd.Series",")",":","a","treatment","vector","y","(","np.array","or","pd.Series",")",":","an","outcome","vector","p","(","np.ndarray","or","pd.Series","or","dict",",","optional",")",":","an","array","of","propensity","scores","of","float","(","0,1",")","in","the","single-treatment","case",";","or",",","a","dictionary","of","treatment","groups","that","map","to","propensity","vectors","of","float","(","0,1",")",";","if","None","will","run","ElasticNetPropensityModel","(",")","to","generate","the","propensity","scores",".","return_ci","(","bool",")",":","whether","to","return","confidence","intervals","n_bootstraps","(","int",")",":","number","of","bootstrap","iterations","bootstrap_size","(","int",")",":","number","of","samples","per","bootstrap","return_components","(","bool",",","optional",")",":","whether","to","return","outcome","for","treatment","and","control","seperately","verbose","(","str",")",":","whether","to","output","progress","logs","Returns",":","(","numpy.ndarray",")",":","Predictions","of","treatment","effects",".","Output","dim",":","[","n_samples",",","n_treatment","]","If","return_ci",",","returns","CATE","[","n_samples",",","n_treatment","]",",","LB","[","n_samples",",","n_treatment","]",",","UB","[","n_samples",",","n_treatment","]"]
code: def fit_predict(
      self,
      X,
      treatment,
      y,
      p=None,
      return_ci=False,
      n_bootstraps=1000,
      bootstrap_size=10000,
      return_components=False,
      verbose=True,
  ):
      """Fit the treatment effect and outcome models of the R learner and predict treatment effects.
  
      Args:
          X (np.matrix or np.array or pd.Dataframe): a feature matrix
          treatment (np.array or pd.Series): a treatment vector
          y (np.array or pd.Series): an outcome vector
          p (np.ndarray or pd.Series or dict, optional): an array of propensity scores of float (0,1) in the
              single-treatment case; or, a dictionary of treatment groups that map to propensity vectors of
              float (0,1); if None will run ElasticNetPropensityModel() to generate the propensity scores.
          return_ci (bool): whether to return confidence intervals
          n_bootstraps (int): number of bootstrap iterations
          bootstrap_size (int): number of samples per bootstrap
          return_components (bool, optional): whether to return outcome for treatment and control seperately
          verbose (str): whether to output progress logs
      Returns:
          (numpy.ndarray): Predictions of treatment effects. Output dim: [n_samples, n_treatment]
              If return_ci, returns CATE [n_samples, n_treatment], LB [n_samples, n_treatment],
              UB [n_samples, n_treatment]
      """
      X, treatment, y = convert_pd_to_np(X, treatment, y)
      self.fit(X, treatment, y, p)
  
      if p is None:
          p = self.propensity
      else:
          p = self._format_p(p, self.t_groups)
  
      te = self.predict(
          X,
          treatment=treatment,
          y=y,
          p=p,
          return_components=return_components,
      )
  
      if not return_ci:
          return te
      else:
          t_groups_global = self.t_groups
          _classes_global = self._classes
          models_mu_c_global = deepcopy(self.models_mu_c)
          models_mu_t_global = deepcopy(self.models_mu_t)
          models_tau_c_global = deepcopy(self.models_tau_c)
          models_tau_t_global = deepcopy(self.models_tau_t)
          te_bootstraps = np.zeros(
              shape=(X.shape[0], self.t_groups.shape[0], n_bootstraps)
          )
  
          logger.info("Bootstrap Confidence Intervals")
          for i in tqdm(range(n_bootstraps)):
              te_b = self.bootstrap(
                  X, treatment, y, p, size=bootstrap_size
              )
              te_bootstraps[:, :, i] = te_b
  
          te_lower = np.percentile(
              te_bootstraps, (self.ate_alpha / 2) * 100, axis=2
          )
          te_upper = np.percentile(
              te_bootstraps, (1 - self.ate_alpha / 2) * 100, axis=2
          )
  
          # set member variables back to global (currently last bootstrapped outcome)
          self.t_groups = t_groups_global
          self._classes = _classes_global
          self.models_mu_c = deepcopy(models_mu_c_global)
          self.models_mu_t = deepcopy(models_mu_t_global)
          self.models_tau_c = deepcopy(models_tau_c_global)
          self.models_tau_t = deepcopy(models_tau_t_global)
  
          return (te, te_lower, te_upper)
  
imports: from copy import deepcopy
  import logging
  import numpy
  import pandas
  from tqdm import tqdm
  from scipy.stats import norm
  from causalml.inference.meta.base import BaseLearner
  from causalml.inference.meta.utils import check_treatment_vector, check_p_conditions, convert_pd_to_np
  from causalml.inference.meta.explainer import Explainer
  from causalml.metrics import regression_metrics, classification_metrics
  from causalml.propensity import compute_propensity_score
label_desc: Use image node_id 5 for calling the BaseXLearner obj's underlying member method code with example usage: obj.fit_predict(X, treatment, y, p, return_ci, n_bootstraps, bootstrap_size, return_components, verbose) and returns: te, te,  te_lower,  te_upper