【机器学习】xgboost如何不显示warnings

0.环境

xgboost==1.4.1

1.参数参考

https://xgboost.readthedocs.io/en/latest/parameter.html 

verbosity [default=1]

Verbosity of printing messages. 
Valid values are 0 (silent), 1 (warning), 2 (info), 3 (debug). 

Sometimes XGBoost tries to change configurations based on heuristics, which is displayed as warning message. If there’s unexpected behaviour, please try to increase value of verbosity.

 2.实践

# train.py
import xgboost as xgb
model = xgb.XGBClassifier(...,
                         verbosity=0)

运行:

python -W ignore train.py

Guess you like

Origin blog.csdn.net/qq_35975447/article/details/118966976