【发布时间】:2021-01-08 23:28:03
【问题描述】:
我正在研究一个时间序列问题并且我训练了一个模型 与财务数据。在网的训练过程中表现非常好。
现在我在问如何预测未来的 FORWARD 使用 Tensorflow 模型对新数据集进行预测函数的结果是什么。下面的 sn-p 显示了预测函数的调用
def predict(self, data=None ):
model = tf.keras.models.load_model(self.createModelFileName())
scaler = MinMaxScaler()
feature_scaler = MinMaxScaler()
data.loc[:, data.columns != self.feature] = scaler.fit_transform(data.loc[:, data.columns != self.feature])
data[[self.feature]] = feature_scaler.fit_transform(data[[self.feature]])
inputs = data[1:]
inputs = np.expand_dims(inputs, axis=0)
print(f'Shape data: {data}')
print(f'Shape inputs: {inputs.shape}')
prediction = model.predict(inputs, 32, steps=5, verbose=1)
print(prediction.shape)
data[[self.feature]] = feature_scaler.inverse_transform(data[[self.feature]])
inputs = np.array(data[self.feature])
prediction = prediction[0,:,:]
print(prediction.shape)
prediction = feature_scaler.inverse_transform(prediction)
return inputs, prediction
我所做的图只是显示了使用任意偏移对过去输入的预测,而不是对未来的预测。
我知道自动回归这个术语,我也尝试过,通过使用最后的预测值扩展预测函数的输入。
【问题讨论】:
标签: python-3.x tensorflow machine-learning