我目前有一个kdb+数据库,其中有大约100万行的财务节拍数据。使用Python3、TensorFlow和numpy,将时间序列财务数据分解为训练/开发/测试集的最佳方法是什么?
This paper建议使用k折交叉验证,它将数据划分为互补的子集。但它来自Spring-2014,在读完它之后,我仍然不清楚如何在实践中实现它。这是最好的解决方案,还是像等待验证这样的东西更适合于财务数据?
我还对学习将本地存储的时间序列数据导入到我的TensorFlow模型的最佳实践很感兴趣。
谢谢。
发布于 2018-03-12 16:40:03
可以使用qPython将数据加载到Python进程中,然后使用sklearn中的KFold将数据集反复拆分为训练和测试部分。假设我们在KDB+端定义了下面的表:
t:([] time:.z.t+til 30;ask:100.0+30?1.0;bid:98+30?1.0)然后,在Python端,您可以执行以下操作来生成训练/测试拆分的索引:
from qpython import qconnection
import pandas as pd
from sklearn.model_selection import KFold
with qconnection.QConnection(host = 'localhost', port = 5001, pandas = True) as q:
X = q.sync('t')
kf = KFold(n_splits=4)
for train_index, test_index in kf.split(X):
print("TRAIN:", train_index, "TEST:", test_index)有关KFold的其他变体,请参阅KFold documentation。
https://stackoverflow.com/questions/48913072
复制相似问题