'Constant difference while transforming forecast from its "differenced" form
I am transforming "differencing" transformation to my data. But when i want to do the inverse operation to my forecast, I am getting something like this, this, and this as prediction. How can I fix this "constant blank" issue?
How I apply difference transform to my dataset (pretty simple.):
df['diff'] = df.loc[:,'RequestResponseLogDuration'].diff(1)
And here is how I am trying to revert this operation:
def inverse_difference(history, yhat, interval=1):
return yhat + history[-interval]
for x, y in train_data_multi.take(10):
predictions = list()
for i in range(len(y)):
# predict
X, T = y[i, 0:-1], y[i, -1]
yhat = multi_step_model.predict(x)[i]
# invert differencing
yhat = inverse_difference(dataset, yhat, len(T)+1-i)
# store forecast
predictions.append(yhat)
multi_step_plot(x[v], y[v], predictions[v])
UPDATE I transferred code to this:
from tensorflow.python.ops.numpy_ops import np_config
np_config.enable_numpy_behavior()
for x, y in train_data_multi.take(1):
predictions = list()
for i in range(len(y)):
# predict
yhat = multi_step_model.predict(x)[i]
# invert scaling
# invert differencing
yhat = inverse_difference(dataset, yhat, i)
xx=True
# store forecast
predictions.append(yhat)
multi_step_plot(x[v], y[v], predictions[v])
print(predictions[v].ravel()-y[v].ravel())
Now this is the result
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
