class_docstr: Use a sliding window to perform cross validation
  
  This approach to CV slides a window over the training samples while using
  several future samples as a test set. While similar to the
  :class:`RollingForecastCV`, it differs in that the train set does not grow,
  but rather shifts.
  
  Parameters
  ----------
  h : int, optional (default=1)
      The forecasting horizon, or the number of steps into the future after
      the last training sample for the test set.
  
  step : int, optional (default=1)
      The size of step taken between training folds.
  
  window_size : int or None, optional (default=None)
      The size of the rolling window to use. If None, a rolling window of
      size n_samples // 5 will be used.
  
  Examples
  --------
  With a step size of one and a forecasting horizon of one, the training size
  will grow by 1 for each step, and the test index will be 1 + the last
  training index. Notice the sliding window also adjusts where the training
  sample begins for each fold:
  
  >>> import pmdarima as pm
  >>> from pmdarima.model_selection import SlidingWindowForecastCV
  >>> wineind = pm.datasets.load_wineind()
  >>> cv = SlidingWindowForecastCV()
  >>> cv_generator = cv.split(wineind)
  >>> next(cv_generator)
  (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
         17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
         34]), array([35]))
  >>> next(cv_generator)
  (array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
         18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
         35]), array([36]))
  
  With a step size of 4, a forecasting horizon of 6, and a window size of 12,
  the training size will grow by 4 for each step, and the test index will 6 +
  the last index in the training fold:
  
  >>> cv = SlidingWindowForecastCV(step=4, h=6, window_size=12)
  >>> cv_generator = cv.split(wineind)
  >>> next(cv_generator)
  (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11]),
   array([12, 13, 14, 15, 16, 17]))
  >>> next(cv_generator)
  (array([ 4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15]),
   array([16, 17, 18, 19, 20, 21]))
  
  See Also
  --------
  RollingForecastCV
  
  References
  ----------
  .. [1] https://robjhyndman.com/hyndsight/tscv/
class_docstr_tok: ["Use","a","sliding","window","to","perform","cross","validation","This","approach","to","CV","slides","a","window","over","the","training","samples","while","using","several","future","samples","as","a","test","set",".","While","similar","to","the",":","class",":","`","RollingForecastCV","`",",","it","differs","in","that","the","train","set","does","not","grow",",","but","rather","shifts",".","Parameters","--","--","--","--","--","h",":","int",",","optional","(","default=1",")","The","forecasting","horizon",",","or","the","number","of","steps","into","the","future","after","the","last","training","sample","for","the","test","set",".","step",":","int",",","optional","(","default=1",")","The","size","of","step","taken","between","training","folds",".","window_size",":","int","or","None",",","optional","(","default=None",")","The","size","of","the","rolling","window","to","use",".","If","None",",","a","rolling","window","of","size","n_samples","\/\/","5","will","be","used",".","Examples","--","--","--","--","With","a","step","size","of","one","and","a","forecasting","horizon","of","one",",","the","training","size","will","grow","by","1","for","each","step",",","and","the","test","index","will","be","1","+","the","last","training","index",".","Notice","the","sliding","window","also","adjusts","where","the","training","sample","begins","for","each","fold",":",">",">",">","import","pmdarima","as","pm",">",">",">","from","pmdarima.model_selection","import","SlidingWindowForecastCV",">",">",">","wineind","=","pm.datasets.load_wineind","(",")",">",">",">","cv","=","SlidingWindowForecastCV","(",")",">",">",">","cv_generator","=","cv.split","(","wineind",")",">",">",">","next","(","cv_generator",")","(","array","(","[","0",",","1",",","2",",","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10",",","11",",","12",",","13",",","14",",","15",",","16",",","17",",","18",",","19",",","20",",","21",",","22",",","23",",","24",",","25",",","26",",","27",",","28",",","29",",","30",",","31",",","32",",","33",",","34","]",")",",","array","(","[","35","]",")",")",">",">",">","next","(","cv_generator",")","(","array","(","[","1",",","2",",","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10",",","11",",","12",",","13",",","14",",","15",",","16",",","17",",","18",",","19",",","20",",","21",",","22",",","23",",","24",",","25",",","26",",","27",",","28",",","29",",","30",",","31",",","32",",","33",",","34",",","35","]",")",",","array","(","[","36","]",")",")","With","a","step","size","of","4",",","a","forecasting","horizon","of","6",",","and","a","window","size","of","12",",","the","training","size","will","grow","by","4","for","each","step",",","and","the","test","index","will","6","+","the","last","index","in","the","training","fold",":",">",">",">","cv","=","SlidingWindowForecastCV","(","step=4",",","h=6",",","window_size=12",")",">",">",">","cv_generator","=","cv.split","(","wineind",")",">",">",">","next","(","cv_generator",")","(","array","(","[","0",",","1",",","2",",","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10",",","11","]",")",",","array","(","[","12",",","13",",","14",",","15",",","16",",","17","]",")",")",">",">",">","next","(","cv_generator",")","(","array","(","[","4",",","5",",","6",",","7",",","8",",","9",",","10",",","11",",","12",",","13",",","14",",","15","]",")",",","array","(","[","16",",","17",",","18",",","19",",","20",",","21","]",")",")","See","Also","--","--","--","--","RollingForecastCV","References","--","--","--","--","--","..","[","1","]","https",":","\/\/robjhyndman.com\/hyndsight\/tscv\/"]
docstr: Yields the train/test indices
docstr_tok: ["Yields","the","train\/test","indices"]
code: def _iter_train_test_indices(self, y, X):
      """Yields the train/test indices"""
      n_samples = y.shape[0]
      window_size = self.window_size
      step = self.step
      h = self.h
  
      if window_size is not None:
          if window_size + h > n_samples:
              raise ValueError(
                  "The window_size + forecasting "
                  "horizon would exceed the length of the "
                  "given timeseries!"
              )
      else:
          # TODO: what's a good sane default for this?
          window_size = max(3, n_samples // 5)
  
      if window_size < 3:
          raise ValueError("window_size must be > 2")
  
      indices = np.arange(n_samples)
      window_start = 0
      while True:
          window_end = window_start + window_size
          if window_end + h > n_samples:
              break
  
          train_indices = indices[window_start:window_end]
          test_indices = indices[window_end : window_end + h]
          window_start += step
  
          yield train_indices, test_indices
  
imports: import abc
  import numpy
  from sklearn.base import BaseEstimator
  from sklearn.utils.validation import indexable
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 2 for calling the SlidingWindowForecastCV obj's underlying member method code with example usage: obj._iter_train_test_indices(y, X) without return types