Created
March 5, 2020 09:29
-
-
Save geniusnhu/9e80e6a2dbce52d81c548e54dc9b6196 to your computer and use it in GitHub Desktop.
Train test set for Time series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Split train and test sets in correspondence with Time series data | |
def ts_train_test_split(X, y, test_size): | |
test_index = int(len(X)*(1-test_size)) | |
X_train = X.iloc[:test_index] | |
y_train = y.iloc[:test_index] | |
X_test = X.iloc[test_index:] | |
y_test = y.iloc[test_index:] | |
return X_train, X_test, y_train, y_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment