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

update fix CI tests bugs

This commit is contained in:
Young
2021-10-02 08:28:17 +00:00
committed by you-n-g
parent 3a152f9b8b
commit 873129aa9b
10 changed files with 101 additions and 74 deletions

View File

@@ -15,8 +15,6 @@ from qlib.workflow.online.update import LabelUpdater
class TestRolling(TestAutoData):
_setup_kwargs = dict(expression_cache=None, dataset_cache=None)
def test_update_pred(self):
"""
This test is for testing if it will raise error if the `to_date` is out of the boundary.
@@ -26,6 +24,7 @@ class TestRolling(TestAutoData):
task["record"] = {
"class": "SignalRecord",
"module_path": "qlib.workflow.record_temp",
"kwargs": {"dataset": "<DATASET>", "model": "<MODEL>"},
}
exp_name = "online_srv_test"
@@ -65,6 +64,7 @@ class TestRolling(TestAutoData):
task["record"] = {
"class": "SignalRecord",
"module_path": "qlib.workflow.record_temp",
"kwargs": {"dataset": "<DATASET>", "model": "<MODEL>"},
}
exp_name = "online_srv_test"

View File

@@ -47,6 +47,7 @@ def train(uri_path: str = None):
rid = recorder.id
sr = SignalRecord(model, dataset, recorder)
sr.generate()
pred_score = sr.load(sr.get_path("pred.pkl"))
# calculate ic and ric
sar = SigAnaRecord(recorder)
@@ -54,7 +55,7 @@ def train(uri_path: str = None):
ic = sar.load(sar.get_path("ic.pkl"))
ric = sar.load(sar.get_path("ric.pkl"))
return {"ic": ic, "ric": ric}, rid
return pred_score, {"ic": ic, "ric": ric}, rid
def train_with_sigana(uri_path: str = None):
@@ -73,16 +74,20 @@ def train_with_sigana(uri_path: str = None):
with R.start(experiment_name="workflow_with_sigana", uri=uri_path):
R.log_params(**flatten_dict(CSI300_GBDT_TASK))
model.fit(dataset)
recorder = R.get_recorder()
sr = SignalRecord(model, dataset, recorder)
sr.generate()
pred_score = sr.load(sr.get_path("pred.pkl"))
# predict and calculate ic and ric
recorder = R.get_recorder()
sar = SigAnaRecord(recorder, model=model, dataset=dataset)
sar = SigAnaRecord(recorder)
sar.generate()
ic = sar.load(sar.get_path("ic.pkl"))
ric = sar.load(sar.get_path("ric.pkl"))
uri_path = R.get_uri()
return {"ic": ic, "ric": ric}, uri_path
return pred_score, {"ic": ic, "ric": ric}, uri_path
def fake_experiment():
@@ -122,7 +127,9 @@ def backtest_analysis(pred, rid, uri_path: str = None):
the analysis result
"""
recorder = R.get_recorder(experiment_name="workflow", recorder_id=rid)
with R.uri_context(uri=uri_path):
recorder = R.get_recorder(experiment_name="workflow", recorder_id=rid)
dataset = init_instance_by_config(CSI300_GBDT_TASK["dataset"])
model = recorder.load_object("trained_model")

View File

@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from qlib.workflow.record_temp import SignalRecord
import shutil
import unittest
from pathlib import Path
@@ -32,7 +33,8 @@ def train_mse(uri_path: str = None):
R.log_params(**flatten_dict(CSI300_GBDT_TASK))
model.fit(dataset)
recorder = R.get_recorder()
sr = SignalMseRecord(recorder, model=model, dataset=dataset)
SignalRecord(recorder=recorder, model=model, dataset=dataset).generate()
sr = SignalMseRecord(recorder)
sr.generate()
uri = R.get_uri()
return uri