mirror of
https://github.com/newnius/YAO-optimizer.git
synced 2025-12-13 00:16:44 +00:00
update
This commit is contained in:
10
train.py
10
train.py
@@ -111,18 +111,18 @@ lstm_model.predict(train_reshaped, batch_size=1)
|
||||
|
||||
# walk-forward validation on the test data
|
||||
predictions = list()
|
||||
for i in range(len(test_scaled)):
|
||||
for j in range(len(test_scaled)):
|
||||
# make one-step forecast
|
||||
X, y = test_scaled[i, 0:-1], test_scaled[i, -1]
|
||||
X, y = test_scaled[j, 0:-1], test_scaled[j, -1]
|
||||
yhat = forecast_lstm(lstm_model, 1, X)
|
||||
# invert scaling
|
||||
yhat = invert_scale(scaler, X, yhat)
|
||||
# invert differencing
|
||||
yhat = inverse_difference(raw_values, yhat, len(test_scaled) + 1 - i)
|
||||
yhat = inverse_difference(raw_values, yhat, len(test_scaled) + 1 - j)
|
||||
# store forecast
|
||||
predictions.append(yhat)
|
||||
expected = raw_values[len(train) + i + 1]
|
||||
print('Month=%d, Predicted=%f, Expected=%f' % (i + 1, yhat, expected))
|
||||
expected = raw_values[len(train) + j + 1]
|
||||
print('Month=%d, Predicted=%f, Expected=%f' % (j + 1, yhat, expected))
|
||||
|
||||
# report performance
|
||||
rmse = sqrt(mean_squared_error(raw_values[-12:], predictions))
|
||||
|
||||
Reference in New Issue
Block a user