我正在使用 LSTM NN 和 Keras 进行时间序列预测。作为输入特征,有两个变量(降水量和温度),要预测的一个目标是地下水位。
\n尽管实际数据和输出之间存在严重的偏移(见图),但它似乎工作得很好。
\n现在我读到这可能是网络无法正常工作的典型标志,因为它似乎在模仿输出并且
\n\n\n该模型实际上所做的是,当预测\n时间 \xe2\x80\x9ct+1\xe2\x80\x9d 的值时,它只是使用时间 \xe2\x80\x9ct\xe2\x80\x9d 的值作为它的预测https://towardsdatascience.com/how-not-to-use-machine-learning-for-time-series-forecasting-avoiding-the-pitfalls-19f9d7adf424
\n
然而,在我的例子中这实际上是不可能的,因为目标值不用作输入变量。我使用的是具有两个特征的多元时间序列,与输出特征无关。\n此外,预测值在未来 (t+1) 中不会偏移,而是似乎滞后于 (t-1)。
\n\n这是我的网络的完整代码:
\n# Split in Input and Output Data \nx_1 = data[[\'MeanT\']].values\nx_2 = data[[\'Precip\']].values\ny = data[[\'Z_424A_6857\']].values\n\n# Scale Data\nx = np.hstack([x_1, x_2])\nscaler = MinMaxScaler(feature_range=(0, 1))\nx = scaler.fit_transform(x)\n\nscaler_out = MinMaxScaler(feature_range=(0, 1))\ny = scaler_out.fit_transform(y)\n\n# Reshape Data\nx_1, x_2, y = H.create2feature_data(x_1, x_2, y, window)\ntrain_size = int(len(x_1) * .8)\ntest_size = int(len(x_1)) # * .5\n\nx_1 = np.expand_dims(x_1, 2) # …Run Code Online (Sandbox Code Playgroud)