class_docstr: Flexible splitter for time-series cross validation and rolling window evaluation.
  Suitable for use in GridSearchCV.
  
  Attributes
  ----------
  min_splits : int
      Guaranteed min number of splits. This is always set to 1. If provided configuration results in 0 splits,
      the cross validator will yield a default split.
  
  __starting_test_index : int
      Test end index of the first CV split. Actual offset = __starting_test_index + _get_offset(X), for a particular
      dataset X.
      Cross validator ensures the last test split contains the last observation in X.
  
  Examples
  --------
  >>> from greykite.sklearn.cross_validation import RollingTimeSeriesSplit
  >>> X = np.random.rand(20, 4)
  >>> tscv = RollingTimeSeriesSplit(forecast_horizon=3, max_splits=4)
  >>> tscv.get_n_splits(X=X)
  4
  >>> for train, test in tscv.split(X=X):
  ...     print(train, test)
  [2 3 4 5 6 7] [ 8  9 10]
  [ 5  6  7  8  9 10] [11 12 13]
  [ 8  9 10 11 12 13] [14 15 16]
  [11 12 13 14 15 16] [17 18 19]
  >>> X = np.random.rand(20, 4)
  >>> tscv = RollingTimeSeriesSplit(forecast_horizon=2,
  ...                               min_train_periods=4,
  ...                               expanding_window=True,
  ...                               periods_between_splits=4,
  ...                               periods_between_train_test=2,
  ...                               max_splits=None)
  >>> tscv.get_n_splits(X=X)
  4
  >>> for train, test in tscv.split(X=X):
  ...     print(train, test)
  [0 1 2 3] [6 7]
  [0 1 2 3 4 5 6 7] [10 11]
  [ 0  1  2  3  4  5  6  7  8  9 10 11] [14 15]
  [ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15] [18 19]
  >>> X = np.random.rand(5, 4)  # default split if there is not enough data
  >>> for train, test in tscv.split(X=X):
  ...     print(train, test)
  [0 1 2 3] [4]
class_docstr_tok: ["Flexible","splitter","for","time-series","cross","validation","and","rolling","window","evaluation",".","Suitable","for","use","in","GridSearchCV",".","Attributes","--","--","--","--","--","min_splits",":","int","Guaranteed","min","number","of","splits",".","This","is","always","set","to","1",".","If","provided","configuration","results","in","0","splits",",","the","cross","validator","will","yield","a","default","split",".","__starting_test_index",":","int","Test","end","index","of","the","first","CV","split",".","Actual","offset","=","__starting_test_index","+","_get_offset","(","X",")",",","for","a","particular","dataset","X",".","Cross","validator","ensures","the","last","test","split","contains","the","last","observation","in","X",".","Examples","--","--","--","--",">",">",">","from","greykite.sklearn.cross_validation","import","RollingTimeSeriesSplit",">",">",">","X","=","np.random.rand","(","20",",","4",")",">",">",">","tscv","=","RollingTimeSeriesSplit","(","forecast_horizon=3",",","max_splits=4",")",">",">",">","tscv.get_n_splits","(","X=X",")","4",">",">",">","for","train",",","test","in","tscv.split","(","X=X",")",":","...","print","(","train",",","test",")","[","2","3","4","5","6","7","]","[","8","9","10","]","[","5","6","7","8","9","10","]","[","11","12","13","]","[","8","9","10","11","12","13","]","[","14","15","16","]","[","11","12","13","14","15","16","]","[","17","18","19","]",">",">",">","X","=","np.random.rand","(","20",",","4",")",">",">",">","tscv","=","RollingTimeSeriesSplit","(","forecast_horizon=2",",","...","min_train_periods=4",",","...","expanding_window=True",",","...","periods_between_splits=4",",","...","periods_between_train_test=2",",","...","max_splits=None",")",">",">",">","tscv.get_n_splits","(","X=X",")","4",">",">",">","for","train",",","test","in","tscv.split","(","X=X",")",":","...","print","(","train",",","test",")","[","0","1","2","3","]","[","6","7","]","[","0","1","2","3","4","5","6","7","]","[","10","11","]","[","0","1","2","3","4","5","6","7","8","9","10","11","]","[","14","15","]","[","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","]","[","18","19","]",">",">",">","X","=","np.random.rand","(","5",",","4",")","#","default","split","if","there","is","not","enough","data",">",">",">","for","train",",","test","in","tscv.split","(","X=X",")",":","...","print","(","train",",","test",")","[","0","1","2","3","]","[","4","]"]
docstr: Returns an offset to add to test set indices when creating CV splits
  CV splits are shifted so that the last test observation is the last point in X.
  This shift does not affect the total number of splits.
  
  Parameters
  ----------
  X : array-like, shape (n_samples, n_features)
      Input data to split
  
  Returns
  -------
  offset : int
      The number of observations to ignore at the beginning of X when creating CV splits
docstr_tok: ["Returns","an","offset","to","add","to","test","set","indices","when","creating","CV","splits","CV","splits","are","shifted","so","that","the","last","test","observation","is","the","last","point","in","X",".","This","shift","does","not","affect","the","total","number","of","splits",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","(","n_samples",",","n_features",")","Input","data","to","split","Returns","--","--","--","-","offset",":","int","The","number","of","observations","to","ignore","at","the","beginning","of","X","when","creating","CV","splits"]
code: def _get_offset(self, X=None):
      """Returns an offset to add to test set indices when creating CV splits
      CV splits are shifted so that the last test observation is the last point in X.
      This shift does not affect the total number of splits.
  
      Parameters
      ----------
      X : array-like, shape (n_samples, n_features)
          Input data to split
  
      Returns
      -------
      offset : int
          The number of observations to ignore at the beginning of X when creating CV splits
      """
      last_index = X.shape[0] - 1
      starting_index = self.__starting_test_index
      if starting_index > last_index:
          return 0
      return (last_index - starting_index) % self.periods_between_splits
  
file_path: greykite/greykite/sklearn/cross_validation.py
imports: import math
  import random
  import warnings
  import numpy
  from sklearn.model_selection import BaseCrossValidator
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.python_utils import get_integer
label_desc: Use image node_id 5 for calling the RollingTimeSeriesSplit obj's underlying member method code with example usage: obj._get_offset(X) and returns: unknown, int