Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.model_selection import TimeSeriesSplit
- X = np.array([[1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]])
- y = np.array([1, 2, 3, 4, 5, 6])
- tscv = TimeSeriesSplit(n_splits=5)
- for train_index, test_index in tscv.split(X):
- print("TRAIN:", train_index, "TEST:", test_index)
- X_train, X_test = X[train_index], X[test_index]
- y_train, y_test = y[train_index], y[test_index]
- >> TRAIN: [0] TEST: [1]
- >> TRAIN: [0 1] TEST: [2]
- >> TRAIN: [0 1 2] TEST: [3]
- >> TRAIN: [0 1 2 3] TEST: [4]
- >> TRAIN: [0 1 2 3 4] TEST: [5]
Add Comment
Please, Sign In to add comment