@@ -38,7 +38,7 @@ def intervals_to_mask(index, intervals):
3838
3939
4040def rolling_window_sequences (X , index , window_size , target_size , step_size , target_column ,
41- drop = None , drop_windows = False ):
41+ offset = 0 , drop = None , drop_windows = False ):
4242 """Create rolling window sequences out of time series data.
4343
4444 The function creates an array of input sequences and an array of target sequences by rolling
@@ -58,6 +58,8 @@ def rolling_window_sequences(X, index, window_size, target_size, step_size, targ
5858 Indicating the number of steps to move the window forward each round.
5959 target_column (int):
6060 Indicating which column of X is the target.
61+ offset (int):
62+ Indicating the number of steps between the input and the target sequence.
6163 drop (ndarray or None or str or float or bool):
6264 Optional. Array of boolean values indicating which values of X are invalid, or value
6365 indicating which value should be dropped. If not given, `None` is used.
@@ -89,7 +91,7 @@ def rolling_window_sequences(X, index, window_size, target_size, step_size, targ
8991 drop = X == drop
9092
9193 start = 0
92- max_start = len (X ) - window_size - target_size + 1
94+ max_start = len (X ) - window_size - target_size - offset + 1
9395 while start < max_start :
9496 end = start + window_size
9597
@@ -101,9 +103,9 @@ def rolling_window_sequences(X, index, window_size, target_size, step_size, targ
101103 continue
102104
103105 out_X .append (X [start :end ])
104- out_y .append (target [end :end + target_size ])
106+ out_y .append (target [end + offset :end + offset + target_size ])
105107 X_index .append (index [start ])
106- y_index .append (index [end ])
108+ y_index .append (index [end + offset ])
107109 start = start + step_size
108110
109111 return np .asarray (out_X ), np .asarray (out_y ), np .asarray (X_index ), np .asarray (y_index )
0 commit comments