microsoft / microsoft/qlib

ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[KeyError: 'PRED'].

Open
#1,636 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
48.7k
Forks
7.7k
PR merge metrics
No merged PRs in 30d

Description

🐛 Bug Description

cd examples && qrun .\benchmarks\Linear\workflow_config_linear_Alpha158.yaml
and it output error:
[5468:MainThread](2023-09-03 19:15:58,118) INFO - qlib.Initialization - [config.py:417] - default_conf: client.
[5468:MainThread](2023-09-03 19:15:58,124) INFO - qlib.Initialization - [init.py:74] - qlib successfully initialized based on client settings.
[5468:MainThread](2023-09-03 19:15:58,125) INFO - qlib.Initialization - [init.py:76] - data_path={'__DEFAULT_FREQ': WindowsPath('C:/Users/hsz/.qlib/qlib_data/cn_data')}
[5468:MainThread](2023-09-03 19:15:58,129) INFO - qlib.workflow - [exp.py:258] - Experiment 1 starts running ...
[5468:MainThread](2023-09-03 19:15:58,506) INFO - qlib.workflow - [recorder.py:341] - Recorder fef59cb8c44b4c2da1422e3df21ee0e3 starts running under Experiment 1 ...
[5468:MainThread](2023-09-03 19:17:10,487) INFO - qlib.timer - [log.py:128] - Time cost: 66.236s | Loading data Done
C:\Program Files\Python39\lib\site-packages\numpy\lib\nanfunctions.py:1096: RuntimeWarning: All-NaN slice encountered
result = np.apply_along_axis(_nanmedian1d, axis, a, overwrite_input)
[5468:MainThread](2023-09-03 19:17:32,525) INFO - qlib.timer - [log.py:128] - Time cost: 21.523s | RobustZScoreNorm Done
[5468:MainThread](2023-09-03 19:17:33,175) INFO - qlib.timer - [log.py:128] - Time cost: 0.648s | Fillna Done
[5468:MainThread](2023-09-03 19:17:33,604) INFO - qlib.timer - [log.py:128] - Time cost: 0.259s | DropnaLabel Done
C:\Program Files\Python39\lib\site-packages\qlib\data\dataset\processor.py:360: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df[cols] = t
[5468:MainThread](2023-09-03 19:17:34,136) INFO - qlib.timer - [log.py:128] - Time cost: 0.531s | CSRankNorm Done
[5468:MainThread](2023-09-03 19:17:34,167) INFO - qlib.timer - [log.py:128] - Time cost: 23.679s | fit & process data Done
[5468:MainThread](2023-09-03 19:17:34,168) INFO - qlib.timer - [log.py:128] - Time cost: 89.917s | Init data Done
[5468:MainThread](2023-09-03 19:17:37,246) INFO - qlib.timer - [log.py:128] - Time cost: 0.000s | waiting async_log Done
[5468:MainThread](2023-09-03 19:17:37,253) ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[KeyError: 'PRED'].
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Program Files\Python39\Scripts\qrun.exe_main
.py", line 7, in
sys.exit(run())
File "C:\Program Files\Python39\lib\site-packages\qlib\workflow\cli.py", line 115, in run
fire.Fire(workflow)
File "C:\Program Files\Python39\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "C:\Program Files\Python39\lib\site-packages\fire\core.py", line 475, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "C:\Program Files\Python39\lib\site-packages\fire\core.py", line 691, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\qlib\workflow\cli.py", line 109, in workflow
recorder = task_train(config.get("task"), experiment_name=experiment_name)
File "C:\Program Files\Python39\lib\site-packages\qlib\model\trainer.py", line 127, in task_train
exe_task(task_config)
File "C:\Program Files\Python39\lib\site-packages\qlib\model\trainer.py", line 56, in exe_task
task_config = fill_placeholder(task_config, placehorder_value)
File "C:\Program Files\Python39\lib\site-packages\qlib\utils_init
.py", line 930, in fill_placeholder
now_item[key] = get_item_from_obj(config, m.groupdict()["name_path"])
File "C:\Program Files\Python39\lib\site-packages\qlib\utils_init
.py", line 875, in get_item_from_obj
cur_cfg = cur_cfg[k]
KeyError: 'PRED'

To Reproduce

Steps to reproduce the behavior:

1.cd examples && qrun .\benchmarks\Linear\workflow_config_linear_Alpha158.yaml
1.
1.

Expected Behavior

Screenshot

Environment

Note: User could run cd scripts && python collect_info.py all under project directory to get system information
and paste them here directly.

  • Qlib version:pyqlib-0.9.3.99
  • Python version:python3.9
  • OS (Windows, Linux, MacOS):Windows
  • Commit number (optional, please provide it if you are using the dev version):

Additional Notes

Any workflow configuration that contains PREV will report an error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/benchmarks/Linear/workflow_config_linear_Alpha158.yaml and trace the PREV placeholder through qlib/model/trainer.py and qlib/utils/init.py, especially fill_placeholder and get_item_from_obj. Reproduce the command from the issue, then verify that workflow configurations containing PREV no longer fail with KeyError: 'PRED'.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.