1
0
mirror of https://github.com/newnius/YAO-optimizer.git synced 2025-12-13 00:16:44 +00:00
This commit is contained in:
2020-05-02 09:21:56 +08:00
parent b8e6dfcbc2
commit dcc7664f85
2 changed files with 13 additions and 18 deletions

View File

@@ -12,11 +12,6 @@ from math import sqrt
import numpy
# date-time parsing function for loading the dataset
def parser(x):
return datetime.strptime('190' + x, '%Y-%m')
# frame a sequence as a supervised learning problem
def timeseries_to_supervised(data, lag=1):
df = DataFrame(data)
@@ -104,7 +99,7 @@ train, test = supervised_values[0:-12], supervised_values[-12:]
scaler, train_scaled, test_scaled = scale(train, test)
# fit the model
lstm_model = fit_lstm(train_scaled, 1, 30, 4)
lstm_model = fit_lstm(train_scaled, 32, 30, 4)
# forecast the entire training dataset to build up state for forecasting
train_reshaped = train_scaled[:, 0].reshape(len(train_scaled), 1, 1)
lstm_model.predict(train_reshaped, batch_size=1)