class_docstr: Base class for estimators that estimate effects based on propensity of
  treatment assignment.
  
  Supports additional parameters as listed below.
class_docstr_tok: ["Base","class","for","estimators","that","estimate","effects","based","on","propensity","of","treatment","assignment",".","Supports","additional","parameters","as","listed","below","."]
docstr: Fits the estimator with data for effect estimation
  :param data: data frame containing the data
  :param effect_modifiers: Variables on which to compute separate
              effects, or return a heterogeneous effect function. Not all
              methods support this currently.
docstr_tok: ["Fits","the","estimator","with","data","for","effect","estimation",":","param","data",":","data","frame","containing","the","data",":","param","effect_modifiers",":","Variables","on","which","to","compute","separate","effects",",","or","return","a","heterogeneous","effect","function",".","Not","all","methods","support","this","currently","."]
code: def fit(
      self,
      data: pd.DataFrame,
      effect_modifier_names: Optional[List[str]] = None,
  ):
      """
      Fits the estimator with data for effect estimation
      :param data: data frame containing the data
      :param effect_modifiers: Variables on which to compute separate
                  effects, or return a heterogeneous effect function. Not all
                  methods support this currently.
      """
      self._set_effect_modifiers(data, effect_modifier_names)
  
      self.logger.debug(
          "Back-door variables used:"
          + ",".join(self._target_estimand.get_backdoor_variables())
      )
      self._observed_common_causes_names = (
          self._target_estimand.get_backdoor_variables()
      )
  
      if self._observed_common_causes_names:
          self._observed_common_causes = data[
              self._observed_common_causes_names
          ]
          # Convert the categorical variables into dummy/indicator variables
          # Basically, this gives a one hot encoding for each category
          # The first category is taken to be the base line.
          self._observed_common_causes = pd.get_dummies(
              self._observed_common_causes, drop_first=True
          )
      else:
          self._observed_common_causes = None
          error_msg = "No common causes/confounders present. Propensity score based methods are not applicable"
          self.logger.error(error_msg)
          raise Exception(error_msg)
  
      # Check if the treatment is one-dimensional
      if len(self._target_estimand.treatment_variable) > 1:
          error_msg = (
              str(self.__class__)
              + "cannot handle more than one treatment variable"
          )
          raise Exception(error_msg)
      # Checking if the treatment is binary
      treatment_values = (
          data[self._target_estimand.treatment_variable[0]]
          .astype(int)
          .unique()
      )
      if any([v not in [0, 1] for v in treatment_values]):
          error_msg = "Propensity score methods are applicable only for binary treatments"
          self.logger.error(error_msg)
          raise Exception(error_msg)
  
      if self.propensity_score_column not in data:
          if self.propensity_score_model is None:
              self.propensity_score_model = (
                  linear_model.LogisticRegression()
              )
          treatment_reshaped = np.ravel(
              data[self._target_estimand.treatment_variable]
          )
          self.propensity_score_model.fit(
              self._observed_common_causes, treatment_reshaped
          )
  
      return self
  
file_path: dowhy/dowhy/causal_estimators/propensity_score_estimator.py
imports: from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from sklearn import linear_model
  from sklearn.exceptions import NotFittedError
  from dowhy.causal_estimator import CausalEstimator
  from dowhy.causal_identifier import IdentifiedEstimand
label_desc: Use image node_id 2 for calling the PropensityScoreEstimator obj's underlying member method code with example usage: obj.fit(data, effect_modifier_names) and returns: self