【发布时间】:2020-06-22 18:22:18
【问题描述】:
使用这个tutorial,它只处理多变量和一步,我一直在尝试编写多变量和多步代码。 由于代码太长,我附上它here(您也可以在同一个存储库中找到数据集)。
代码的目的是预测未来 6 小时的污染值。
在对数据进行预处理和标准化后,我将数据拆分并重新整形,如下所示:
# split into train and test sets
values = reframed.values
n_train_hours = 365 * 24 * 1 # 5 years data 1 year training
train = values[:n_train_hours, :]
test = values[n_train_hours:n_train_hours+50, :]
# split into input and outputs
n_obs = n_hours * n_features
train_X, train_y = train[:, :n_obs], train[:, :n_out] # the problem is here
test_X, test_y = test[:, :n_obs], test[:,:n_out] # and here
# reshape input to be 3D [samples, timesteps, features]
train_X = train_X.reshape((train_X.shape[0], n_hours, n_features))
train_y = train_y
test_X = test_X.reshape((test_X.shape[0], n_hours, n_features))
print(train_X.shape, train_y.shape, test_X.shape, test_y.shape)
我对 train_X、train_y、test_X 和 test_y 有疑问,我不确定是否必须使用 n_out 和 n_obs 而不是 n_out*n_features 和 n_obs 或其他替代方案,因为在这两者中在inv_y 上使用inverse_transform 的情况下,我得到的值与数据集上的真实值不同:
print('predicted: ',inv_yhat)
print('real:' ,inv_y)
predicted: [ 3.04286 7.406884 6.121824 ... -10.307352 -7.0151763
-3.4667058]
real: [36. 30.999998 19.999998 ... 24.999998 48. 48.999996]
如果您需要更多详细信息,请告诉我。
【问题讨论】:
标签: python machine-learning deep-learning dataset forecasting