Example #1
0
         stateful=True,
         return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(n_seq))
model.add(Activation('linear'))
#model.add(LeakyReLU())
model.compile(loss='mse', optimizer='adam')
# fit network
model.fit(train_X,
          train_y,
          epochs=1,
          batch_size=batch_size,
          validation_data=(test_X, test_y),
          verbose=2,
          shuffle=False)
model.reset_states()
# plot history
#pyplot.plot(history.history['loss'], label='train')
#pyplot.plot(history.history['val_loss'], label='test')
#pyplot.legend()
#pyplot.show()

# make a prediction
# test data should be predicted with batch size
yhat = model.predict(test_X, batch_size)

# invert scaling for forecast
# take every 7 variables on certain time ranges like 0 to 6 and 7 to 13 and so forth
# assign this variables to dictionary
# make inverse transform
t1 = list()