Created
September 28, 2018 18:28
-
-
Save mratsim/9af51fab4c25d381db622d69d7951e96 to your computer and use it in GitHub Desktop.
train_test_split for sequence predictions
This file contains hidden or 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
def make_input_seqs(data, seq_len, train_split=0.9): | |
seq_len = seq_len + 1 | |
result = [] | |
for index in range(len(data) - seq_len): | |
result.append(data[index: index + seq_len, :]) | |
result = np.array(result) | |
train_ind = round(train_split * result.shape[0]) | |
train = result[:int(train_ind), :, :] | |
x_train = train[:, :-1, :] | |
y_train = train[:, -1, :] | |
x_test = result[int(train_ind):, :-1, :] | |
y_test = result[int(train_ind):, -1, :] | |
return [x_train, y_train, x_test, y_test] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment