How to hide warnings from xgboost library in jupyter?

Viewed 17572

Not working:

import warnings
warnings.filterwarnings('ignore')

The warning I get:

[14:24:45] WARNING: C:/Jenkins/workspace/xgboost-win64_release_0.90/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.

It clutters my output in cell.

3 Answers

Change the verbosity parameter verbosity = 0 in the model definition. The values it can take are: 0 - "silent", 1 - "warning", 2 - "info", 3 - "debug"

xgboost = xgb.XGBRegressor(objective ='reg:linear', verbosity = 0, random_state=42)

XGBoost Documentation

Just add silent = True in the model's definition:

xgboost = xgb.XGBRegressor(random_state=42,silent=True)

I had the same issue, and adding both verbose=0 and silent=True helped me

xgboost = xgb.XGBRegressor(objective ='reg:linear', verbosity = 0, silent=True, random_state=42)
Related