class_docstr: Nonparametric kernel regression class.
  
  Calculates the conditional mean ``E[y|X]`` where ``y = g(X) + e``.
  Note that the "local constant" type of regression provided here is also
  known as Nadaraya-Watson kernel regression; "local linear" is an extension
  of that which suffers less from bias issues at the edge of the support. Note
  that specifying a custom kernel works only with "local linear" kernel
  regression. For example, a custom ``tricube`` kernel yields LOESS regression.
  
  Parameters
  ----------
  endog : array_like
      This is the dependent variable.
  exog : array_like
      The training data for the independent variable(s)
      Each element in the list is a separate variable
  var_type : str
      The type of the variables, one character per variable:
  
          - c: continuous
          - u: unordered (discrete)
          - o: ordered (discrete)
  
  reg_type : {'lc', 'll'}, optional
      Type of regression estimator. 'lc' means local constant and
      'll' local Linear estimator.  Default is 'll'
  bw : str or array_like, optional
      Either a user-specified bandwidth or the method for bandwidth
      selection. If a string, valid values are 'cv_ls' (least-squares
      cross-validation) and 'aic' (AIC Hurvich bandwidth estimation).
      Default is 'cv_ls'. User specified bandwidth must have as many
      entries as the number of variables.
  ckertype : str, optional
      The kernel used for the continuous variables.
  okertype : str, optional
      The kernel used for the ordered discrete variables.
  ukertype : str, optional
      The kernel used for the unordered discrete variables.
  defaults : EstimatorSettings instance, optional
      The default values for the efficient bandwidth estimation.
  
  Attributes
  ----------
  bw : array_like
      The bandwidth parameters.
docstr: Local constant estimator of g(x) in the regression
  y = g(x) + e
  
  Parameters
  ----------
  bw : array_like
      Array of bandwidth value(s).
  endog : 1D array_like
      The dependent variable.
  exog : 1D or 2D array_like
      The independent variable(s).
  data_predict : 1D or 2D array_like
      The point(s) at which the density is estimated.
  
  Returns
  -------
  G : ndarray
      The value of the conditional mean at `data_predict`.
  B_x : ndarray
      The marginal effects.
code: def _est_loc_constant(self, bw, endog, exog, data_predict):
      """
      Local constant estimator of g(x) in the regression
      y = g(x) + e
  
      Parameters
      ----------
      bw : array_like
          Array of bandwidth value(s).
      endog : 1D array_like
          The dependent variable.
      exog : 1D or 2D array_like
          The independent variable(s).
      data_predict : 1D or 2D array_like
          The point(s) at which the density is estimated.
  
      Returns
      -------
      G : ndarray
          The value of the conditional mean at `data_predict`.
      B_x : ndarray
          The marginal effects.
      """
      ker_x = gpke(
          bw,
          data=exog,
          data_predict=data_predict,
          var_type=self.var_type,
          ckertype=self.ckertype,
          ukertype=self.ukertype,
          okertype=self.okertype,
          tosum=False,
      )
      ker_x = np.reshape(ker_x, np.shape(endog))
      G_numer = (ker_x * endog).sum(axis=0)
      G_denom = ker_x.sum(axis=0)
      G = G_numer / G_denom
      nobs = exog.shape[0]
      f_x = G_denom / float(nobs)
      ker_xc = gpke(
          bw,
          data=exog,
          data_predict=data_predict,
          var_type=self.var_type,
          ckertype="d_gaussian",
          # okertype='wangryzin_reg',
          tosum=False,
      )
  
      ker_xc = ker_xc[:, np.newaxis]
      d_mx = -(endog * ker_xc).sum(axis=0) / float(
          nobs
      )  # * np.prod(bw[:, ix_cont]))
      d_fx = -ker_xc.sum(axis=0) / float(
          nobs
      )  # * np.prod(bw[:, ix_cont]))
      B_x = d_mx / f_x - G * d_fx / f_x
      B_x = (G_numer * d_fx - G_denom * d_mx) / (G_denom**2)
      # B_x = (f_x * d_mx - m_x * d_fx) / (f_x ** 2)
      return G, B_x
  
imports: import copy
  import numpy
  from scipy import optimize
  from scipy.stats.mstats import mquantiles
  from ._kernel_base import GenericKDE, EstimatorSettings, gpke, LeaveOneOut, _get_type_pos, _adjust_shape, _compute_min_std_IQR, kernel_func
label_desc: Use image node_id 4 for calling the KernelReg obj's underlying member method code with example usage: obj._est_loc_constant(bw, endog, exog, data_predict) and returns: G,  B_x