XGBoostError:[09:48:50] /usr/local/xgboost/src/metric/metric.cc:21:未知的度量函数auc

时间:2017-05-20 01:58:17

标签: xgboost

我使用xgboost进行预测,我的主要代码如下:

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)

但是有一个错误:

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]

1 个答案:

答案 0 :(得分:0)

我也面临同样的问题。从kaggle内核复制粘贴示例代码后。我只是重新输入这个部分:

  

'eval_metric':“auc”

然后它没有错误。