25

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.

kaban
  • 423
  • 1
  • 5
  • 10

3 Answers3

30

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

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
ASHISH JETHANI
  • 401
  • 4
  • 4
  • 7
    This is actually the only answer that works (in 2020). silent=True does not work, neither does warnings.filterwarnings('ignore') if you are about to try that. Not sure if this has to do with XGBRegressor not actually classifying its warning messages correctly? Nonetheless verbosity = 0 is what kills of the 100's of endless warnings that occur during a gridsearch for example. – Christoffer Oct 15 '20 at 08:13
  • VSCode, Jupyter, Python 3.8, Linux Mint - works, but doesn't quiet UserWarnings. – Thom Ives Sep 16 '21 at 23:08
5

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

xgboost = xgb.XGBRegressor(random_state=42,silent=True)
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
1

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)
Darkstar Dream
  • 1,649
  • 1
  • 12
  • 23