1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-03 19:10:58 +08:00

Update test_dataset

This commit is contained in:
lwwang1995
2020-12-05 22:36:04 +08:00
committed by you-n-g
parent d2d865fb7a
commit 60f62482b7

38
tests/test_dataset.py Normal file → Executable file
View File

@@ -6,6 +6,8 @@ import sys
from qlib.tests import TestAutoData
from qlib.data.dataset import TSDatasetH
import numpy as np
from torch.utils.data import DataLoader
import time
class TestDataset(TestAutoData):
@@ -20,6 +22,36 @@ class TestDataset(TestAutoData):
"fit_start_time": "2008-01-01",
"fit_end_time": "2014-12-31",
"instruments": "csi300",
"infer_processors": [
{
"class" : "DropCol",
"kwargs":{"col_list": ["VWAP0"]}
},
{
"class" : "FilterCol",
"kwargs":{"col_list": ["RESI5", "WVMA5", "RSQR5"]}
},
{
"class" : "CSZFillna",
"kwargs":{"fields_group": "feature"}
}
],
"learn_processors": [
{
"class" : "DropCol",
"kwargs":{"col_list": ["VWAP0"]}
},
{
"class" : "DropnaProcessor",
"kwargs":{"fields_group": "feature"}
},
"DropnaLabel",
{
"class": "CSZScoreNorm",
"kwargs": {"fields_group": "label"}
}
],
"process_type": "independent"
},
},
segments={
@@ -28,8 +60,12 @@ class TestDataset(TestAutoData):
"test": ("2017-01-01", "2020-08-01"),
},
)
_ = tsdh.prepare("train") # Test the correctness
tsds_train = tsdh.prepare("train") # Test the correctness
tsds = tsdh.prepare("valid") # prepare a dataset with is friendly to converting tabular data to time-series
train_loader = DataLoader(tsds_train, batch_size=800, shuffle=True)
for data in train_loader:
now = time.localtime()
print(time.strftime("%Y-%m-%d-%H_%M_%S", now))
# The dimension of sample is same as tabular data, but it will return timeseries data of the sample