我使用 Scikit-Learn Python API 在 Python 中训练了一个 xgboost 模型,并使用pickle库对其进行序列化。我将模型上传到 ML Engine,但是当我尝试进行在线预测时,出现以下异常:
Prediction failed: Exception during xgboost prediction: can not initialize DMatrix from DMatrix
Run Code Online (Sandbox Code Playgroud)
我用于预测的 json 示例如下:
{
"instances":[
[
24.90625,
21.6435643564356,
20.3762376237624,
24.3679245283019,
30.2075471698113,
28.0947368421053,
16.7797359774725,
14.9262079299572,
17.9888028979966,
15.3333284503293,
19.6535308744024,
17.1501961307627,
0.0,
0.0,
0.0,
0.0,
0.0,
509.0,
497.0,
439.0,
427.0,
407.0,
1.0,
1.0,
1.0,
1.0,
1.0,
2.0,
23.0,
10.0,
58.0,
11.0,
20.0,
23.3617021276596,
23.3617021276596,
23.3617021276596,
23.3617021276596,
23.3617021276596,
23.9423076923077,
26.3082269243683,
23.6212606363851,
22.6752334301282,
27.4343583104833,
34.0090408101173,
11.1991944104063,
7.33420726455092,
8.15160392948917,
11.4119236389594,
17.9429092915607, …Run Code Online (Sandbox Code Playgroud)