0

pycaret我用(v2.3.0)训练了一个模型,如下所示:

setup(df_train, target='y', fold_shuffle=True, silent=True)
model = create_model('rf')
model.predict(df_valid)


> array([21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
   21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
   21, 21, 21, 21, 21, 21, 21, 43, 43, 22, 43, 18, 20, 19, 43, 43, 43,
   43, 43, 22, 18, 18, 43, 23, 23, 23, 23, 23, 23, 23, 23, 12, 12, 12,
   12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 25, 25, 13, 25,
   25, 13, 25, 25, 25, 25, 25, 23, 25, 25, 25, 25, 25, 25, 43, 27, 27,
   27, 27, 13, 19, 19, 19, 19, 19, 12, 19, 19, 19, 19, 20, 19, 19, 19,
   20, 20, 20, 19, 19, 12, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
   18, 18, 18, 18, 18, 18, 18, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
   13, 13, 13, 13, 13, 51, 13, 13, 13, 13, 13, 13, 45, 13, 13, 13, 13,
   13, 13, 13, 45, 45, 45, 13, 13,  7,  7,  7,  7,  7,  7,  7,  7, 13,
   13, 13, 13, 13, 13, 13, 54,  2, 13, 13, 13, 13, 13, 13, 13, 13, 13,
   13, 13, 13, 13, 13, 13, 13, 21, 24, 24, 24, 24, 24, 24,  0, 24, 24,
   24, 24, 24, 24, 24, 13, 24, 42, 42, 42, 42, 42, 42, 42, 42,  2, 21,
   10,  2, 29, 21, 21, 10,  2,  8,  8,  2,  2, 10,  2,  2,  2, 21, 21,
    8, 21, 21,  8, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
    6, 21, 21,  8,  8,  8, 21,  8,  8,  8, 13, 13, 13, 21, 38, 21, 21,
   21, 38, 52, 21, 21, 21, 21, 52, 36, 33, 36, 36, 33, 36, 36, 52, 53,
   53, 41, 41, 21, 41, 41, 41, 41, 31, 31, 31, 31, 31, 31, 31, 31, 14,
   14, 14, 14, 31, 14, 14, 14, 21, 15, 14, 14, 15, 14, 14, 14, 15, 14,
   14, 14, 14, 14, 15, 42, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
   15, 29, 34, 29, 29, 29, 29, 29, 29, 33, 30, 30, 33, 30, 33, 52, 53,
   21, 38, 38, 30, 52, 53, 30, 33, 52, 53, 38, 38, 30, 21, 38, 52, 38,
   52, 52, 21, 21, 21, 52, 52, 27, 21, 21, 21, 38, 21, 38, 36, 21, 21,
   21, 38, 21,  0, 34, 34, 34, 52, 34, 34, 34, 34, 34, 34, 34, 38, 38,
   34, 34, 34, 34, 34, 15, 34, 34, 24, 38, 38, 38])

问题是预测返回一个标签编码的预测。如何将其解码为实际标签?

4

1 回答 1

0

而不是使用model.predict(df_valid)use predict_model(model, df_valid)

这将返回df_valid添加的“分数”和“标签”列,后者包含您(我正在)寻找的内容。

于 2021-06-18T23:52:51.697 回答