首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用BayesSearchCV对CatBoostClassifier (多类分类)进行超参数整定时出错

用BayesSearchCV对CatBoostClassifier (多类分类)进行超参数整定时出错
EN

Stack Overflow用户
提问于 2021-12-10 18:20:29
回答 1查看 109关注 0票数 0

我正在尝试用CatBoostClassifier调优多类分类的超参数,但是得到的错误。

代码语言:javascript
复制
ValueError: multiclass format is not supported

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

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

代码语言:javascript
复制
  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)

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

EN

回答 1

Stack Overflow用户

发布于 2021-12-10 21:09:23

尝试将objective = 'multi:softmax'添加到分类器并设置classes_count

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70308841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档