【发布时间】:2019-03-17 15:35:10
【问题描述】:
我只是从 kaggle post 测试这个模型这个模型假设从给定的一组最后的股票预测提前 1 天。如您所见,在调整了一些参数后,我得到了令人惊讶的好结果。
均方误差为 5.193。所以总体而言,它看起来很擅长预测未来的股票,对吧?好吧,当我仔细查看结果时,结果很糟糕。
如您所见,此模型正在预测给定股票的最后价值,即我们当前的最后一只股票。
所以我确实将预测调整到了后退一步..
所以现在您可以清楚地看到该模型预测的是退一步或最后的股票奖励,而不是未来的股票预测。
这是我的训练数据
# So for each element of training set, we have 30 previous training set elements
X_train = []
y_train = []
previous = 30
for i in range(previous,len(training_set_scaled)):
X_train.append(training_set_scaled[i-previous:i,0])
y_train.append(training_set_scaled[i,0])
X_train, y_train = np.array(X_train), np.array(y_train)
print(X_train[-1],y_train[-1])
这是我的模型
# The GRU architecture
regressorGRU = Sequential()
# First GRU layer with Dropout regularisation
regressorGRU.add(GRU(units=50, return_sequences=True, input_shape=(X_train.shape[1],1)))
regressorGRU.add(Dropout(0.2))
# Second GRU layer
regressorGRU.add(GRU(units=50, return_sequences=True))
regressorGRU.add(Dropout(0.2))
# Third GRU layer
regressorGRU.add(GRU(units=50, return_sequences=True))
regressorGRU.add(Dropout(0.2))
# Fourth GRU layer
regressorGRU.add(GRU(units=50))
regressorGRU.add(Dropout(0.2))
# The output layer
regressorGRU.add(Dense(units=1))
# Compiling the RNN
regressorGRU.compile(optimizer='adam',loss='mean_squared_error')
# Fitting to the training set
regressorGRU.fit(X_train,y_train,epochs=50,batch_size=32)
here 是我的完整代码,您也可以在 google colab 运行此代码。
所以我的问题是它背后的原因是什么?我做错了什么有什么建议吗?
【问题讨论】:
-
你是如何处理这个问题的?
-
我仍在努力寻找答案,但从post 你可以看到序列生成部分的一些更新,但我还没有尝试过。
标签: machine-learning keras time-series lstm gated-recurrent-unit