class_docstr: Abstract base class for time series panel tasks, e.g., classifiers, regressors.
  
  The class contains boilerplate for checks and data conversions,
  which are common to multiple descendants, most importantly,
  BaseClassifier and BaseRegressor.
docstr: Boilerplate logic for fit_predict and fit_predict_proba.
docstr_tok: ["Boilerplate","logic","for","fit_predict","and","fit_predict_proba","."]
code: def _fit_predict_boilerplate(self, X, y, cv, change_state, method):
      """Boilerplate logic for fit_predict and fit_predict_proba."""
      from sklearn.model_selection import KFold
  
      if isinstance(cv, int):
          random_state = getattr(self, "random_state", None)
          cv = KFold(cv, random_state=random_state, shuffle=True)
  
      if change_state:
          self.reset()
          est = self
      else:
          est = self.clone()
  
      if cv is None:
          return getattr(est.fit(X, y), method)(X)
      elif change_state:
          self.fit(X, y)
  
      # we now know that cv is an sklearn splitter
      X, y = self._internal_convert(X, y)
      X_metadata = self._check_input(
          X, y, return_metadata=self.METADATA_REQ_IN_CHECKS
      )
      X_mtype = X_metadata["mtype"]
      # Check this estimator can handle characteristics
      self._check_capabilities(X_metadata)
  
      # handle single class case
      if len(self._class_dictionary) == 1:
          return self._single_class_y_pred(X)
  
      # Convert data to format easily usable for applying cv
      if isinstance(X, np.ndarray):
          X = convert(
              X,
              from_type=X_mtype,
              to_type="numpy3D",
              as_scitype="Panel",
              store_behaviour="freeze",
          )
      else:
          X = convert(
              X,
              from_type=X_mtype,
              to_type="nested_univ",
              as_scitype="Panel",
              store_behaviour="freeze",
          )
  
      if method == "predict_proba":
          y_pred = np.empty([len(y), len(np.unique(y))])
      else:
          y_pred = np.empty_like(y)
      y_pred[:] = -1
      if isinstance(X, np.ndarray):
          for tr_idx, tt_idx in cv.split(X):
              X_train = X[tr_idx]
              X_test = X[tt_idx]
              y_train = y[tr_idx]
              fitted_est = self.clone().fit(X_train, y_train)
              y_pred[tt_idx] = getattr(fitted_est, method)(X_test)
      else:
          for tr_idx, tt_idx in cv.split(X):
              X_train = X.iloc[tr_idx]
              X_test = X.iloc[tt_idx]
              y_train = y[tr_idx]
              fitted_est = self.clone().fit(X_train, y_train)
              y_pred[tt_idx] = getattr(fitted_est, method)(X_test)
  
      return y_pred
  
file_path: sktime/sktime/base/_base_panel.py
imports: import numpy
  import pandas
  from sktime.base import BaseEstimator
  from sktime.datatypes import MTYPE_LIST_PANEL, MTYPE_LIST_TABLE, VectorizedDF, check_is_error_msg, check_is_scitype, convert
  from sktime.utils.warnings import warn
label_desc: Use image node_id 2 for calling the BasePanelMixin obj's underlying member method code with example usage: obj._fit_predict_boilerplate(X, y, cv, change_state, method) and returns: y_pred, getattr, self