docstr: Initialize an R-learner regressor with XGBoost model using pairwise ranking objective.
  
  Args:
      early_stopping: whether or not to use early stopping when fitting effect learner
      test_size (float, optional): the proportion of the dataset to use as validation set when early stopping is
                                   enabled
      early_stopping_rounds (int, optional): validation metric needs to improve at least once in every
                                             early_stopping_rounds round(s) to continue training
      effect_learner_objective (str, optional): the learning objective for the effect learner
                                                (default = 'reg:squarederror')
      effect_learner_n_estimators (int, optional): number of trees to fit for the effect learner (default = 500)
docstr_tok: ["Initialize","an","R-learner","regressor","with","XGBoost","model","using","pairwise","ranking","objective",".","Args",":","early_stopping",":","whether","or","not","to","use","early","stopping","when","fitting","effect","learner","test_size","(","float",",","optional",")",":","the","proportion","of","the","dataset","to","use","as","validation","set","when","early","stopping","is","enabled","early_stopping_rounds","(","int",",","optional",")",":","validation","metric","needs","to","improve","at","least","once","in","every","early_stopping_rounds","round","(","s",")","to","continue","training","effect_learner_objective","(","str",",","optional",")",":","the","learning","objective","for","the","effect","learner","(","default","=","'reg",":","squarederror","'",")","effect_learner_n_estimators","(","int",",","optional",")",":","number","of","trees","to","fit","for","the","effect","learner","(","default","=","500",")"]
code: def __init__(
      self,
      early_stopping=True,
      test_size=0.3,
      early_stopping_rounds=30,
      effect_learner_objective="reg:squarederror",
      effect_learner_n_estimators=500,
      random_state=42,
      *args,
      **kwargs,
  ):
      """Initialize an R-learner regressor with XGBoost model using pairwise ranking objective.
  
      Args:
          early_stopping: whether or not to use early stopping when fitting effect learner
          test_size (float, optional): the proportion of the dataset to use as validation set when early stopping is
                                       enabled
          early_stopping_rounds (int, optional): validation metric needs to improve at least once in every
                                                 early_stopping_rounds round(s) to continue training
          effect_learner_objective (str, optional): the learning objective for the effect learner
                                                    (default = 'reg:squarederror')
          effect_learner_n_estimators (int, optional): number of trees to fit for the effect learner (default = 500)
      """
  
      assert isinstance(
          random_state, int
      ), "random_state should be int."
  
      objective, metric = get_xgboost_objective_metric(
          effect_learner_objective
      )
      self.effect_learner_objective = objective
      self.effect_learner_eval_metric = metric
      self.effect_learner_n_estimators = effect_learner_n_estimators
      self.early_stopping = early_stopping
      if self.early_stopping:
          self.test_size = test_size
          self.early_stopping_rounds = early_stopping_rounds
  
      super().__init__(
          outcome_learner=XGBRegressor(
              random_state=random_state, *args, **kwargs
          ),
          effect_learner=XGBRegressor(
              objective=self.effect_learner_objective,
              n_estimators=self.effect_learner_n_estimators,
              random_state=random_state,
              *args,
              **kwargs,
          ),
      )
  
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 XGBRRegressor object from inherited base classes: BaseRRegressor with example: obj = XGBRRegressor(early_stopping, test_size, early_stopping_rounds, effect_learner_objective, effect_learner_n_estimators, random_state)