class_docstr: A Learner that learns a treatment assignment policy with observational data using doubly robust estimator of causal
  effect for binary treatment.
  
  Details of the policy learner are available at Athey and Wager (2018) (https://arxiv.org/abs/1702.02896).
class_docstr_tok: ["A","Learner","that","learns","a","treatment","assignment","policy","with","observational","data","using","doubly","robust","estimator","of","causal","effect","for","binary","treatment",".","Details","of","the","policy","learner","are","available","at","Athey","and","Wager","(","2018",")","(","https",":","\/\/arxiv.org\/abs\/1702.02896",")","."]
docstr: Fit the treatment assignment policy learner.
  
  Args:
      X (np.matrix): a feature matrix
      treatment (np.array): a treatment vector (1 if treated, otherwise 0)
      y (np.array): an outcome vector
      p (optional, np.array): user provided propensity score vector between 0 and 1
      dhat (optinal, np.array): user provided predicted treatment effect vector
  
  Returns:
      self: returns an instance of self.
docstr_tok: ["Fit","the","treatment","assignment","policy","learner",".","Args",":","X","(","np.matrix",")",":","a","feature","matrix","treatment","(","np.array",")",":","a","treatment","vector","(","1","if","treated",",","otherwise","0",")","y","(","np.array",")",":","an","outcome","vector","p","(","optional",",","np.array",")",":","user","provided","propensity","score","vector","between","0","and","1","dhat","(","optinal",",","np.array",")",":","user","provided","predicted","treatment","effect","vector","Returns",":","self",":","returns","an","instance","of","self","."]
code: def fit(self, X, treatment, y, p=None, dhat=None):
      """Fit the treatment assignment policy learner.
  
      Args:
          X (np.matrix): a feature matrix
          treatment (np.array): a treatment vector (1 if treated, otherwise 0)
          y (np.array): an outcome vector
          p (optional, np.array): user provided propensity score vector between 0 and 1
          dhat (optinal, np.array): user provided predicted treatment effect vector
  
      Returns:
          self: returns an instance of self.
      """
  
      logger.info(
          "generating out-of-fold CV outcome estimates with {}".format(
              self.model_mu
          )
      )
      self._outcome_estimate(X, treatment, y)
  
      if dhat is not None:
          self._tau_pred = dhat
  
      if p is None:
          self._treatment_estimate(X, treatment)
      else:
          self._w_pred = np.clip(
              p, self.clip_bounds[0], self.clip_bounds[1]
          )
  
      # Doubly Robust Modification
      self._dr_score = self._tau_pred + (
          treatment - self._w_pred
      ) / self._w_pred / (1 - self._w_pred) * (y - self._y_pred)
  
      target = self._dr_score.copy()
      target = np.sign(target)
  
      logger.info(
          "training the treatment assignment model, {}".format(
              self.model_pi
          )
      )
      self.model_pi.fit(X, target, sample_weight=abs(self._dr_score))
  
      return self
  
file_path: causalml/causalml/optimize/policylearner.py
imports: import logging
  import numpy
  from causalml.propensity import compute_propensity_score
  from sklearn.ensemble import GradientBoostingRegressor, GradientBoostingClassifier
  from sklearn.model_selection import cross_val_predict, KFold
  from sklearn.tree import DecisionTreeClassifier
label_desc: Use image node_id 5 for calling the PolicyLearner obj's underlying member method code with example usage: obj.fit(X, treatment, y, p, dhat) and returns: self