class_docstr: Simple matching estimator for binary treatments based on a distance
  metric.
  
  Supports additional parameters as listed below.
docstr: Fits the estimator with data for effect estimation
  :param data: data frame containing the data
  :param treatment: name of the treatment variable
  :param outcome: name of the outcome variable
  :param exact_match_cols: List of column names whose values should be
  exactly matched. Typically used for columns with discrete values.
  :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,
      exact_match_cols=None,
      effect_modifier_names: Optional[List[str]] = None,
  ):
      """
      Fits the estimator with data for effect estimation
      :param data: data frame containing the data
      :param treatment: name of the treatment variable
      :param outcome: name of the outcome variable
      :param exact_match_cols: List of column names whose values should be
      exactly matched. Typically used for columns with discrete values.
      :param effect_modifiers: Variables on which to compute separate
                  effects, or return a heterogeneous effect function. Not all
                  methods support this currently.
      """
      self.exact_match_cols = exact_match_cols
  
      self._set_effect_modifiers(data, effect_modifier_names)
  
      # 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
      if (
          not data[self._target_estimand.treatment_variable[0]]
          .isin([0, 1])
          .all()
      ):
          error_msg = "Distance Matching method is applicable only for binary treatments."
          self.logger.error(error_msg)
          raise Exception(error_msg)
  
      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:
          if self.exact_match_cols is not None:
              self._observed_common_causes_names = [
                  v
                  for v in self._observed_common_causes_names
                  if v not in self.exact_match_cols
              ]
          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. Distance matching methods are not applicable"
          self.logger.error(error_msg)
          raise Exception(error_msg)
  
      self.symbolic_estimator = self.construct_symbolic_estimator(
          self._target_estimand
      )
      self.logger.info(self.symbolic_estimator)
  
      return self
  
file_path: dowhy/dowhy/causal_estimators/distance_matching_estimator.py
imports: from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from sklearn.neighbors import NearestNeighbors
  from dowhy.causal_estimator import CausalEstimate, CausalEstimator
  from dowhy.causal_identifier import IdentifiedEstimand
label_desc: Use image node_id 2 for calling the DistanceMatchingEstimator obj's underlying member method code with example usage: obj.fit(data, exact_match_cols, effect_modifier_names) and returns: self