11

I am training a xgboost model for regression task and I passed the following parameters -

params = {'eta':0.4, 'max_depth':5, 'colsample_bytree':0.6, 'objective':'reg:squarederror'}
num_round = 10
xgb_model = xgboost.train(params, dtrain_x, num_round)

In the training phase I get the following error-

XGBoostError: b'[18:03:23] C:\Users\xgboost\src\objective\objective.cc:23: Unknown objective function reg:squarederror'

While in the docs, it is clearly a valid objective function. Can anyone tell me why am I getting this error?

INFO- I am using python 3.7.3 on windows and xgboost version is 0.82

Ankit Seth
  • 729
  • 1
  • 9
  • 23
  • 3
    Did you try to upgrade xgboost (pip install --upgrade xgboost) and scipy (pip install --upgrade scipy)? It worked for me today. I had the same issue – Lumber Jack May 21 '19 at 14:42
  • 1
    @LumberJack I just upgraded xgboost to version 0.90, it worked. Thanks. – Ankit Seth May 22 '19 at 08:07

1 Answers1

5
xgb_model = xgboost.train(**params, dtrain_x, num_round)

This would work for all versions. It is the way to pass **kwargs as a dictionary.

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

fcdt
  • 2,371
  • 5
  • 14
  • 26
T.singh
  • 71
  • 2
  • 6
  • 2
    This doesn't work in any version, since python doesn't allow keyword arguments before positional arguments. – Quaternion Dec 20 '20 at 13:44