问答交流

XGBoostError: 回测正常,模拟报错

由bq9nacjt创建,最终由bqkzh1gu 被浏览 12 用户

策略社区的XGBoost模板,只是修改了训练、回测数据日期,执行回测时正常,但提交模拟就报错,策略已分享给小Q,下面是报错信息

2025-03-10 20:24:00 任务运行开始调度 state=trigger event= 5ec3d941-73b9-47ca-8183-759397725f79 ..

2

2025-03-10 20:24:01 任务运行状态更新 state=scheduled event=20250310 5ec3d941-73b9-47ca-8183-759397725f79

3

2025-03-10 20:24:04 任务运行状态更新 state=running event=20250310 5ec3d941-73b9-47ca-8183-759397725f79

4

2025-03-10 20:24:04 [info ] run task_id='5ec3d941-73b9-47ca-8183-759397725f79' ..

5

2025-03-10 20:24:04 [info ] fetch task 5ec3d941-73b9-47ca-8183-759397725f79 ..

6

2025-03-10 20:24:04 [info ] start 5ec3d941-73b9-47ca-8183-759397725f79.ipynb ..

7

0.00s - Debugger warning: It seems that frozen modules are being used, which may

8

0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off

9

0.00s - to python to disable frozen modules.

10

0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

11

0.00s - Debugger warning: It seems that frozen modules are being used, which may

12

0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off

13

0.00s - to python to disable frozen modules.

14

0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

15

[2025-03-10 20:24:06] [info ] input_features_dai.v30 开始运行 ..

16

[2025-03-10 20:24:07] [info ] input_features_dai.v30 命中缓存

17

[2025-03-10 20:24:07] [info ] input_features_dai.v30 运行完成 [1.046s].

18

[2025-03-10 20:24:07] [info ] input_features_dai.v30 开始运行 ..

19

[2025-03-10 20:24:07] [info ] input_features_dai.v30 命中缓存

20

[2025-03-10 20:24:07] [info ] input_features_dai.v30 运行完成 [0.064s].

21

[2025-03-10 20:24:07] [warning ] cache disabled for paper/live trading for bound date

22

[2025-03-10 20:24:07] [info ] extract_data_dai.v18 开始运行 ..

23

[2025-03-10 20:24:07] [warning ] start_date='2025-03-10', end_date='2025-03-10', query_start_date='2024-08-22 00:00:00' (支持加速 [url="command:switch-quota"]升级资源[/url]) ..

24

[2025-03-10 20:24:15] [info ] data extracted: (5126, 17)

25

[2025-03-10 20:24:15] [info ] extract_data_dai.v18 运行完成 [7.403s].

26

[2025-03-10 20:24:15] [info ] input_features_dai.v30 开始运行 ..

27

[2025-03-10 20:24:15] [info ] input_features_dai.v30 命中缓存

28

[2025-03-10 20:24:15] [info ] input_features_dai.v30 运行完成 [0.054s].

29

[2025-03-10 20:24:15] [warning ] cache disabled for paper/live trading for bound date

30

[2025-03-10 20:24:15] [info ] extract_data_dai.v18 开始运行 ..

31

[2025-03-10 20:24:15] [warning ] start_date='2025-03-10', end_date='2025-03-10', query_start_date='2025-03-10 00:00:00' (支持加速 [url="command:switch-quota"]升级资源[/url]) ..

32

[2025-03-10 20:24:17] [info ] data extracted: (0, 16)

33

[2025-03-10 20:24:17] [warning ] data extracted: 0 rows

34

[2025-03-10 20:24:17] [info ] extract_data_dai.v18 运行完成 [1.694s].

35

[2025-03-10 20:24:17] [info ] python.v2 开始运行 ..

36

2025-03-10 20:24:19 任务运行状态更新 state=failed event=20250310 5ec3d941-73b9-47ca-8183-759397725f79

37

Traceback (most recent call last):

38

File "/var/app/enabled/aiflowtaskrun.py", line 199, in <module>

39

run(run_id=sys.argv[1], task_id=sys.argv[2], event_name=sys.argv[3], dry_run=sys.argv[4])

40

File "/var/app/enabled/aiflowtaskrun.py", line 194, in run

41

raise ex from ex

42

File "/var/app/enabled/aiflowtaskrun.py", line 181, in run

43

do_run(task_id, event_name)

44

File "/var/app/enabled/aiflowtaskrun.py", line 146, in do_run

45

pm.execute_notebook(

46

File "/opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/papermill/execute.py", line 134, in execute_notebook

47

raise_for_execution_errors(nb, output_path)

48

File "/opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/papermill/execute.py", line 241, in raise_for_execution_errors

49

raise error

50

papermill.exceptions.PapermillExecutionError:

51

---------------------------------------------------------------------------

52

Exception encountered at "In [1]":

53

---------------------------------------------------------------------------

54

XGBoostError Traceback (most recent call last)

55

Cell In[1], line 340

56

327 m3 = M.extract_data_dai.v18(

57

328 sql=m7.data,

58

329 start_date="""2020-01-01""",

59

(...)

60

336 m_name="""m3"""

61

337 )

62

339 # @module(position="-697,-697", comment="""模型训练""")

63

--> 340 m8 = M.python.v2(

64

341 input_1=m3.data,

65

342 run=m8_run_bigquant_run,

66

343 do_run=True,

67

344 post_run_outputs_=m8_post_run_outputs__bigquant_run,

68

345 m_name="""m8"""

69

346 )

70

348 # @module(position="-565,-595", comment="""模型预测""")

71

349 m9 = M.python.v2(

72

350 input_1=m8.data_1,

73

351 input_2=m5.data,

74

(...)

75

356 m_name="""m9"""

76

357 )

77

78

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/modules.py:28, in call(self, **kwargs)

79

80

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:203, in module_invoke(name, version, kwargs)

81

82

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:169, in _module_invoke(name, version, kwargs)

83

84

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:41, in _module_run(module, kwargs)

85

86

File dist/build/python/v2/init.py:60, in v2.run()

87

88

Cell In[1], line 64, in m8_run_bigquant_run(input_1, input_2, input_3)

89

60 raise e

90

63 df = training_ds.read()

91

---> 64 dm = prepare_data(df, features, group_col)

92

65 parameters = {"objective":objective_map[objective], "booster": booster, "max_depth": max_depth, "nthread": nthread}

93

66 print('-----', parameters)

94

95

Cell In[1], line 55, in m8_run_bigquant_run.<locals>.prepare_data(df, features, group_col)

96

53 dm = xgb.DMatrix(data, label=label)

97

54 if group_col:

98

---> 55 dm.set_group(list(df.groupby(group_col).apply(len)))

99

56 dm.feature_names = features

100

57 return dm

101

102

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/core.py:997, in DMatrix.set_group(self, group)

103

989 """Set group size of DMatrix (used for ranking).

104

990

105

991 Parameters

106

(...)

107

994 Group size of each group

108

995 """

109

996 from .data import dispatch_meta_backend

110

--> 997 dispatch_meta_backend(self, group, 'group', 'uint32')

111

112

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/data.py:1108, in dispatch_meta_backend(matrix, data, name, dtype)

113

1106 return

114

1107 if _is_list(data):

115

-> 1108 _meta_from_list(data, name, dtype, handle)

116

1109 return

117

1110 if _is_tuple(data):

118

119

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/data.py:1047, in _meta_from_list(data, field, dtype, handle)

120

1040 def _meta_from_list(

121

1041 data: Sequence,

122

1042 field: str,

123

1043 dtype: Optional[NumpyDType],

124

1044 handle: ctypes.c_void_p

125

1045 ) -> None:

126

1046 data_np = np.array(data)

127

-> 1047 _meta_from_numpy(data_np, field, dtype, handle)

128

129

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/data.py:1037, in _meta_from_numpy(data, field, dtype, handle)

130

1035 raise ValueError("Masked array is not supported.")

131

1036 interface_str = _array_interface(data)

132

-> 1037 _check_call(_LIB.XGDMatrixSetInfoFromInterface(handle, c_str(field), interface_str))

133

134

File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/core.py:279, in _check_call(ret)

135

268 """Check the return value of C API call

136

269

137

270 This function will raise exception when error occurs.

138

(...)

139

276 return value from API calls

140

277 """

141

278 if ret != 0:

142

--> 279 raise XGBoostError(py_str(_LIB.XGBGetLastError()))

143

144

XGBoostError: [20:24:18] ../src/c_api/../data/array_interface.h:468: Unicode-6 is not supported.

145

Stack trace:

146

[bt] (0) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x128d29) [0x7fa1cc176d29]

147

[bt] (1) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x15c8ac) [0x7fa1cc1aa8ac]

148

[bt] (2) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x15dcfa) [0x7fa1cc1abcfa]

149

[bt] (3) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x208997) [0x7fa1cc256997]

150

[bt] (4) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x209ed2) [0x7fa1cc257ed2]

151

[bt] (5) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(+0x20bab0) [0x7fa1cc259ab0]

152

[bt] (6) /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/xgboost/lib/libxgboost.so(XGDMatrixSetInfoFromInterface+0xad) [0x7fa1cc17797d]

153

[bt] (7) /lib64/libffi.so.8(+0x78d6) [0x7fa2f95c98d6]

154

[bt] (8) /lib64/libffi.so.8(+0x4556) [0x7fa2f95c6556]

标签

XGBoost回测
评论
  • 看起来是xgboost的问题,XGBoostError: [18:33:46] ../src/c_api/../data/array_interface.h:468: Unicode-6 is not supported.
  • https://bigquant.com/quantagent/share/be2733af-5465-4357-a44e-7384764ef6ce
{link}