class_docstr: Base class for interfacing statsmodels forecasting algorithms.
class_docstr_tok: ["Base","class","for","interfacing","statsmodels","forecasting","algorithms","."]
docstr: Compute/return prediction interval forecasts.
  
  private _predict_interval containing the core logic,
      called from predict_interval and default _predict_quantiles
  
  Parameters
  ----------
  fh : guaranteed to be ForecastingHorizon
      The forecasting horizon with the steps ahead to to predict.
  X : optional (default=None)
      guaranteed to be of a type in self.get_tag("X_inner_mtype")
      Exogeneous time series to predict from.
  coverage : float or list of float, optional (default=0.95)
     nominal coverage(s) of predictive interval(s)
  
  Returns
  -------
  pred_int : pd.DataFrame
      Column has multi-index: first level is variable name from y in fit,
          second level coverage fractions for which intervals were computed.
              in the same order as in input `coverage`.
          Third level is string "lower" or "upper", for lower/upper interval end.
      Row index is fh, with additional (upper) levels equal to instance levels,
          from y seen in fit, if y_inner_mtype is Panel or Hierarchical.
      Entries are forecasts of lower/upper interval end,
          for var in col index, at nominal coverage in second col index,
          lower/upper depending on third col index, for the row index.
          Upper/lower interval end forecasts are equivalent to
          quantile forecasts at alpha = 0.5 - c/2, 0.5 + c/2 for c in coverage.
docstr_tok: ["Compute\/return","prediction","interval","forecasts",".","private","_predict_interval","containing","the","core","logic",",","called","from","predict_interval","and","default","_predict_quantiles","Parameters","--","--","--","--","--","fh",":","guaranteed","to","be","ForecastingHorizon","The","forecasting","horizon","with","the","steps","ahead","to","to","predict",".","X",":","optional","(","default=None",")","guaranteed","to","be","of","a","type","in","self.get_tag","(","``","X_inner_mtype","''",")","Exogeneous","time","series","to","predict","from",".","coverage",":","float","or","list","of","float",",","optional","(","default=0.95",")","nominal","coverage","(","s",")","of","predictive","interval","(","s",")","Returns","--","--","--","-","pred_int",":","pd.DataFrame","Column","has","multi-index",":","first","level","is","variable","name","from","y","in","fit",",","second","level","coverage","fractions","for","which","intervals","were","computed",".","in","the","same","order","as","in","input","`","coverage","`",".","Third","level","is","string","``","lower","''","or","``","upper","''",",","for","lower\/upper","interval","end",".","Row","index","is","fh",",","with","additional","(","upper",")","levels","equal","to","instance","levels",",","from","y","seen","in","fit",",","if","y_inner_mtype","is","Panel","or","Hierarchical",".","Entries","are","forecasts","of","lower\/upper","interval","end",",","for","var","in","col","index",",","at","nominal","coverage","in","second","col","index",",","lower\/upper","depending","on","third","col","index",",","for","the","row","index",".","Upper\/lower","interval","end","forecasts","are","equivalent","to","quantile","forecasts","at","alpha","=","0.5","-","c\/2",",","0.5","+","c\/2","for","c","in","coverage","."]
code: def _predict_interval(self, fh, X, coverage):
      """Compute/return prediction interval forecasts.
  
      private _predict_interval containing the core logic,
          called from predict_interval and default _predict_quantiles
  
      Parameters
      ----------
      fh : guaranteed to be ForecastingHorizon
          The forecasting horizon with the steps ahead to to predict.
      X : optional (default=None)
          guaranteed to be of a type in self.get_tag("X_inner_mtype")
          Exogeneous time series to predict from.
      coverage : float or list of float, optional (default=0.95)
         nominal coverage(s) of predictive interval(s)
  
      Returns
      -------
      pred_int : pd.DataFrame
          Column has multi-index: first level is variable name from y in fit,
              second level coverage fractions for which intervals were computed.
                  in the same order as in input `coverage`.
              Third level is string "lower" or "upper", for lower/upper interval end.
          Row index is fh, with additional (upper) levels equal to instance levels,
              from y seen in fit, if y_inner_mtype is Panel or Hierarchical.
          Entries are forecasts of lower/upper interval end,
              for var in col index, at nominal coverage in second col index,
              lower/upper depending on third col index, for the row index.
              Upper/lower interval end forecasts are equivalent to
              quantile forecasts at alpha = 0.5 - c/2, 0.5 + c/2 for c in coverage.
      """
      implements_interval_adapter = self._has_implementation_of(
          "_extract_conf_int"
      )
      implements_quantiles = self._has_implementation_of(
          "_predict_quantiles"
      )
  
      if not implements_interval_adapter and implements_quantiles:
          return BaseForecaster._predict_interval(
              self, fh, X=X, coverage=coverage
          )
  
      start, end = fh.to_absolute_int(self._y.index[0], self.cutoff)[
          [0, -1]
      ]
      fh_int = fh.to_absolute_int(self._y.index[0], self.cutoff) - len(
          self._y
      )
      # if fh > 1 steps ahead of cutoff
      fh_int = fh_int - fh_int[0]
  
      get_prediction_arguments = {"start": start, "end": end}
  
      if hasattr(self, "random_state"):
          get_prediction_arguments["random_state"] = self.random_state
  
      if inspect.signature(
          self._fitted_forecaster.get_prediction
      ).parameters.get("exog"):
          get_prediction_arguments["exog"] = X
  
      prediction_results = self._fitted_forecaster.get_prediction(
          **get_prediction_arguments
      )
  
      var_names = self._get_varnames()
      var_name = var_names[0]
      columns = pd.MultiIndex.from_product(
          [var_names, coverage, ["lower", "upper"]]
      )
      preds_index = self._extract_conf_int(
          prediction_results, (1 - coverage[0])
      )
      preds_index = preds_index.iloc[fh_int].index
      pred_int = pd.DataFrame(index=preds_index, columns=columns)
  
      for c in coverage:
          pred_statsmodels = self._extract_conf_int(
              prediction_results, (1 - c)
          )
  
          pred_int[(var_name, c, "lower")] = pred_statsmodels.iloc[
              fh_int
          ]["lower"]
          pred_int[(var_name, c, "upper")] = pred_statsmodels.iloc[
              fh_int
          ]["upper"]
  
      return pred_int
  
file_path: sktime/sktime/forecasting/base/adapters/_statsmodels.py
imports: import inspect
  import numpy
  import pandas
  from sktime.forecasting.base import BaseForecaster
  from sktime.utils.warnings import warn
label_desc: Use image node_id 7 for calling the _StatsModelsAdapter obj's underlying member method code with example usage: obj._predict_interval(fh, X, coverage) and returns: pred_int, BaseForecaster