小编Rud*_*nko的帖子

ValueError:xgboost不支持多类格式

我的第一个多类分类.我有值X和Y.Y有5个值[0,1,2,3,4].但我得到这个"不支持多类格式".理解我需要xgb_params中的num_class,但是如果我想要'num_class':range(0,5,1)而不是获取estimator XGBClassifier的无效参数num_class.

xgb_model = xgb.XGBClassifier(objective='multi:softmax')

xgb_params  = [
{
"n_estimators": range(50, 501, 50),
}
]
cv = cross_validation.StratifiedShuffleSplit(y_train, n_iter=5, 
test_size=0.3, random_state=42)

xgb_grid = grid_search.GridSearchCV(xgb_model, xgb_params, scoring='roc_auc', cv=cv, n_jobs=-1, verbose=3)
xgb_grid.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)

这个值的例子:

                          X                                     Y
-1.35173485 1.50224188  2.04951167  0.43759658  0.24381777      2
2.81047260  1.31259056  1.39265240  0.16384002  0.65438366      3
2.32878809  -1.92845940 -2.06453246 0.73132270  0.11771229      2
-0.12810555 -2.07268765 -2.40760215 0.97855042  0.11144164      1
1.88682063  0.75792329  -0.09754671 0.46571931  0.62111648      2
-1.09361266 1.74758304  2.49960891  0.36679883  0.88895562      2
0.71760095  -1.30711698 -2.15681966 0.33700593  0.07171119      2
4.60060308  -1.60544855 -1.88996123 0.94500124 …
Run Code Online (Sandbox Code Playgroud)

python xgboost

6
推荐指数
2
解决办法
9591
查看次数

标签 统计

python ×1

xgboost ×1