class_docstr: A parent class for R-learner classes.
  
  An R-learner estimates treatment effects with two machine learning models and the propensity score.
  
  Details of R-learner are available at Nie and Wager (2019) (https://arxiv.org/abs/1712.04912).
docstr: Initialize an R-learner.
  
  Args:
      learner (optional): a model to estimate outcomes and treatment effects
      outcome_learner (optional): a model to estimate outcomes
      effect_learner (optional): a model to estimate treatment effects. It needs to take `sample_weight` as an
          input argument for `fit()`
      propensity_learner (optional): a model to estimate propensity scores. `ElasticNetPropensityModel()` will
          be used by default.
      ate_alpha (float, optional): the confidence level alpha of the ATE estimate
      control_name (str or int, optional): name of control group
      n_fold (int, optional): the number of cross validation folds for outcome_learner
      random_state (int or RandomState, optional): a seed (int) or random number generator (RandomState)
      cv_n_jobs (int, optional): number of parallel jobs to run for cross_val_predict. -1 means using all processors
docstr_tok: ["Initialize","an","R-learner",".","Args",":","learner","(","optional",")",":","a","model","to","estimate","outcomes","and","treatment","effects","outcome_learner","(","optional",")",":","a","model","to","estimate","outcomes","effect_learner","(","optional",")",":","a","model","to","estimate","treatment","effects",".","It","needs","to","take","`","sample_weight","`","as","an","input","argument","for","`","fit","(",")","`","propensity_learner","(","optional",")",":","a","model","to","estimate","propensity","scores",".","`","ElasticNetPropensityModel","(",")","`","will","be","used","by","default",".","ate_alpha","(","float",",","optional",")",":","the","confidence","level","alpha","of","the","ATE","estimate","control_name","(","str","or","int",",","optional",")",":","name","of","control","group","n_fold","(","int",",","optional",")",":","the","number","of","cross","validation","folds","for","outcome_learner","random_state","(","int","or","RandomState",",","optional",")",":","a","seed","(","int",")","or","random","number","generator","(","RandomState",")","cv_n_jobs","(","int",",","optional",")",":","number","of","parallel","jobs","to","run","for","cross_val_predict",".","-1","means","using","all","processors"]
code: def __init__(
      self,
      learner=None,
      outcome_learner=None,
      effect_learner=None,
      propensity_learner=ElasticNetPropensityModel(),
      ate_alpha=0.05,
      control_name=0,
      n_fold=5,
      random_state=None,
      cv_n_jobs=-1,
  ):
      """Initialize an R-learner.
  
      Args:
          learner (optional): a model to estimate outcomes and treatment effects
          outcome_learner (optional): a model to estimate outcomes
          effect_learner (optional): a model to estimate treatment effects. It needs to take `sample_weight` as an
              input argument for `fit()`
          propensity_learner (optional): a model to estimate propensity scores. `ElasticNetPropensityModel()` will
              be used by default.
          ate_alpha (float, optional): the confidence level alpha of the ATE estimate
          control_name (str or int, optional): name of control group
          n_fold (int, optional): the number of cross validation folds for outcome_learner
          random_state (int or RandomState, optional): a seed (int) or random number generator (RandomState)
          cv_n_jobs (int, optional): number of parallel jobs to run for cross_val_predict. -1 means using all processors
      """
      assert (learner is not None) or (
          (outcome_learner is not None) and (effect_learner is not None)
      )
      assert propensity_learner is not None
  
      self.model_mu = (
          outcome_learner
          if outcome_learner is not None
          else deepcopy(learner)
      )
      self.model_tau = (
          effect_learner
          if effect_learner is not None
          else deepcopy(learner)
      )
      self.model_p = propensity_learner
  
      self.ate_alpha = ate_alpha
      self.control_name = control_name
  
      self.random_state = random_state
      self.cv = KFold(
          n_splits=n_fold, shuffle=True, random_state=random_state
      )
      self.cv_n_jobs = cv_n_jobs
  
      self.propensity = None
      self.propensity_model = None
  
imports: from copy import deepcopy
  import logging
  import numpy
  import pandas
  from tqdm import tqdm
  from scipy.stats import norm
  from sklearn.model_selection import cross_val_predict, KFold, train_test_split
  from xgboost import XGBRegressor
  from causalml.inference.meta.base import BaseLearner
  from causalml.inference.meta.utils import check_treatment_vector, get_xgboost_objective_metric, convert_pd_to_np, get_weighted_variance
  from causalml.propensity import compute_propensity_score, ElasticNetPropensityModel
label_desc: Use image node_id 1 to create a new BaseRLearner object from inherited base classes: BaseLearner with example: obj = BaseRLearner(learner, outcome_learner, effect_learner, propensity_learner, ate_alpha, control_name, n_fold, random_state, cv_n_jobs)