How to solve this question (Parameters: { "eval_set", "verbose" } might not be used.?

4.3k Views Asked by At

When I use the XGBoostRegressor to predict the Stock Price, and I try to fit the model.

    # XGBoostRegressor
parameters = {
    'n_estimators': [100, 200, 300, 400],
    'learning_rate': [0.001, 0.005, 0.01, 0.05],
    'max_depth': [8, 10, 12, 15],
    'gamma': [0.001, 0.005, 0.01, 0.02],
    'random_state': [42]
}

eval_set = [(X_train, y_train), (X_valid, y_valid)]
model = xgb.XGBRegressor(eval_set = eval_set, objective = 'reg:squarederror', verbose = False)
clf = GridSearchCV(model, parameters)

clf.fit(X_train, y_train)

print(f'Best params: {clf.best_params_}')
print(f'Best validation score = {clf.best_score_}')

And then I got a WARNING.

Parameters: { "eval_set", "verbose" } might not be used.
  This could be a false alarm, with some parameters getting used by language bindings but
  then being mistakenly passed down to XGBoost core, or some parameter actually being used
  but getting flagged wrongly here. Please open an issue if you find any such cases.

Repeat and Repeat again. I have already changed the parameters, but it did not work. And I did not find any methods to solve it? Did anyone meet this QUESTION? And How to solve it? Thanks.

1

There are 1 best solutions below

2
On

Pass the eval_set and verbose to fit() and not to XGBRegressor()

clf.fit(X_train, y_train, eval_set=eval_set, verbose=False)

Ref.: https://xgboost.readthedocs.io/en/latest/python/python_api.html?highlight=fit#xgboost.XGBRFRegressor.fit