Search code examples
pythonpandasparametersxgboost

Warning about parameters in XGBoost function in Python?


I have sample of code (all code is huge) like below:

def my_xgb(train, validate, features, target, 
            eta=0.03, max_depth=7, subsample = 0.7, colsample_bytree = 0.7, 
            colsample_bylevel=1,lambdaX = 1, alpha=0, gamma=0, min_child_weight=0, 
            rate_drop = 0.2, skip_drop=0.5, 
            num_boost_round = 1000, early_stopping_rounds = 50, 
            debug=True, eval_metric= ["auc"], objective = "binary:logistic", 
            seed=2017, booster = "gbtree", tree_method="exact", grow_policy="depthwise")

....

It is sample of function to calculate XGBoost model, and then when I use code below:

resHists = dict()
rang = range(4,15,2)

for x in rang:
    score, trainPred, testPred, train_history, impFig, imp = run_xgb(X_train_XGB,
                                                                     X_test_XGB,
                                                                     X_XGB,
                                                                     y_XGB,
                                                                     max_depth=x,
                                                                     early_stopping_rounds=50, debug=False)
    resHists[x]=train_history
    print(x, score)
fig, ax = plt.subplots(1, 2, figsize=(14,6))

for x in rang:
    resHists[x][['trainAUC']].add_suffix('_'+str(x)).iloc[10:].plot(ax=ax[0])
    resHists[x][['validAUC']].add_suffix('_'+str(x)).iloc[10:].plot(ax=ax[1])
plt.show()

I have error like below:

[16:53:51] WARNING: C:/Users/Administrator/workspace/xgboost-win64_release_1.3.0/src/learner.cc:541: 
Parameters: { early_stopping_rounds, lambdaX, num_boost_round, rate_drop, silent, skip_drop } might not be used.

  This may not be accurate due to some parameters are only used in language bindings but
  passed down to XGBoost core.  Or some parameters are not used but slip through this
  verification. Please open an issue if you find the above cases.

Code works and calculates everything correct but I have this warning and the below import warning does not help. It can be because of bad spelling of parameters names: { early_stopping_rounds, lambdaX, num_boost_round, rate_drop, silent, skip_drop } but it is also correct spell inf function. How can I get rid of this warning?

import warnings
warnings.filterwarnings("ignore")
warnings.simplefilter(action='ignore', category=FutureWarning)

Solution

  • It seems its a warning from the xgboost package. If you want to suppress you might want to consider something like:

    import xgboost as xgb
    
    xgb.set_config(verbosity=0)
    

    This is extracted from their documentation