1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-10 14:26:56 +08:00

ensemble & get_exp & dataset_pickle

This commit is contained in:
lzh222333
2021-03-31 02:39:14 +00:00
parent eae94d1ee8
commit 544365f3a9
7 changed files with 249 additions and 164 deletions

View File

@@ -5,9 +5,12 @@ import qlib
from qlib.config import REG_CN
from qlib.model.trainer import task_train
from qlib.workflow import R
from qlib.workflow.task.collect import RollingCollector
from qlib.workflow.task.gen import RollingGen, task_generator
from qlib.workflow.task.manage import TaskManager, run_task
from qlib.workflow.task.collect import RecorderCollector
from qlib.workflow.task.ensemble import RollingEnsemble
import pandas as pd
from qlib.workflow.task.utils import list_recorders
data_handler_config = {
"start_time": "2008-01-01",
@@ -70,7 +73,7 @@ def reset(task_pool, exp_name):
print("========== reset ==========")
TaskManager(task_pool=task_pool).remove()
exp, _ = R.exp_manager._get_or_create_exp(experiment_name=exp_name)
exp, _ = R.get_exp(experiment_name=exp_name)
for rid in exp.list_recorders():
exp.delete_recorder(rid)
@@ -110,19 +113,21 @@ def task_collecting(task_pool, exp_name):
def get_group_key_func(recorder):
task_config = recorder.load_object("task")
return task_config["model"]["class"]
model_key = task_config["model"]["class"]
rolling_key = task_config["dataset"]["kwargs"]["segments"]["test"]
return model_key, model_key, rolling_key
def my_filter(recorder):
# only choose the results of "LGBModel"
task_key = get_group_key_func(recorder)
if task_key == "LGBModel":
model_key, rolling_key = get_group_key_func(recorder)
if model_key == "LGBModel":
return True
return False
rolling_collector = RollingCollector(exp_name)
collector = RecorderCollector(exp_name)
# group tasks by "get_task_key" and filter tasks by "my_filter"
pred_rolling = rolling_collector.collect(get_group_key_func, my_filter)
print(pred_rolling)
artifact = collector.collect(RollingEnsemble(), get_group_key_func, rec_filter_func=my_filter)
print(artifact)
def main(