xgboostpython分类_xgboost中的多类分类(python)我⽆法弄清楚如何使⽤⽬标函数’multi:softmax’将类数或eval度量传递给xgb.XGBClassifier.
军力排名我查看了许多⽂档,但是关于sklearn包装器的唯⼀讨论是接受n_class / num_class.
我⽬前的设置看起来像
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))