Fix bugs in the new models

This commit is contained in:
D-X-Y
2021-03-24 21:17:55 +08:00
parent 15dda79e3b
commit e7467fd474
4 changed files with 67 additions and 60 deletions

View File

@@ -2,17 +2,42 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"library path: /Users/xuanyidong/Desktop/XAutoDL/lib\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[95290:MainThread](2021-03-03 12:14:32,922) INFO - qlib.Initialization - [config.py:276] - default_conf: client.\n",
"[95290:MainThread](2021-03-03 12:14:32,925) WARNING - qlib.Initialization - [config.py:291] - redis connection failed(host=127.0.0.1 port=6379), cache will not be used!\n",
"[95290:MainThread](2021-03-03 12:14:33,203) INFO - qlib.Initialization - [__init__.py:46] - qlib successfully initialized based on client settings.\n",
"[95290:MainThread](2021-03-03 12:14:33,205) INFO - qlib.Initialization - [__init__.py:47] - data_path=/Users/xuanyidong/.qlib/qlib_data/cn_data\n"
"[61704:MainThread](2021-03-22 13:56:38,104) INFO - qlib.Initialization - [config.py:276] - default_conf: client.\n",
"[61704:MainThread](2021-03-22 13:56:38,106) WARNING - qlib.Initialization - [config.py:291] - redis connection failed(host=127.0.0.1 port=6379), cache will not be used!\n",
"[61704:MainThread](2021-03-22 13:56:38,680) INFO - qlib.Initialization - [__init__.py:46] - qlib successfully initialized based on client settings.\n",
"[61704:MainThread](2021-03-22 13:56:38,681) INFO - qlib.Initialization - [__init__.py:47] - data_path=/Users/xuanyidong/.qlib/qlib_data/cn_data\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'class': 'DatasetH',\n",
" 'kwargs': {'handler': {'class': 'Alpha158',\n",
" 'kwargs': {'end_time': '2020-08-01',\n",
" 'fit_end_time': '2014-12-31',\n",
" 'fit_start_time': '2008-01-01',\n",
" 'instruments': 'csi100',\n",
" 'start_time': '2008-01-01'},\n",
" 'module_path': 'qlib.contrib.data.handler'},\n",
" 'segments': {'test': ('2017-01-01', '2020-08-01'),\n",
" 'train': ('2008-01-01', '2014-12-31'),\n",
" 'valid': ('2015-01-01', '2016-12-31')}},\n",
" 'module_path': 'qlib.data.dataset'}\n"
]
}
],
@@ -24,6 +49,16 @@
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"from pathlib import Path\n",
"\n",
"__file__ = os.path.dirname(os.path.realpath(\"__file__\"))\n",
"\n",
"lib_dir = (Path(__file__).parent / \"..\" / \"lib\").resolve()\n",
"print(\"library path: {:}\".format(lib_dir))\n",
"assert lib_dir.exists(), \"{:} does not exist\".format(lib_dir)\n",
"if str(lib_dir) not in sys.path:\n",
" sys.path.insert(0, str(lib_dir))\n",
"\n",
"from qlib import config as qconfig\n",
"from qlib.utils import init_instance_by_config\n",
"\n",
@@ -41,7 +76,7 @@
" \"end_time\": \"2020-08-01\",\n",
" \"fit_start_time\": \"2008-01-01\",\n",
" \"fit_end_time\": \"2014-12-31\",\n",
" \"instruments\": \"csi300\",\n",
" \"instruments\": \"csi100\",\n",
" },\n",
" },\n",
" \"segments\": {\n",
@@ -50,7 +85,15 @@
" \"test\": (\"2017-01-01\", \"2020-08-01\"),\n",
" },\n",
" },\n",
" }"
" }\n",
"pprint.pprint(dataset_config)\n",
"dataset = init_instance_by_config(dataset_config)\n",
"\n",
"df_train, df_valid, df_test = dataset.prepare(\n",
" [\"train\", \"valid\", \"test\"],\n",
" col_set=[\"feature\", \"label\"],\n",
" data_key=DataHandlerLP.DK_L,\n",
" )"
]
},
{
@@ -89,39 +132,10 @@
}
],
"source": [
"pprint.pprint(dataset_config)\n",
"dataset = init_instance_by_config(dataset_config)"
"from trade_models.transformations import get_transformer\n",
"\n",
"model = get_transformer(None)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'class': 'MLflowExpManager', 'module_path': 'qlib.workflow.expm', 'kwargs': {'uri': 'file:/Users/xuanyidong/Desktop/AutoDL-Projects/notebooks/Q/mlruns', 'default_exp_name': 'Experiment'}}\n",
"Wrapper(provider=<qlib.workflow.QlibRecorder object at 0x7ff46b8a4850>)\n",
"<qlib.workflow.expm.MLflowExpManager object at 0x7ff46b8a4c10>\n"
]
}
],
"source": [
"from qlib.workflow import R\n",
"from qlib.config import C\n",
"print(C.exp_manager)\n",
"print(R)\n",
"print(R.exp_manager)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -140,7 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.8.8"
}
},
"nbformat": 4,