在使用 XGBoost 进行机器学习模型训练和部署时,可能会遇到控制台警告信息,尤其是当模型在不同版本的 XGBoost 之间加载时。虽然这些警告通常不会影响代码的运行,但对于强迫症患者来说,这些警告信息可能会让人感到不适。本文将详细介绍如何解决 XGBoost 控制台警告问题,并分享我在尝试多种方法后,最终通过 xgb.set_config(verbosity=0)
成功解决问题的经验。
问题描述
当你在加载一个通过旧版本 XGBoost 保存的模型时,可能会看到以下警告信息:
[11:31:55] WARNING: C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-0fdc6d574b9c0d168-1\xgboost\xgboost-ci-windows\src\learner.cc:553:
If you are loading a serialized model (like pickle in Python, RDS in R) generated by
older XGBoost, please export the model by calling Booster.save_model from that version
first, then load it back in current version. See:
https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
for more details about differences between saving model and serializing.
这个警告信息的意思是,如果你正在加载一个通过旧版本 XGBoost 序列化的模型(例如使用 pickle