使用CatBoostClassifier的BayesSearchCV进行超参数调整时出错(多类分类)



我正试图用CatBoostClassifier为多类分类调整超参数,但出现以下错误。

ValueError: multiclass format is not supported

我的目标变量包含(0,1,2,3(

请检查下面我已经实现的代码。

accuracy = make_scorer(accuracy_score, greater_is_better=True, needs_threshold=True)
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
clf = CatBoostClassifier(thread_count=2, loss_function='MultiClass', eval_metric='Accuracy', leaf_estimation_method='Newton',  od_type = 'Iter', verbose= False)
# Defining your search space
search_spaces = {'iterations': Integer(10, 2000),
'depth': Integer(1, 12),
'learning_rate': Real(0.01, 1.0, 'log-uniform'),
'random_strength': Real(1e-9, 10, 'log-uniform'),
'bagging_temperature': Real(0.0, 1.0),
'border_count': Integer(1, 255),
'l2_leaf_reg': Integer(2, 30)}
# Setting up BayesSearchCV
opt = BayesSearchCV(clf,
search_spaces,
scoring=accuracy,
cv=skf,
n_iter=100,
n_jobs=1, 
return_train_score=False,
refit=True,
optimizer_kwargs={'base_estimator': 'GP'},
random_state=42)
opt.fit(X_train, y_train)

如果需要更多关于我的问题的细节,请告诉我。请帮我解决这个问题。谢谢

尝试将objective = 'multi:softmax'添加到分类器中,同时设置classes_count

最新更新