Guest User

Untitled

a guest
Nov 18th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from sklearn.model_selection import TimeSeriesSplit
  2. X = np.array([[1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]])
  3. y = np.array([1, 2, 3, 4, 5, 6])
  4. tscv = TimeSeriesSplit(n_splits=5)
  5.  
  6. for train_index, test_index in tscv.split(X):
  7. print("TRAIN:", train_index, "TEST:", test_index)
  8. X_train, X_test = X[train_index], X[test_index]
  9. y_train, y_test = y[train_index], y[test_index]
  10.  
  11. >> TRAIN: [0] TEST: [1]
  12. >> TRAIN: [0 1] TEST: [2]
  13. >> TRAIN: [0 1 2] TEST: [3]
  14. >> TRAIN: [0 1 2 3] TEST: [4]
  15. >> TRAIN: [0 1 2 3 4] TEST: [5]
Add Comment
Please, Sign In to add comment