qlib icon indicating copy to clipboard operation
qlib copied to clipboard

TypeError: mean() got an unexpected keyword argument 'level'

Open andy071001 opened this issue 7 months ago • 1 comments

🐛 Bug Description

To Reproduce

Steps to reproduce the behavior:

(qlib_test) roger@beijing:~/anaconda3/envs/rdagent_test/lib/python3.10/site-packages/rdagent/qlib_repo/qlib/examples/highfreq$ qrun workflow_config_High_Freq_Tree_Alpha158.yaml [290722:MainThread](2025-05-06 19:00:03,943) INFO - qlib.qrun - [cli.py:78] - Render the template with the context: {} [290722:MainThread](2025-05-06 19:00:03,950) INFO - qlib.Initialization - [config.py:420] - default_conf: client. [290722:MainThread](2025-05-06 19:00:03,952) INFO - qlib.Initialization - [init.py:74] - qlib successfully initialized based on client settings. [290722:MainThread](2025-05-06 19:00:03,952) INFO - qlib.Initialization - [init.py:76] - data_path={'__DEFAULT_FREQ': PosixPath('/home/roger/.qlib/qlib_data/cn_data_1min')} [290722:MainThread](2025-05-06 19:00:03,956) WARNING - qlib.workflow - [expm.py:231] - No valid experiment found. Create a new experiment with name workflow. [290722:MainThread](2025-05-06 19:00:03,958) INFO - qlib.workflow - [exp.py:258] - Experiment 349096071971132076 starts running ... [290722:MainThread](2025-05-06 19:00:04,220) INFO - qlib.workflow - [recorder.py:345] - Recorder 89be48867a894dc8bc562697f6e09db3 starts running under Experiment 349096071971132076 ... ModuleNotFoundError. CatBoostModel are skipped. (optional: maybe installing CatBoostModel can fix it.) ModuleNotFoundError. XGBModel is skipped(optional: maybe installing xgboost can fix it). ModuleNotFoundError. PyTorch models are skipped (optional: maybe installing pytorch can fix it). [290722:MainThread](2025-05-06 19:00:22,751) INFO - qlib.timer - [log.py:127] - Time cost: 18.270s | Loading data Done /home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/numpy/lib/_nanfunctions_impl.py:1233: RuntimeWarning: All-NaN slice encountered return fnb._ureduce(a, func=_nanmedian, keepdims=keepdims, [290722:MainThread](2025-05-06 19:00:33,364) INFO - qlib.timer - [log.py:127] - Time cost: 8.424s | RobustZScoreNorm Done [290722:MainThread](2025-05-06 19:00:35,410) INFO - qlib.timer - [log.py:127] - Time cost: 2.046s | Fillna Done [290722:MainThread](2025-05-06 19:00:39,221) INFO - qlib.timer - [log.py:127] - Time cost: 0.752s | DropnaLabel Done /home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/data/dataset/processor.py:363: 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 [290722:MainThread](2025-05-06 19:00:39,919) INFO - qlib.timer - [log.py:127] - Time cost: 0.698s | CSRankNorm Done [290722:MainThread](2025-05-06 19:00:39,923) INFO - qlib.timer - [log.py:127] - Time cost: 17.172s | fit & process data Done [290722:MainThread](2025-05-06 19:00:39,924) INFO - qlib.timer - [log.py:127] - Time cost: 35.443s | Init data Done [290722:MainThread](2025-05-06 19:00:39,924) WARNING - qlib.utils - [init.py:849] - The parameter reweighter with value None is ignored. [290722:MainThread](2025-05-06 19:00:41,360) INFO - qlib.timer - [log.py:127] - Time cost: 0.000s | waiting async_log Done [290722:MainThread](2025-05-06 19:00:41,361) ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[TypeError: mean() got an unexpected keyword argument 'level']. File "/home/roger/anaconda3/envs/qlib_test/bin/qrun", line 8, in sys.exit(run()) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/workflow/cli.py", line 153, in run fire.Fire(workflow) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/fire/core.py", line 135, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/workflow/cli.py", line 147, in workflow recorder = task_train(config.get("task"), experiment_name=experiment_name) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/model/trainer.py", line 127, in task_train _exe_task(task_config) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/model/trainer.py", line 49, in _exe_task auto_filter_kwargs(model.fit)(dataset, reweighter=reweighter) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/utils/init.py", line 852, in _func return func(*args, **new_kwargs) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/contrib/model/highfreq_gdbt_model.py", line 120, in fit dtrain, dvalid = self._prepare_data(dataset) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/qlib/contrib/model/highfreq_gdbt_model.py", line 93, in _prepare_data df_train["label"][l_name] = df_train["label"][l_name] - df_train["label"][l_name].mean(level=0) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/core/series.py", line 6549, in mean return NDFrame.mean(self, axis, skipna, numeric_only, **kwargs) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/core/generic.py", line 12420, in mean return self._stat_function( File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/core/generic.py", line 12373, in _stat_function nv.validate_func(name, (), kwargs) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/compat/numpy/function.py", line 418, in validate_func return validation_func(args, kwargs) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/compat/numpy/function.py", line 88, in call validate_args_and_kwargs( File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/util/_validators.py", line 223, in validate_args_and_kwargs validate_kwargs(fname, kwargs, compat_args) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/util/_validators.py", line 164, in validate_kwargs _check_for_invalid_keys(fname, kwargs, compat_args) File "/home/roger/anaconda3/envs/qlib_test/lib/python3.10/site-packages/pandas/util/_validators.py", line 138, in _check_for_invalid_keys raise TypeError(f"{fname}() got an unexpected keyword argument '{bad_arg}'") TypeError: mean() got an unexpected keyword argument 'level'

seems the highfreq model has some problem

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:
  • Python version:
  • OS (Windows, Linux, MacOS):
  • Commit number (optional, please provide it if you are using the dev version):

Additional Notes

andy071001 avatar May 06 '25 11:05 andy071001

Hi, @andy071001 TypeError: mean() got an unexpected keyword argument 'level' Series.mean(level=0), which has been removed or is no longer recommended in newer versions of Pandas. This has been fixed in PR 1917, and has now been merged, so please pull the latest main branch code and retry.

SunsetWolf avatar May 13 '25 12:05 SunsetWolf