Skip to content

Instantly share code, notes, and snippets.

@ArunkumarRamanan
Forked from susanli2016/construct_LSTM.py
Created April 24, 2019 07:38
Show Gist options
  • Save ArunkumarRamanan/de75d444c5b12c92f09c4ce59359d099 to your computer and use it in GitHub Desktop.
Save ArunkumarRamanan/de75d444c5b12c92f09c4ce59359d099 to your computer and use it in GitHub Desktop.
train_sc_df = pd.DataFrame(train_sc, columns=['Y'], index=train.index)
test_sc_df = pd.DataFrame(test_sc, columns=['Y'], index=test.index)
for s in range(1,2):
train_sc_df['X_{}'.format(s)] = train_sc_df['Y'].shift(s)
test_sc_df['X_{}'.format(s)] = test_sc_df['Y'].shift(s)
X_train = train_sc_df.dropna().drop('Y', axis=1)
y_train = train_sc_df.dropna().drop('X_1', axis=1)
X_test = test_sc_df.dropna().drop('Y', axis=1)
y_test = test_sc_df.dropna().drop('X_1', axis=1)
X_train = X_train.as_matrix()
y_train = y_train.as_matrix()
X_test = X_test.as_matrix()
y_test = y_test.as_matrix()
X_train_lmse = X_train.reshape(X_train.shape[0], X_train.shape[1], 1)
X_test_lmse = X_test.reshape(X_test.shape[0], X_test.shape[1], 1)
print('Train shape: ', X_train_lmse.shape)
print('Test shape: ', X_test_lmse.shape)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment