XGBoostError: [09:48:50] /usr/local/xgboost/src/metric/metric.cc:21: Unknown metric function auc

I am using xgboost for prediction and my main code is as follows:

params={
    'booster':'gbtree',
    'object':'binary:logistic',
    'early_stopping_rounds':100,
    'eval_metric':'auc',
    'gamma':0.1,
    'max_depth':8,
    'lambda':550,
    'subsample':0.7,
    'colsample_bytree':0.2,
    'min_child_weight':3,
    'eta':0.02,
    'seed':2,
    'min_child_weight':0.5,
    'scale_pos_weight':ratio,
    'max_delta_step':5, 
    'nthread':7
}

watch_list = [(dval,'val'),(dtrain,'train')]
xgboost_model = xgb.train(params,dtrain,num_boost_round=500, evals = watch_list)

      

but there is an error:

XGBoostError: [09:48:50] /usr/local/xgboost/src/metric/metric.cc:21: Unknown metric function auc

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/python2.7/dist-packages/xgboost-0.6-
py2.7.egg/xgboost/libxgboost.so(_ZN7xgboost6Metric6CreateERKSs+0x5f7) 
[0x7f0cadfff417]
[bt] (1) /usr/local/lib/python2.7/dist-packages/xgboost-0.6-
py2.7.egg/xgboost/libxgboost.so(_ZN7xgboost11LearnerImpl9ConfigureERKSt6vectorISt4pairISsSsESaIS3_EE+0x717) [0x7f0cae0bfd27]
[bt] (2) /usr/local/lib/python2.7/dist-packages/xgboost-0.6-py2.7.egg/xgboost/libxgboost.so(XGBoosterUpdateOneIter+0x5e) 
[0x7f0cadf6816e]
[bt] (3) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) 
[0x7f0d3a3bcadc]
[bt] (4) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x1fc) [0x7f0d3a3bc40c]
[bt] (5) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(_ctypes_callproc+0x48e) [0x7f0d3a5d35fe]
[bt] (6) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(+0x15f9e) [0x7f0d3a5d4f9e]
[bt] (7) /usr/bin/python(PyEval_EvalFrameEx+0x98d) [0x5244dd]
[bt] (8) /usr/bin/python(PyEval_EvalCodeEx+0x2b1) [0x555551]
[bt] (9) /usr/bin/python(PyEval_EvalFrameEx+0x7e8) [0x524338]

      

+3


source to share


1 answer


I am also facing the same problem. After copy-pasting, sample code from kaggle core. I'll just retype this part:

'eval_metric': "auc"



Then it works without error.

0


source







All Articles