更新时间:2023-12-02 09:19:58
更改
a = dataset[i:(i + look_back), 0]
收件人
a = dataset[i:(i + look_back), :]
如果要在训练数据中包含3个功能.
If you want the 3 features in your training data.
然后使用
model.add(LSTM(4, input_shape=(look_back,3)))
要指定您的序列中有look_back
个时间步长,每个时间步长都具有3个功能.
To specify that you have look_back
time steps in your sequence, each with 3 features.
它应该运行
实际上,sklearn.preprocessing.MinMaxScaler()
的功能:inverse_transform()
接受的输入与您安装的对象具有相同的形状.因此,您需要执行以下操作:
Indeed, sklearn.preprocessing.MinMaxScaler()
's function : inverse_transform()
takes an input which has the same shape as the object you fitted. So you need to do something like this :
# Get something which has as many features as dataset
trainPredict_extended = np.zeros((len(trainPredict),3))
# Put the predictions there
trainPredict_extended[:,2] = trainPredict
# Inverse transform it and select the 3rd column.
trainPredict = scaler.inverse_transform(trainPredict_extended)[:,2]
我想您的代码中还会遇到类似以下的其他问题,但您无法解决的所有问题都没有解决:) ML部分已修复,您知道错误的出处.只需检查对象的形状,然后尝试使其匹配即可.
I guess you will have other issues like this below in your code but nothing that you can't fix :) the ML part is fixed and you know where the error comes from. Just check the shapes of your objects and try to make them match.