简体   繁体   English

如何为股票预测输出CNN的值

[英]How to output a value of a CNN for Stock Prediction

I built an LSTM based Neural Network to predict the price of BTC. 我建立了一个基于LSTM的神经网络来预测BTC的价格。 Its training is decent I'd say, but I'm not sure about how to make it predict tomorrow's price for example. 它的培训是不错的我会说,但我不知道如何让它预测明天的价格。

I tried Keras' method predict for my trained model with today's price as argument and then tensorflow's "tf.argmax" to pick the highest certainty in the array outputed. 我尝试了Keras的方法predict我训练的模型,以今天的价格作为参数,然后是tensorflow的“tf.argmax”来挑选阵列中最高的确定性。 Now I know that it refers to the class predicted in the case of computer vision but I really have no clue about what those probabilities refer to in that case. 现在我知道它指的是在计算机视觉的情况下预测的类,但我真的不知道那些概率在这种情况下所指的是什么。

Model built: 型号内置:


  model = Sequential()
  model.add(LSTM(neurons, return_sequences=True, input_shape=(inputs.shape[1], inputs.shape[2]), activation=activ_func))
  model.add(Dropout(dropout))
  model.add(LSTM(neurons, return_sequences=True, activation=activ_func))
  model.add(Dropout(dropout))
  model.add(LSTM(neurons, activation=activ_func))
  model.add(Dropout(dropout))
  model.add(Dense(units=output_size))
  model.add(Activation(activ_func))
  model.compile(loss=loss, optimizer=optimizer, metrics=['mae'])
  model.summary()
  plot_keras_model(model, show_shapes=True, show_layer_names=False)

Training and prediction: 培训和预测:


prediction_data = get_today_price4prediction('bitcoin', tag="BTC")
X_prediction = create_inputs(prediction_data)
X_prediction = to_array(X_prediction)
btc_history = btc_model.fit(X_train, Y_train_btc, epochs=epochs, batch_size=batch_size, verbose=1, validation_data=(X_test, Y_test_btc), shuffle=False)
predictions = btc_model.predict(X_prediction, verbose=1, steps=None)
plot_results(btc_history, btc_model, Y_train_btc, coin='BTC')
predictions = tf.math.argmax(predictions)
print(predictions)

The expected output is a 7D numpy array with values from 1 to 1e-7 . 预期输出是7D numpy数组,值为11e-7 But I dont know what those values refers to. 但我不知道这些价值所指的是什么。 Any suggestion? 有什么建议吗?

Sounds like you are trying to get results without knowing your data. 听起来你正试图在不知道你的数据的情况下得到结果。 Don't ever do that, you are likely to end up with useless results. 不要那么做,你可能会得到无用的结果。

I don't know where you got the data from, but that place should describe what the target is. 我不知道你从哪里得到数据,但那个地方应该描述目标是什么。 In this case it is probably a categorical target because of the multi-dimensional output (it is if you're using categorical crossentropy loss for example but it is also not stated in the code). 在这种情况下,由于多维输出,它可能是一个分类目标(例如,如果你使用分类的交叉熵损失,但它也没有在代码中说明)。 If that is the case and the output you expect is a real number, the categories are probably ranges of this number, and each value in the output array would be the probability that this number belongs to each of these ranges. 如果是这种情况并且您期望的输出是实数,则类别可能是此数字的范围,并且输出数组中的每个值将是该数字属于这些范围中的每一个的概率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM