gpt4 book ai didi

python - 如何使用 Keras Python 3 查找总损失、准确性、预测日期时间?

转载 作者:行者123 更新时间:2023-11-30 22:11:54 25 4
gpt4 key购买 nike

我正在尝试预测 OHLC 值。到目前为止我已经实现了这一点:
Jupyter Note of the complete code

正如人们所看到的,我的代码正在运行。但我对我创建的模型没有什么疑问。

  1. 我不知道预测的输出有多准确。
  2. 错误损失是否有所改善。

我什至无法理解为什么所做的预测在图表上没有日期和时间?我想知道预测是在哪一天做出的。

我怎样才能实现目标?有没有办法将 OHLC 与预测时间结合起来?

最佳答案

要使用这些指标:

On the docs page of metrics of Keras

Usage of metrics

A metric is a function that is used to judge the performance of your model. Metric functions are to be supplied in the metrics parameter when a model is compiled.

A metric function is similar to a loss function, except that the results from evaluating a metric are not used when training the model.

model.compile(loss='mean_squared_error',optimizer='sgd', metrics=['mae', 'acc'])

You can either pass the name of an existing metric, or pass a Theano/TensorFlow symbolic function (see Custom metrics).

Arguments

y_true: True labels. Theano/TensorFlow tensor.

y_pred: Predictions. Theano/TensorFlow tensor of the same shape as y_true.

Returns

Single tensor value representing the mean of the output array across all datapoints.

并在训练后评估模型的性能,您可以使用

On the docs page of Model of Keras

evaluate

evaluate(self, x=None, y=None, batch_size=None, verbose=1, sample_weight=None, steps=None)

Returns

the loss value & metrics values for the model in test mode.

就你的情况

我想你只需要更改这些行:

model_open.compile(loss='mse', optimizer='rmsprop')
model_high.compile(loss='mse', optimizer='rmsprop')
model_low.compile(loss='mse', optimizer='rmsprop')
model_close.compile(loss='mse', optimizer='rmsprop')

model_open.compile(loss='mse', optimizer='rmsprop', metrics=['mae', 'acc'])
model_high.compile(loss='mse', optimizer='rmsprop', metrics=['mae', 'acc'])
model_low.compile(loss='mse', optimizer='rmsprop', metrics=['mae', 'acc'])
model_close.compile(loss='mse', optimizer='rmsprop', metrics=['mae', 'acc'])

最后用以下方法评估模型:

model_open.evaluate( testX_open, testY_open)
model_high.evaluate( testX_high, testY_high)
model_low.evaluate( testX_low, testY_low)
model_close.evaluate(testX_close,testY_close)

要在训练栏上添加准确度 acc 等指标,您只需像这样修改编译语句。

关于python - 如何使用 Keras Python 3 查找总损失、准确性、预测日期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51282076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com