python-3.xxgboostgridsearchcv

Python notebook supress warning xgboost + GridSearchCV


I am using GridSearchCV to find the best hyper parameters for an XGBoost model. The grid I am using is large, and I want to supress warnings to avoid slowing the code down. I've looked at other questions and have written the following code cells:

import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')
import xgboost as xgb
xgb.set_config(verbosity=0)
gsearch = GridSearchCV(..., jobs=-1)
gsearch.fit(vars, target)

when I run the code, I get the following warning repeatedly:

.venv/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: WARNING: /workspace/src/learner.cc
Parameters: { "scale_pos_weight" } are not used

I suspect it has to do with the number of jobs of the GridSearch run, but I have no clue how to fix it. What do I have to do to get rid of these warnings?


Solution

  • Even though I did not find the answer to my question, I found out that resolving the issue causes the warning to disappear.

    Even if this is most likely the best way to solve this problem in particular, I'd still want to know why the code seems to ignore the warnings settings and how to fix that.