regressor.add(LSTM(units=50, return_sequences=True, input_shape=(x_train.shape[1], x_train.shape[2]))) regressor.add(Dropout(0.2)) regressor.add(LSTM(units=50, return_sequences=True )) regressor.add(Dropout(0.2)) regressor.add(LSTM(units=33, return_sequences=True)) regressor.add(Flatten()) regressor.add(Dense(units=1)) #compiling the model with mean_absolute_percentage_error and adam optimizer regressor.compile(optimizer='adam', loss='mean_absolute_percentage_error') #fitting model with training sets and validation set history = regressor.fit(x_train, y_train, epochs = EPOCH, batch_size=BATCH_SIZE, validation_data=(x_test, y_test)) bm.save_val_loss_plot(history, PLACE+"_epoch_history.csv") results = regressor.predict(x_test) #constructing estimation dataframe real_values = pd.DataFrame(index = test.index, data = bm.inverse_scale(sc, y_test.reshape(-1, 1)), columns = ['Real']) predictions = pd.DataFrame(index = test.index, data = bm.inverse_scale(sc, results), columns = ['Predictions']) predictions = pd.concat([real_values, predictions], axis = 1)
regressor.add(Dropout(0.2)) regressor.add(LSTM(units=33, return_sequences=True)) regressor.add(Flatten()) regressor.add(Dense(units=1)) #compiling the model with mean_absolute_percentage_error and adam optimizer regressor.compile(optimizer='adam', loss='mean_absolute_percentage_error') #fitting model with training sets and validation set history = regressor.fit(x_train, y_train, epochs=EPOCH, batch_size=BATCH_SIZE, validation_data=(x_test, y_test)) bm.save_val_loss_plot(history, "loss_graph.png") results = regressor.predict(x_test) #constructing estimation dataframe real_values = pd.DataFrame(index=test.index, data=bm.inverse_scale(sc, y_test.reshape(-1, 1)), columns=['Real']) predictions = pd.DataFrame(index=test.index, data=bm.inverse_scale(sc, results), columns=['Predictions']) predictions = pd.concat([real_values, predictions], axis=1) #constructing daily error dataframe