Skip to content

Instantly share code, notes, and snippets.

@saivarunk
Last active January 12, 2019 18:45
Show Gist options
  • Save saivarunk/bd92cb575d8ec781d4760174383ecf88 to your computer and use it in GitHub Desktop.
Save saivarunk/bd92cb575d8ec781d4760174383ecf88 to your computer and use it in GitHub Desktop.
# choose a number of time steps
n_steps = 5
# split into sequence
X, y = split_sequence(real_price.values, n_steps)
# reshape from [samples, timesteps] into [samples, timesteps, features] to fit in LSTM model
n_features = 1
X = X.reshape((X.shape[0], X.shape[1], n_features))
# split into train - test sets
X_train = X[0:-365]
y_train = y[0:-365]
X_test = X[-365:]
y_test = y[-365:]
# store the test dates
test_dates = real_price.index[-365:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment