将 XGBoost 模型转换为 CoreML

Converting XGBoost model to CoreML

我正在尝试将以下 XGBoost 模型转换为 CoreML 文件,但出现错误。

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-
  packages/coremltools/converters/xgboost/_tree.py", line 48, in convert
return _MLModel(_convert_tree_ensemble(model, feature_names, target))
File "/usr/local/lib/python2.7/dist-
 packages/coremltools/converters/xgboost/_tree_ensemble.py", line 111, in convert_tree_ensemble
xgb_model_str = model.get_dump(with_stats=True, dump_format = 'json')
TypeError: get_dump() got an unexpected keyword argument 'dump_format'

我使用 pip 安装了 xgboost。为什么会出现这种情况?

按照安装指南进行操作。不要使用 pip install xgboost 否则你会得到 get_dump 这个错误。有关详细信息,请参阅 http://xgboost.readthedocs.io/en/latest/build.html

我的 xgboost 版本是 0.61,后来我换到了 0.81,这解决了我的问题。