我正在使用树算法(决策树、随机森林和 XGBoost)来预测股票市场回报的符号(分类)。
我使用这篇文章作为参考:
在拆分训练集和测试集时,作者使用如下R代码:
index <- sample(1:nrow(stock_indicators))
size=0.2*nrow(stock_indicators)
test <- stock_indicators[index, ]
train <- stock_indicators[-index, ]
使用一组随机日期将测试集和训练集与时间序列财务数据分开是否正确?
对我来说,这看起来像是前瞻偏见。
这将是替代方案:
train <-head(stock_indicators,round(0.70 * nrow(stock_indicators)))
test <- tail(stock_indicators,round(0.30 * nrow(stock_indicators)))
但是通过这种拆分,即使尝试使用不同的数据集,我也无法获得显着的准确性。
你有什么建议吗?