def test_autoregressive_transform_2(self): X = np.arange(1, 6, dtype=np.float64)[:, np.newaxis] at = AutoregressiveTransformer(num_lags=2, pred_stride=2) X_trans = at.fit_transform(X) expected = np.array([ [np.nan, np.nan], [np.nan, np.nan], [np.nan, np.nan], [1, 2], [2, 3], ], dtype=np.float64) assert np.allclose(X_trans, expected, equal_nan=True)
def test_autoregressive_transform_3(self): X = np.arange(1, 9, dtype=np.float64)[:, np.newaxis] at = AutoregressiveTransformer(num_lags=3, pred_stride=2) X_trans = at.fit_transform(X) expected = np.array([ [np.nan, np.nan, np.nan], # y = 1 [np.nan, np.nan, np.nan], # y = 2 [np.nan, np.nan, np.nan], # y = 3 [np.nan, np.nan, np.nan], # y = 4 [1, 2, 3], # y = 5 [2, 3, 4], # y = 6 [3, 4, 5], # y = 7 [4, 5, 6], # y = 8 ], dtype=np.float64) assert np.allclose(X_trans, expected, equal_nan=True)