# XGBOOST (sklearn interface) REGRESSION error

I am trying to run a GRIDSEARCHCV (sklearn) on XGBRegressor. Documentation on the parameter says that if regression, then objective = reg:squarederror.(see https://github.com/dmlc/xgboost/tree/master/demo/regression) However, whenever I am trying to run the search, I am getting an error saying XGBoostError: b'[13:39:54] src/objective/objective.cc:23: Unknown objective function reg:squarederror.

I am not sure how to get around this problem. For the sake of completeness, below is the piece of code I am using for this purpose.

cv_params = {
'n_estimators' : np.arange(100, 1201, 100),
'max_depth' : np.arange(2, 10)
}

xgbr_params = {'objective':'reg:squarederror','n_jobs':-1,'random_state':4444,'min_child_weight':1,
'eta':0.3,'subsample':0.8,'gamma':0.5,'colsample_bytree':0.8}

opt_xgbr = GridSearchCV(xgb.XGBRegressor(**xgbr_params)
,param_grid=cv_params,scoring='r2',cv=5,n_jobs=-1,return_train_score=True, verbose=3)


Any help would be greatly appreciated.

Thanks

• What version of xgboost are you using? import xgboost as xgb; xgb.__version__ – TitoOrt Apr 10 '19 at 7:25
• >>> import xgboost as xgb;xgb.__version__ '0.82'. I thought this is the latest version. Am I right? – user62198 Apr 10 '19 at 15:45

Upgrade your xgboost version. reg:squarederror was added in 0.83 release
(In version 0.82 or below, use reg:linear)