class_docstr: Plotter for numeric independent variables with regression model.
  
  This does the computations and drawing for the `regplot` function, and
  is thus also used indirectly by `lmplot`.
class_docstr_tok: ["Plotter","for","numeric","independent","variables","with","regression","model",".","This","does","the","computations","and","drawing","for","the","`","regplot","`","function",",","and","is","thus","also","used","indirectly","by","`","lmplot","`","."]
docstr: Fit the regression model.
docstr_tok: ["Fit","the","regression","model","."]
code: def fit_regression(self, ax=None, x_range=None, grid=None):
      """Fit the regression model."""
      self._check_statsmodels()
  
      # Create the grid for the regression
      if grid is None:
          if self.truncate:
              x_min, x_max = self.x_range
          else:
              if ax is None:
                  x_min, x_max = x_range
              else:
                  x_min, x_max = ax.get_xlim()
          grid = np.linspace(x_min, x_max, 100)
      ci = self.ci
  
      # Fit the regression
      if self.order > 1:
          yhat, yhat_boots = self.fit_poly(grid, self.order)
      elif self.logistic:
          from statsmodels.genmod.generalized_linear_model import GLM
          from statsmodels.genmod.families import Binomial
  
          yhat, yhat_boots = self.fit_statsmodels(
              grid, GLM, family=Binomial()
          )
      elif self.lowess:
          ci = None
          grid, yhat = self.fit_lowess()
      elif self.robust:
          from statsmodels.robust.robust_linear_model import RLM
  
          yhat, yhat_boots = self.fit_statsmodels(grid, RLM)
      elif self.logx:
          yhat, yhat_boots = self.fit_logx(grid)
      else:
          yhat, yhat_boots = self.fit_fast(grid)
  
      # Compute the confidence interval at each grid point
      if ci is None:
          err_bands = None
      else:
          err_bands = utils.ci(yhat_boots, ci, axis=0)
  
      return grid, yhat, err_bands
  
imports: import copy
  from textwrap import dedent
  import warnings
  import numpy
  import pandas
  import matplotlib
  import matplotlib.pyplot
  from .None import utils
  from .None import algorithms
  from .axisgrid import FacetGrid, _facet_docs
label_desc: Use image node_id 5 for calling the _RegressionPlotter obj's underlying member method code with example usage: obj.fit_regression(ax, x_range, grid) and returns: grid,  yhat,  err_bands