用XGBoost进行二分类任务的的时候,参数定义如下:
params = {
'booster': 'gbtree',
'objective': 'binary:logistic',
'eval_metric': 'auc',
'gamma': 0.1,
'max_depth': 8,
'alpha': 0,
'lambda': 0,
'subsample': 0.7,
'colsample_bytree': 0.5,
'min_child_weight': 3,
# 'silent': 0,
'eta': 0.03,
'nthread': -1,
'seed': 2019,
}
错误遇到:ValueError: Classification metrics can't handle a mix of binary and continuous targets
在检查了predict和label的维数等之后,发现并不是维数的问题。
最终解决这个问题是发现predict和label的数据类型不同,label是整数,predict是浮点数