我不知道如何用目标函数“multi:softmax”将类数或求值度量传递给xgb.XGBClassifier。
我看了很多文档,但只谈到了接受núclass/numúclass的sklearn包装器。
我当前的设置看起来像kf = cross_validation.KFold(y_data.shape[0], \
n_folds=10, shuffle=True, random_state=30)
err = [] # to hold cross val errors
# xgb instance
xgb_model = xgb.XGBClassifier(n_estimators=_params['n_estimators'], \
max_depth=params['max_depth'], learning_rate=_params['learning_rate'], \
min_child_weight=_params['min_child_weight'], \
subsample=_params['subsample'], \
colsample_bytree=_params['colsample_bytree'], \
objective='multi:softmax', nthread=4)
# cv
for train_index, test_index in kf:
xgb_model.fit(x_data[train_index], y_data[train_index], eval_metric='mlogloss')
predictions = xgb_model.predict(x_data[test_index])
actuals = y_data[test_index]
err.append(metrics.accuracy_score(actuals, predictions))